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

Fix(openfile): avoid returning stale slice caches #5192

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions pkg/meta/openfile.go
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,10 @@ func (o *openfiles) ReadChunk(ino Ino, indx uint32) ([]Slice, bool) {
if !ok {
return nil, false
}
if time.Since(time.Unix(of.lastCheck, 0)) >= o.expire {
SandyXSD marked this conversation as resolved.
Show resolved Hide resolved
of.invalidateChunk()
return nil, false
}
if indx == 0 {
return of.first, of.first != nil
} else {
Expand All @@ -222,6 +226,7 @@ func (o *openfiles) CacheChunk(ino Ino, indx uint32, cs []Slice) {
}
of.chunks[indx] = cs
}
of.lastCheck = time.Now().Unix()
Copy link
Contributor

Choose a reason for hiding this comment

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

The lastCheck is used to indicate the check time of attribute, so should not be updated here.

}

func (o *openfiles) InvalidateChunk(ino Ino, indx uint32) {
Expand Down
Loading