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
src/mds: increment directory inode's change attr by one #48241
Conversation
Nice find tracking down the cause of this bug! The biggest concern here is just making sure we don't have any outstanding places where we set the change_attr to the value of another dirstat or something, because that could rewind us back to having this bug again. Sounds like that's been verified @ajarr? :) |
I tracked down the two instances where directory inode's change_attr was set to its dirstat's change_attr, and made the required changes in this PR. Not much has changed around change_attr since the PR #10922 that introduced it. |
@jtlayton I looked at your PR that introduced change_attr #10922. I don't see much code changes around change_attr tracking since then in Ceph. In this PR, I make changes in the MDS code where directory inode's change_attr were set to its dirstat's change_attr (by 0d441dc), and instead increment the directory inode's change_attr by one as explained in the commit message. |
@vshankar, these are operations that happen on a FS subvolume clone export directory (/volumes///UUID/) when you issue
|
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 all looks good to me. Nice catch @ajarr !
@@ -2543,7 +2543,8 @@ void CInode::finish_scatter_gather_update(int type, MutationRef& mut) | |||
if (touched_mtime) | |||
pi->mtime = pi->ctime = pi->dirstat.mtime; | |||
if (touched_chattr) | |||
pi->change_attr = pi->dirstat.change_attr; | |||
pi->change_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.
I don't know what I was thinking here. Your fix seems obviously correct.
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.
Great catch!
This is great! Thank you @ajarr - looking forward to backports when you have them; and i'll be happy to test with OpenStack in the picture! |
@ajarr you mentioned about an alternate fix. Do you plan to work on it and discuss it here? (A separate PR for that would work too). |
@vshankar I plan to work on it in a separate PR. This PR can be merged if the tests passed. |
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.
Great work!
In the latest patchset, only made changes to the test to break it down into smaller ones. |
jenkins test api |
Alternate operations that only change directory's ctime (setattr/setxattr/removexattr on directory) with those that change directory's mtime and ctime (create/rename/remove a file within directory). Check that directory's change_attr is updated everytime ctime changes. Signed-off-by: Ramana Raja <rraja@redhat.com>
... whenever the mtime or ctime of the directory inode is modified. In CephFS subvolume clones exported using NFS-Ganesha, newly created files using `touch` were not being listed. It was identified that the create request sent to the Ceph MDS via NFS-Ganesha's libcephfs client modified the mtime and ctime of the parent directory, but did not modify the change_attr of the parent directory. Since the NFS client didn't see a modification of the change attribute in the reply, it didn't invalidate its readdir cache. The subsequent directory `ls` was satisfied from the NFS client's stale readdir cache. Whenever parent directory inode's mtime was modified in MDCache::predirty_journal_parents(), the parent inode's change_attr was set to its dirstat->change_attr. The parent inode's dirstat->change_attr doesn't track changes to parent's *ctime only* changes such as setattr, setvxattr, etc. on the parent directory. See commit 0d441dc for more details. This caused the directory inode's change_attr to not be updated when an operation to change only its ctime was followed by an operation to change its mtime and ctime. Fix this by making changes to MDCache::predirty_journal_parents() and CInode::finish_scatter_gather_update() to increment the directory inode's change_attr by one instead of setting it to its dirstat->change_attr. Fixes: https://tracker.ceph.com/issues/57210 Signed-off-by: Ramana Raja <rraja@redhat.com>
Signed-off-by: Ramana Raja <rraja@redhat.com>
In the latest patchset made the following changes to the tests:
|
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.
jenkins test api |
jenkins test api |
... whenever the mtime or ctime of the directory inode is modified.
Checklist
Show available Jenkins commands
jenkins retest this please
jenkins test classic perf
jenkins test crimson perf
jenkins test signed
jenkins test make check
jenkins test make check arm64
jenkins test submodules
jenkins test dashboard
jenkins test dashboard cephadm
jenkins test api
jenkins test docs
jenkins render docs
jenkins test ceph-volume all
jenkins test ceph-volume tox
jenkins test windows