-
Notifications
You must be signed in to change notification settings - Fork 1.1k
fuse: add inode cache invalidation on file open #6326
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
Conversation
Add InodeNotify call in Open method to force kernel cache invalidation when files are opened. This ensures that clients get fresh inode attribute information instead of relying on potentially stale cached data. The change calls fsserv.InodeNotify() with the opened file's inode ID to notify the kernel to invalidate its cached attribute information. This improves consistency across multiple clients accessing the same files. Resolves: juicedata#6323
|
Be careful to not introduce a deadlock when calling |
1. FrequencyInodeNotify is invoked at most once per file—right when it is opened. 2. SafetyIt never endangers the JuiceFS daemon:
3. Deadlock Risk
|
pkg/fuse/fuse.go
Outdated
| } else if entry.Attr.KeepCache { | ||
| out.OpenFlags |= fuse.FOPEN_KEEP_CACHE | ||
| } | ||
| fsserv.InodeNotify(uint64(in.NodeId), -1, 0) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The OpenFlags is used to tell kernel to invalidate data cache.
The returned attribute of Open should overwrite stale attr in kernel, so InodeNotify is not needed, I think.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As far as I know, certain OpenFlags can affect how the kernel handles file caching, but there is no specific flag dedicated to 'invalidating the cache'.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe change to this, only invalidate cache when mtime changed. @yangliping
else if entry.Attr.KeepCache {
out.OpenFlags |= fuse.FOPEN_KEEP_CACHE
} else {
fsserv.InodeNotify(uint64(in.NodeId), -1, 0)
}Move the fsserv.InodeNotifycall inside the else branch to prevent unnecessary notifications.
Add InodeNotify call in Open method to force kernel cache invalidation when files are opened. This ensures that clients get fresh inode attribute information instead of relying on potentially stale cached data.
The change calls fsserv.InodeNotify() with the opened file's inode ID to notify the kernel to invalidate its cached attribute information. This improves consistency across multiple clients accessing the same files.
Resolves: #6323