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

cache attribute and chunks for open files #528

Merged
merged 15 commits into from
Jun 19, 2021
Merged

cache attribute and chunks for open files #528

merged 15 commits into from
Jun 19, 2021

Conversation

davies
Copy link
Contributor

@davies davies commented Jun 17, 2021

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. So OpenCache should be set based on the change interval of files.

TODO: add command option for OpenCache

Closes #454

@davies davies requested a review from SandyXSD June 17, 2021 07:58
o.files[ino] = of
} else if attr != nil && attr.Mtime == of.attr.Mtime && attr.Mtimensec == of.attr.Mtimensec {
attr.KeepCache = true
} else {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

attr.KeepCache = false?

Copy link
Contributor Author

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
Copy link
Contributor

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

@davies davies merged commit 67940a5 into main Jun 19, 2021
@davies davies deleted the opencache branch June 19, 2021 01:41
@daimashusheng
Copy link
Contributor

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.

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

Successfully merging this pull request may close these issues.

Keep page cache in kernel
3 participants