-
Notifications
You must be signed in to change notification settings - Fork 1k
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 two inconsistency issues between stat cache and cache file #2152
Conversation
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.
Could you tell us the issue(reason) that led you to submit this PR?
I still don't understand the purpose of this PR fix.
(I've added comments where I think it's intended.)
Therefore, I apologize for the inconvenience, but please let me know the phenomenon that led to the submission of the PR.
Sorry for the late reply.. For both patches, I didn't hit any problems in real uses, just noticed the potential issues when I was reading the code. The first patch "Fix inconsistency between stat cache file and cache file", if cache file needs truncate ( 623 // truncate cache(tmp) file
624 if(is_truncate){
625 if(0 != ftruncate(physical_fd, size) || 0 != fsync(physical_fd)){
626 S3FS_PRN_ERR("ftruncate(%s) or fsync returned err(%d)", cachepath.c_str(), errno);
627 fclose(pfile);
628 pfile = NULL;
629 physical_fd = -1;
630 inode = 0;
631 return (0 == errno ? -EIO : -errno);
632 }
633 }
634
635 // reset cache stat file
636 if(need_save_csf){
637 if(!pagelist.Serialize(cfstat, true, inode)){
638 S3FS_PRN_WARN("failed to save cache stat file(%s), but continue...", path.c_str());
639 }
640 } The second patch "Mark pagelist as unloaded if cache file has been truncated", in case of cache file was truncated to a smaller size and didn't match cache stat file, the |
@eryugey |
"Fix inconsistency between stat cache file and cache file"I understood your issue regarding about this. "Mark pagelist as unloaded if cache file has been truncated"Also I understood about this. SuggestionAbout the above two modifications, I wrote the code that I wanted you to modify for this PR code.(That code has been modified in line with my comment above.) Thanks in advance for your assistance.
|
Thanks for the suggestions! I'll find some free cycles to update this PR according to your suggestions. |
We unlock stat cache file too early in FdEntity::Open(), and would truncate cache file and update stat cache file, so there's a window that stat cache doesn't reflect cache file status. Suggested-by: Takeshi Nakatani <ggtakec@gmail.com> Signed-off-by: Eryu Guan <eguan@linux.alibaba.com>
If cache file size doesn't match object size, the cache file might be corrupted, so invalidate it and save new cache stat file. Suggested-by: Takeshi Nakatani <ggtakec@gmail.com> Signed-off-by: Eryu Guan <eguan@linux.alibaba.com>
All fixed, PTAL. |
@eryugey Thank you for your correction and your contribution. |
Previously pcfstat points to a raw pointer, and it may be leaked if function returned before deleting it. So use unique_ptr to automatically release the object. Fixes: 6ca5a24 ("Fix two inconsistency issues between stat cache and cache file (s3fs-fuse#2152)") Signed-off-by: Eryu Guan <eguan@linux.alibaba.com>
Previously pcfstat points to a raw pointer, and it may be leaked if function returned before deleting it. So use unique_ptr to automatically release the object. Fixes: 6ca5a24 ("Fix two inconsistency issues between stat cache and cache file (s3fs-fuse#2152)") Signed-off-by: Eryu Guan <eguan@linux.alibaba.com>
Previously pcfstat points to a raw pointer, and it may be leaked if function returned before deleting it. So use unique_ptr to automatically release the object. Fixes: 6ca5a24 ("Fix two inconsistency issues between stat cache and cache file (s3fs-fuse#2152)") Signed-off-by: Eryu Guan <eguan@linux.alibaba.com>
Previously pcfstat points to a raw pointer, and it may be leaked if function returned before deleting it. So use smart pointer to automatically release the object. Note that currently s3fs only uses c++03, so we use auto_ptr here, not unique_ptr, which requires c++11. Fixes: 6ca5a24 ("Fix two inconsistency issues between stat cache and cache file (s3fs-fuse#2152)") Signed-off-by: Eryu Guan <eguan@linux.alibaba.com>
Previously pcfstat points to a raw pointer, and it may be leaked if function returned before deleting it. So use smart pointer to automatically release the object. Note that currently s3fs only uses c++03, so we use auto_ptr here, not unique_ptr, which requires c++11. Fixes: 6ca5a24 ("Fix two inconsistency issues between stat cache and cache file (s3fs-fuse#2152)") Signed-off-by: Eryu Guan <eguan@linux.alibaba.com>
Previously pcfstat points to a raw pointer, and it may be leaked if function returned before deleting it. So use smart pointer to automatically release the object. Note that currently s3fs only uses c++03, so we use auto_ptr here, not unique_ptr, which requires c++11. Fixes: 6ca5a24 ("Fix two inconsistency issues between stat cache and cache file (#2152)") Signed-off-by: Eryu Guan <eguan@linux.alibaba.com>
@eryugey could you share more about your use case? We have not seen users attempting to share a cache directory between multiple s3fs instances before. I don't think we guarantee any atomicity of these files. |
I'm trying to use a distributed filesystem as s3fs's cache dir, so multiple s3fs instances may share the same cache to speed up I/O performance. |
…fuse#2152) commit 6ca5a24 upstream * Fix inconsistency between stat cache file and cache file We unlock stat cache file too early in FdEntity::Open(), and would truncate cache file and update stat cache file, so there's a window that stat cache doesn't reflect cache file status. Suggested-by: Takeshi Nakatani <ggtakec@gmail.com> Signed-off-by: Eryu Guan <eguan@linux.alibaba.com> * Mark pagelist as unloaded if cache file has been truncated If cache file size doesn't match object size, the cache file might be corrupted, so invalidate it and save new cache stat file. Suggested-by: Takeshi Nakatani <ggtakec@gmail.com> Signed-off-by: Eryu Guan <eguan@linux.alibaba.com> --------- Fixes: #49342993 Fixes: #49342673 Reference: s3fs-fuse#2152 Signed-off-by: Eryu Guan <eguan@linux.alibaba.com>
Details