Skip to content

mds: add a command to dump directory information#49756

Merged
vshankar merged 2 commits intoceph:mainfrom
zhsgao:mds_dump_dir
Mar 2, 2023
Merged

mds: add a command to dump directory information#49756
vshankar merged 2 commits intoceph:mainfrom
zhsgao:mds_dump_dir

Conversation

@zhsgao
Copy link
Contributor

@zhsgao zhsgao commented Jan 16, 2023

Signed-off-by: Zhansong Gao zhsgao@hotmail.com

Contribution Guidelines

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 the cephfs Ceph File System label Jan 16, 2023
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.

@zhsgao Could you add a test case for this? qa/tasks/cephfs/test_fragment.py

@zhsgao
Copy link
Contributor Author

zhsgao commented Jan 25, 2023

@zhsgao Could you add a test case for this? qa/tasks/cephfs/test_fragment.py

The tests for dump inode is in test_misc.py and tests for dump tree is in test_dump_tree.py, maybe we can put tests for dump dir in one of these two files?

@vshankar
Copy link
Contributor

@zhsgao Could you add a test case for this? qa/tasks/cephfs/test_fragment.py

The tests for dump inode is in test_misc.py and tests for dump tree is in test_dump_tree.py, maybe we can put tests for dump dir in one of these two files?

Sounds good.

f->open_object_section("resolve_status");
f->dump_stream("resolve_gather") << resolve_gather;
f->dump_stream("resolve_ack_gather") << resolve_gather;
f->dump_stream("resolve_ack_gather") << resolve_ack_gather;
Copy link
Contributor

Choose a reason for hiding this comment

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

Advisable to make this a separate commit ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Advisable to make this a separate commit ?

I have separated it into a new PR #49882.

@zhsgao
Copy link
Contributor Author

zhsgao commented Jan 26, 2023

@zhsgao Could you add a test case for this? qa/tasks/cephfs/test_fragment.py

The tests for dump inode is in test_misc.py and tests for dump tree is in test_dump_tree.py, maybe we can put tests for dump dir in one of these two files?

Sounds good.

OK! I have done it.

@dparmar18
Copy link
Contributor

@zhsgao can you create a separate commit for the test? It would be less cluttered that way

@zhsgao
Copy link
Contributor Author

zhsgao commented Jan 29, 2023

@zhsgao can you create a separate commit for the test? It would be less cluttered that way

OK! I have done it.

@dparmar18
Copy link
Contributor

@zhsgao can you create a separate commit for the test? It would be less cluttered that way

OK! I have done it.

Thanks, although a slight change can be done for the commit title - qa: add test for 'dump dir'

Also, this might also need to be documented somewhere, maybe in PendingReleaseNotes or in doc/

@zhsgao
Copy link
Contributor Author

zhsgao commented Jan 30, 2023

@zhsgao can you create a separate commit for the test? It would be less cluttered that way

OK! I have done it.

Thanks, although a slight change can be done for the commit title - qa: add test for 'dump dir'

Also, this might also need to be documented somewhere, maybe in PendingReleaseNotes or in doc/

I have modified the commit title.
I tried to search for similar commands like dump inode or dump tree in doc/ but found nothing, so I have no idea how to add documentation for dump dir.

@dparmar18
Copy link
Contributor

@zhsgao can you create a separate commit for the test? It would be less cluttered that way

OK! I have done it.

Thanks, although a slight change can be done for the commit title - qa: add test for 'dump dir'
Also, this might also need to be documented somewhere, maybe in PendingReleaseNotes or in doc/

I have modified the commit title. I tried to search for similar commands like dump inode or dump tree in doc/ but found nothing, so I have no idea how to add documentation for dump dir.

yeah, those are asok commands, and a lot of them have not been documented anywhere. maybe we need a place in docs or somewhere else to dump info about these commands. @vshankar what do you think?


bool MDCache::dump_dir(Formatter *f, CDir *dir) {
f->open_object_section("dir");
dir->dump(f);
Copy link
Contributor

Choose a reason for hiding this comment

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

This, by default, does not dump dentry items. Should that be made optional?

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, by default, does not dump dentry items. Should that be made optional?

Yes, I think it's a good idea and I have added an option for it. Thanks!

@vshankar
Copy link
Contributor

@zhsgao can you create a separate commit for the test? It would be less cluttered that way

OK! I have done it.

Thanks, although a slight change can be done for the commit title - qa: add test for 'dump dir'
Also, this might also need to be documented somewhere, maybe in PendingReleaseNotes or in doc/

I have modified the commit title. I tried to search for similar commands like dump inode or dump tree in doc/ but found nothing, so I have no idea how to add documentation for dump dir.

yeah, those are asok commands, and a lot of them have not been documented anywhere. maybe we need a place in docs or somewhere else to dump info about these commands. @vshankar what do you think?

Let's do doc changes in a separate PR.

Copy link
Contributor

@kotreshhr kotreshhr left a comment

Choose a reason for hiding this comment

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

LGTM

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.

LGTM

def test_dump_dir(self):
self.mount_a.run_shell(["mkdir", "-p", "foo/bar"])
dirs = self.fs.mds_asok(['dump', 'dir', '/foo'])
assert type(dirs) is list
Copy link
Contributor

Choose a reason for hiding this comment

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

minor nit: use self.assertTrue()

Copy link
Contributor Author

Choose a reason for hiding this comment

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

minor nit: use self.assertTrue()

Thanks! I have modified them.

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.

Otherwise LGTM.

Comment on lines +13491 to +13495
bool MDCache::dump_dir(Formatter *f, CDir *dir, bool dentry_dump) {
f->open_object_section("dir");
dir->dump(f, dentry_dump ? CDir::DUMP_ALL : CDir::DUMP_DEFAULT);
f->close_section();
return true;
}
Copy link
Contributor

Choose a reason for hiding this comment

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

code looks good, just a question: is there any reason for this function to have bool return type? I think void would do too

Copy link
Contributor Author

Choose a reason for hiding this comment

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

code looks good, just a question: is there any reason for this function to have bool return type? I think void would do too

I have modified it. At first I referred to dump_inode and the type of its return value is boolean.

dirs = self.fs.mds_asok(['dump', 'dir', '/foo'])
assert type(dirs) is list
for dir in dirs:
assert dir['path'] == "/foo"
Copy link
Contributor

Choose a reason for hiding this comment

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

as venky mentioned, using self.assert* would be better, do try to replace all assertions if possible, for e.g you can use self.assertEquals() here

Copy link
Contributor Author

Choose a reason for hiding this comment

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

as venky mentioned, using self.assert* would be better, do try to replace all assertions if possible, for e.g you can use self.assertEquals() here

OK! I have replaced all assertions in this file.

Copy link
Contributor

Choose a reason for hiding this comment

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

thanks! but i guess you got me a little bit wrong, by all i meant those in your test case. However if you feel you want to replace them as well, maybe that can be done separately in another commit, but i'm not very sure about it.

Signed-off-by: Zhansong Gao <zhsgao@hotmail.com>
Signed-off-by: Zhansong Gao <zhsgao@hotmail.com>
Copy link
Contributor

@dparmar18 dparmar18 left a comment

Choose a reason for hiding this comment

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

just some minor touchups in test case file, else LGTM

@vshankar
Copy link
Contributor

Test ran successfully with this change - https://pulpito.ceph.com/vshankar-2023-02-24_02:11:45-fs-wip-vshankar-testing-20230222.025426-testing-default-smithi/

Failures are not related to this PR.

@vshankar
Copy link
Contributor

jenkins retest this please

@batrick
Copy link
Member

batrick commented Feb 28, 2023

jenkins test make check

@batrick
Copy link
Member

batrick commented Feb 28, 2023

jenkins test make check arm64

vshankar added a commit to vshankar/ceph that referenced this pull request Mar 2, 2023
* refs/pull/49756/head:
	qa: add test for 'dump dir'
	mds: add a command to dump directory information

Reviewed-by: Dhairya Parmar <dparmar@redhat.com>
Reviewed-by: Kotresh Hiremath Ravishankar <khiremat@redhat.com>
Reviewed-by: Venky Shankar <vshankar@redhat.com>
Reviewed-by: Rishabh Dave <ridave@redhat.com>
@vshankar vshankar merged commit 7f65724 into ceph:main Mar 2, 2023
@trociny
Copy link
Contributor

trociny commented Oct 4, 2023

@vshankar @zhsgao It looks like a very useful command, but it seems like there are no plans to backport it? Right now even reef misses it. Do you think it would be a good idea to create backport tickets (and PRs) for it? I could do it. I would like to have backports down to pacific unless it relies on a new functionality.

@vshankar
Copy link
Contributor

vshankar commented Oct 4, 2023

@vshankar @zhsgao It looks like a very useful command, but it seems like there are no plans to backport it? Right now even reef misses it. Do you think it would be a good idea to create backport tickets (and PRs) for it? I could do it. I would like to have backports down to pacific unless it relies on a new functionality.

Sure thing - please do the needful @trociny. I think we should also address https://github.com/ceph/ceph/pull/49756/files#r1120348923 and then backport both changes. I'll create a tracker.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

9 participants