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

src/mds: increment directory inode's change attr by one #48241

Merged
merged 3 commits into from Oct 17, 2022

Conversation

ajarr
Copy link
Contributor

@ajarr ajarr commented Sep 26, 2022

... 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 0d441dcd6af553d11d6be6df56d577c5659904a0 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>

Checklist

  • Tracker (select at least one)
    • References tracker ticket
    • Very recent bug; references commit where it was introduced
    • New feature (ticket optional)
    • Doc update (no ticket needed)
    • Code cleanup (no ticket needed)
  • Component impact
    • Affects Dashboard, opened tracker ticket
    • Affects Orchestrator, opened tracker ticket
    • No impact that needs to be tracked
  • Documentation (select at least one)
    • Updates relevant documentation
    • No doc update is appropriate
  • Tests (select at least one)
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

@github-actions github-actions bot added cephfs Ceph File System tests labels Sep 26, 2022
@gregsfortytwo
Copy link
Member

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? :)

@ajarr
Copy link
Contributor Author

ajarr commented Sep 27, 2022

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.

@ajarr
Copy link
Contributor Author

ajarr commented Sep 27, 2022

@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.

@ajarr
Copy link
Contributor Author

ajarr commented Sep 27, 2022

@vshankar, these are operations that happen on a FS subvolume clone export directory (/volumes///UUID/) when you issue fs subvolume snaphsot clone command.

  • mkdir of export dir
  • setxattr 'ceph.dir.layout.pool' on export dir
  • setattr mode=0755 on export dir
  • files copied over from snapshot created in export dir
  • setattr mtime, atime on export dir

Copy link
Contributor

@jtlayton jtlayton left a 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++;
Copy link
Contributor

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.

@vshankar vshankar requested a review from a team September 28, 2022 03:53
Copy link
Contributor

@vshankar vshankar left a comment

Choose a reason for hiding this comment

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

Great catch!

@gouthampacha
Copy link
Contributor

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!

@vshankar
Copy link
Contributor

@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).

@ajarr
Copy link
Contributor Author

ajarr commented Oct 10, 2022

@vshankar I plan to work on it in a separate PR. This PR can be merged if the tests passed.

Copy link
Member

@batrick batrick left a comment

Choose a reason for hiding this comment

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

Great work!

src/test/libcephfs/test.cc Outdated Show resolved Hide resolved
@ajarr
Copy link
Contributor Author

ajarr commented Oct 13, 2022

In the latest patchset, only made changes to the test to break it down into smaller ones.

@vshankar
Copy link
Contributor

jenkins test api

src/test/libcephfs/test.cc Outdated Show resolved Hide resolved
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>
@ajarr
Copy link
Contributor Author

ajarr commented Oct 14, 2022

In the latest patchset made the following changes to the tests:

  • improved readability of the code comments per Patrick's suggestion
  • checked that change_attr increases everytime ctime is updated. So used ASSERT_GT instead of ASSERT_NE

Copy link
Contributor

@vshankar vshankar left a comment

Choose a reason for hiding this comment

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

@vshankar
Copy link
Contributor

jenkins test api

@vshankar
Copy link
Contributor

jenkins test api

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cephfs Ceph File System tests
Projects
None yet
7 participants