Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to properly implement filesystem notifications (fsnotify) #320

Open
markg85 opened this issue Nov 23, 2024 · 0 comments
Open

How to properly implement filesystem notifications (fsnotify) #320

markg85 opened this issue Nov 23, 2024 · 0 comments

Comments

@markg85
Copy link

markg85 commented Nov 23, 2024

Hi,

I'm working on a filesystem implementation with this, rather nice, library!

The thing i'm stuck on is the concept of how to properly implement fsnotify support.
When i look at the two [1, 2] provided examples then the current way seems to be:

  • Run a filesystem update loop in a set interval (1 second)
  • Send filesystem updates in that loop

When you have a file that changes every second (like the examples demonstrate) then this logic probably works just fine.
But that's not a realistic scenario.

What i did find out, or i'm wrong, is that fsnotify events should be send outside the code path of where you create/update/delete files themselves to prevent deadlocks. So executing a create call immediately followed by an fsnotify notifier.inval_entry (notifier comes from the Session object) is a big no-no. Thus a serial approach of create -> notify event does not seem to be an option.

This makes me think/assume that i should:

  • Build a queue of filesystem events
  • Have a separate thread where that queue is read and send to the kernel

Is that the intended approach of fsnotify support?
If not, what is the intended approach?

For reference, i'm making a filesystem that essentially exposes external data (think of a web api) to a local filesystem. I'm receiving events from that external source which i need to map to fsnotify events.

[1] https://github.com/cberner/fuser/blob/master/examples/notify_inval_entry.rs
[2] https://github.com/cberner/fuser/blob/master/examples/notify_inval_inode.rs

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant