mirror of
https://github.com/borgbackup/borg.git
synced 2024-12-26 01:37:20 +00:00
repository: fix used quota computation
storage_quota_use should reflect current disk space usage (not considering some overheads like for the index etc.). if a chunk is deleted, but the segment file containing the chunk is not yet compacted, the chunk's disk space is still in use! when compact_segments is dropping the unused chunks, it is the right time to reduce storage_quota_use. storage_quota_use includes the put header overhead.
This commit is contained in:
parent
75cbab3773
commit
f4b9f63856
1 changed files with 2 additions and 3 deletions
|
@ -806,6 +806,7 @@ def complete_xfer(intermediate=True):
|
||||||
# do not remove entry with empty shadowed_segments list here,
|
# do not remove entry with empty shadowed_segments list here,
|
||||||
# it is needed for shadowed_put_exists code (see below)!
|
# it is needed for shadowed_put_exists code (see below)!
|
||||||
pass
|
pass
|
||||||
|
self.storage_quota_use -= len(data) + self.io.put_header_fmt.size
|
||||||
elif tag == TAG_DELETE and not in_index:
|
elif tag == TAG_DELETE and not in_index:
|
||||||
# If the shadow index doesn't contain this key, then we can't say if there's a shadowed older tag,
|
# If the shadow index doesn't contain this key, then we can't say if there's a shadowed older tag,
|
||||||
# therefore we do not drop the delete, but write it to a current segment.
|
# therefore we do not drop the delete, but write it to a current segment.
|
||||||
|
@ -906,7 +907,7 @@ def _update_index(self, segment, objects, report=None):
|
||||||
pass
|
pass
|
||||||
self.index[key] = segment, offset
|
self.index[key] = segment, offset
|
||||||
self.segments[segment] += 1
|
self.segments[segment] += 1
|
||||||
self.storage_quota_use += size
|
self.storage_quota_use += size # note: size already includes the put_header_fmt overhead
|
||||||
elif tag == TAG_DELETE:
|
elif tag == TAG_DELETE:
|
||||||
try:
|
try:
|
||||||
# if the deleted PUT is not in the index, there is nothing to clean up
|
# if the deleted PUT is not in the index, there is nothing to clean up
|
||||||
|
@ -919,7 +920,6 @@ def _update_index(self, segment, objects, report=None):
|
||||||
# is already gone, then it was already compacted.
|
# is already gone, then it was already compacted.
|
||||||
self.segments[s] -= 1
|
self.segments[s] -= 1
|
||||||
size = self.io.read(s, offset, key, read_data=False)
|
size = self.io.read(s, offset, key, read_data=False)
|
||||||
self.storage_quota_use -= size
|
|
||||||
self.compact[s] += size
|
self.compact[s] += size
|
||||||
elif tag == TAG_COMMIT:
|
elif tag == TAG_COMMIT:
|
||||||
continue
|
continue
|
||||||
|
@ -1239,7 +1239,6 @@ def _delete(self, id, segment, offset, *, update_shadow_index):
|
||||||
self.shadow_index.setdefault(id, []).append(segment)
|
self.shadow_index.setdefault(id, []).append(segment)
|
||||||
self.segments[segment] -= 1
|
self.segments[segment] -= 1
|
||||||
size = self.io.read(segment, offset, id, read_data=False)
|
size = self.io.read(segment, offset, id, read_data=False)
|
||||||
self.storage_quota_use -= size
|
|
||||||
self.compact[segment] += size
|
self.compact[segment] += size
|
||||||
segment, size = self.io.write_delete(id)
|
segment, size = self.io.write_delete(id)
|
||||||
self.compact[segment] += size
|
self.compact[segment] += size
|
||||||
|
|
Loading…
Reference in a new issue