Skip to content
Permalink
Browse files
fuse: instead of ENOENT, return nil with op.Entry.Child == 0
The kernel treats a zero nodeid the same as ENOENT, but respects caching:

https://github.com/torvalds/linux/blob/2019fc96af228b412bdb2e8e0ad4b1fc12046a51/fs/fuse/dir.c#L353

This significantly reduces FUSE requests, e.g. during package builds:

before:
distri build -pkg=gtk+-2  438,42s user 160,10s system 569% cpu 1:45,12 total
distri build -pkg=gtk+-2  435,83s user 157,86s system 572% cpu 1:43,78 total

after:
distri build -pkg=gtk+-2  372,39s user 84,34s system 809% cpu 56,400 total
distri build -pkg=gtk+-2  373,22s user 85,02s system 812% cpu 56,366 total

related to #59
  • Loading branch information
stapelberg committed Feb 15, 2020
1 parent 850bd3e commit b6a0e43368d54d5ed0e03af687158dc3e2106e38
Showing 1 changed file with 3 additions and 2 deletions.
@@ -917,6 +917,7 @@ func (fs *fuseFS) LookUpInode(ctx context.Context, op *fuseops.LookUpInodeOp) er
}
return nil
}
// TODO: switch to returning nil once we invalidate the cache
return fuse.ENOENT
} else { // overlay directory
fs.mu.Lock()
@@ -927,7 +928,7 @@ func (fs *fuseFS) LookUpInode(ctx context.Context, op *fuseops.LookUpInodeOp) er
}
dirent, ok := dir.byName[op.Name]
if !ok {
return fuse.ENOENT
return nil // same as ENOENT when op.Entry.Child is 0
}
op.Entry.Child = dirent.inode
op.Entry.Attributes = fuseops.InodeAttributes{
@@ -975,7 +976,7 @@ func (fs *fuseFS) LookUpInode(ctx context.Context, op *fuseops.LookUpInodeOp) er

cie, ok := fis[op.Name]
if !ok {
return fuse.ENOENT
return nil // same as ENOENT when op.Entry.Child is 0
}
op.Entry.Child = cie.Child
op.Entry.Attributes = cie.Attributes

0 comments on commit b6a0e43

Please sign in to comment.