Skip to content

Commit b6a0e43

Browse files
committed
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
1 parent 850bd3e commit b6a0e43

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

cmd/distri/internal/fuse/fuse.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -917,6 +917,7 @@ func (fs *fuseFS) LookUpInode(ctx context.Context, op *fuseops.LookUpInodeOp) er
917917
}
918918
return nil
919919
}
920+
// TODO: switch to returning nil once we invalidate the cache
920921
return fuse.ENOENT
921922
} else { // overlay directory
922923
fs.mu.Lock()
@@ -927,7 +928,7 @@ func (fs *fuseFS) LookUpInode(ctx context.Context, op *fuseops.LookUpInodeOp) er
927928
}
928929
dirent, ok := dir.byName[op.Name]
929930
if !ok {
930-
return fuse.ENOENT
931+
return nil // same as ENOENT when op.Entry.Child is 0
931932
}
932933
op.Entry.Child = dirent.inode
933934
op.Entry.Attributes = fuseops.InodeAttributes{
@@ -975,7 +976,7 @@ func (fs *fuseFS) LookUpInode(ctx context.Context, op *fuseops.LookUpInodeOp) er
975976

976977
cie, ok := fis[op.Name]
977978
if !ok {
978-
return fuse.ENOENT
979+
return nil // same as ENOENT when op.Entry.Child is 0
979980
}
980981
op.Entry.Child = cie.Child
981982
op.Entry.Attributes = cie.Attributes

0 commit comments

Comments
 (0)