-
Notifications
You must be signed in to change notification settings - Fork 999
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
cache attribute and chunks for open files #528
Conversation
o.files[ino] = of | ||
} else if attr != nil && attr.Mtime == of.attr.Mtime && attr.Mtimensec == of.attr.Mtimensec { | ||
attr.KeepCache = true | ||
} else { |
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.
attr.KeepCache = false?
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.
This is the only place to assign KeepCache (initialized as zero).
defer o.Unlock() | ||
of, ok := o.files[ino] | ||
if ok && time.Since(of.lastCheck) < o.expire { | ||
*attr = of.attr |
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.
attr must not be nil
May I ask, if I only use juicefs on linux, is it possible to do same thing without the openfile.go? I just need to mount filesystem without setting ExplicitDataCacheControl of MountOptions and always set FOPEN_KEEP_CACHE when I open a file, because linux kernel can invalidates the page cache by detecting the length or the modification time of the file has changed. |
For not-modified files, we should keep the page cache in kernel, also cache the chunks to speed up read.
For any changes to the data, the mtime of file will be updated in microseconds, so we can check the mtime to know whether the file is changed or not. If not, we will keep the cache for chunks and pages in kernel, otherwise invalidate them.
And, we introduce a new option called
OpenCache
, which tell the client to don't check the mtime of a file before that, then JuiceFS will not know any change in the past period. SoOpenCache
should be set based on the change interval of files.TODO: add command option for OpenCache
Closes #454