go-fuse icon indicating copy to clipboard operation
go-fuse copied to clipboard

Prevent rename() spuriously returning ENOENT.

Open EdSchouten opened this issue 6 years ago • 3 comments

I'm implementing a file system that does its own bookkeeping of files stored in a directory. I need to do this, due to the file sytem also being accessible without going through FUSE. At certain phases, it's even the case the file system is only in-memory and not even exposed through FUSE.

To keep things simple, I've made it so that upon renames and unlinks, I only call into RmChild(). I rely ook Lookup() to expose files once again afterwards. This approach currently causes me to observe some spurious ENOENTs due to the EBUSY check for mount point renaming. Move both checks into one, eliminating the ENOENT return.

EdSchouten avatar Jan 29 '19 09:01 EdSchouten

can you rephrase this without referencing your specific FS, but what general pattern you want to support?

explain why returning ENOENT is not necessary (kernel issues LOOKUP to verify that the source exists)

hanwen avatar Jan 30 '19 19:01 hanwen

Not sure what the problem for the OP is, but the check at https://github.com/hanwen/go-fuse/blob/8020c1880dbdc4bcc1834e9786407edbc3872bdb/fuse/nodefs/fsops.go#L322 is racy in any case, isn't it? The file may have disappeared by the time we reach oldParent.fsInode.Rename()

rfjakob avatar Jan 30 '19 20:01 rfjakob

I think the VFS has locking to prevent the race. Of course, if change the tree behind the kernel's back, things might still go wrong, and you have to have locking on the FS implementation

hanwen avatar Jan 31 '19 10:01 hanwen

is this still an issue with the fs API ?

hanwen avatar Apr 23 '23 21:04 hanwen

Hey! Unfortunately I wouldn’t know. In the meantime I have switched to just using RawFileSystem which works great for me.

Happy to close this if desired.

EdSchouten avatar Apr 24 '23 06:04 EdSchouten