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

Reintroduce lookup/forget calls as notifications #20

Open
albel727 opened this issue Oct 20, 2017 · 4 comments
Open

Reintroduce lookup/forget calls as notifications #20

albel727 opened this issue Oct 20, 2017 · 4 comments

Comments

@albel727
Copy link

It would be nice to have lookup(&Path)/forget(&Path) methods getting called when an inode is looked up for the first time/is removed after it's forgotten for the last time. The methods are not intended to do or return anything that Fuse would rely on, like actual lookup. The default implementations would be empty and hence optimized out.

It is useful to keep track of what kernel actually needs at the moment. For a FS that I'm writing I have to associate some resources with some files and directories, and it would lend itself well to allocate/free these resources on actual demand.

@wfraser
Copy link
Owner

wfraser commented Oct 20, 2017

Sounds reasonable. Only question I have is whether lookup is really necessary, because if you have forget, you can just check in getattr if you have seen a request for that path before or not. But it's easy to add, and fuse provides both for a reason. :)

@albel727
Copy link
Author

Checking in getattr will mean excess lookup in user's HashMap and/or excess write locking of an RwLock that wraps user's HashMap. I think it's better to avoid that and provide for separation of concerns with a distinct lookup notification.

In fact, I'm not sure there isn't some possible utility in notifying user not just on first lookup/last forget, but on every one of them. And so it might be prudent to also pass the increment and current ref count (e.g. before increment for lookup and after increment for forget, so that count == 0 condition would be true for the first/last ref special cases). And then lookup(p: Path, count: u64, increment: u64) won't conflate with getattr(Path, Option<FileHandle>) at all.

@albel727
Copy link
Author

After looking more closely, it seems implementing lookup/forget notifications with actually useful semantics isn't exactly straightforward. I'll show you my take on it, if I manage to, otherwise consider me never having posted this feature request.

@albel727
Copy link
Author

Path-based notifications aren't very useful, after all. User will have to track renames, and it's not even obvious what to do with paths on unlinks and shadowing renames. And exposing inodes isn't straightforward because lookup() notification with inode should ideally be delivered before calls to any other methods using said inode, but the current code doesn't allocate an inode until after a successful call to target.getattr()/other entry creation call. Unless inodes are preallocated and passed to all handlers, nothing makes sense.

I guess I'll just have to use rust-fuse directly. You may close this issue, unless you intend to implement something like what's described in #21.

wfraser added a commit that referenced this issue Nov 8, 2017
Just as notifications to the filesystem implementation; no return value.

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

No branches or pull requests

2 participants