mirror of
https://github.com/borgbackup/borg.git
synced 2026-03-27 04:44:05 -04:00
fuse: get rid of chunk accounting
the chunk accounting code tried to reflect repo space usage via the st_blocks of the files. so, a specific chunk that was shared between multiple files [inodes] was only accounted for one specific file. thus, the overall "du" of everything in the fuse mounted repo was maybe correctly reflecting the repo space usage, but the decision which file has the chunk (the space) was kind of arbitrary and not really useful. otoh, a simple fuse getattr() was rather expensive due to this as it needed to iterate over the chunks list to compute the st_blocks value. also it needed quite some memory for the accounting. thus, st_blocks is now just ceil(size / blocksize). also: fixed bug that st_blocks was a floating point value previously. also: preparing for further optimization of size computation (see next cs)
This commit is contained in:
parent
a52b54dc3c
commit
fe8e14cb2c
1 changed files with 1 additions and 7 deletions
|
|
@ -72,7 +72,6 @@ class FuseOperations(llfuse.Operations):
|
|||
self.contents = defaultdict(dict)
|
||||
self.default_dir = Item(mode=0o40755, mtime=int(time.time() * 1e9), uid=os.getuid(), gid=os.getgid())
|
||||
self.pending_archives = {}
|
||||
self.accounted_chunks = {}
|
||||
self.cache = ItemCache()
|
||||
data_cache_capacity = int(os.environ.get('BORG_MOUNT_DATA_CACHE_ENTRIES', os.cpu_count() or 1))
|
||||
logger.debug('mount data cache capacity: %d chunks', data_cache_capacity)
|
||||
|
|
@ -258,14 +257,9 @@ class FuseOperations(llfuse.Operations):
|
|||
def getattr(self, inode, ctx=None):
|
||||
item = self.get_item(inode)
|
||||
size = 0
|
||||
dsize = 0
|
||||
if 'chunks' in item:
|
||||
# if we would not need to compute dsize, we could get size quickly from item.size, if present.
|
||||
for key, chunksize, _ in item.chunks:
|
||||
size += chunksize
|
||||
if self.accounted_chunks.get(key, inode) == inode:
|
||||
self.accounted_chunks[key] = inode
|
||||
dsize += chunksize
|
||||
entry = llfuse.EntryAttributes()
|
||||
entry.st_ino = inode
|
||||
entry.generation = 0
|
||||
|
|
@ -278,7 +272,7 @@ class FuseOperations(llfuse.Operations):
|
|||
entry.st_rdev = item.get('rdev', 0)
|
||||
entry.st_size = size
|
||||
entry.st_blksize = 512
|
||||
entry.st_blocks = dsize / 512
|
||||
entry.st_blocks = (size + entry.st_blksize - 1) // entry.st_blksize
|
||||
# note: older archives only have mtime (not atime nor ctime)
|
||||
mtime_ns = item.mtime
|
||||
if have_fuse_xtime_ns:
|
||||
|
|
|
|||
Loading…
Reference in a new issue