fuse icon indicating copy to clipboard operation
fuse copied to clipboard

Add support for inode and dentry invalidation.

Open cjc25 opened this issue 7 months ago • 2 comments

Package fusekernel already had definitions of the NotifyInvalInodeOut and NotifyInvalEntryOut structures. We add a Notifier, which allows filesystem implementations to use those to invalidate kernel cache entries.

By using these invalidation mechanisms, user code can still mostly use the page cache, but with some feedback from the filesystem daemon when contents have changed dynamically.

cjc25 avatar May 14 '25 01:05 cjc25

This is somewhat similar to #140 . Some comparisons:

  • Instead of injecting the Connection into the FileSystem interface, this PR uses a wrapper Server, since ServeOps already had access to the Connection
  • Instead of allowing any calls to Connection functions, this PR wraps the writes by requiring the use of an interface in package fuse to issue the writes/notifications
  • #140 writes to the fd directly and risks nil dereference on Connection. This PR wraps the writes in channels to serialize them (probably unnecessary, but convenient to think about), and risks deadlock if an Invalidate function must return before ServeOps can be called (which would be Weird, IMO).
  • Both PRs allow the fuse Server to deadlock if the user performs an invalidation while a "related operation" is outstanding.
  • This PR has a test implementation :). It mirrors the similar test implementations in libfuse.

cjc25 avatar May 14 '25 02:05 cjc25

Nice! Thanks for the clean PR. It passes CI, passes tests and seems to work in a quick manual test.

I am inclined to merge it.

@vitalif This should work for your use-case over in PR #140, too, right?

stapelberg avatar May 20 '25 21:05 stapelberg