| 3621 | } |
| 3622 | |
| 3623 | void MDSRank::command_dump_dir(Formatter *f, const cmdmap_t &cmdmap, std::ostream &ss) |
| 3624 | { |
| 3625 | std::lock_guard l(mds_lock); |
| 3626 | std::string path; |
| 3627 | bool got = cmd_getval(cmdmap, "path", path); |
| 3628 | if (!got) { |
| 3629 | ss << "missing path argument"; |
| 3630 | return; |
| 3631 | } |
| 3632 | |
| 3633 | bool dentry_dump = false; |
| 3634 | cmd_getval(cmdmap, "dentry_dump", dentry_dump); |
| 3635 | |
| 3636 | CInode *in = mdcache->cache_traverse(filepath(path.c_str())); |
| 3637 | if (!in) { |
| 3638 | ss << "directory inode not in cache"; |
| 3639 | return; |
| 3640 | } |
| 3641 | |
| 3642 | f->open_array_section("dirs"); |
| 3643 | frag_vec_t leaves; |
| 3644 | in->dirfragtree.get_leaves_under(frag_t(), leaves); |
| 3645 | for (const auto& leaf : leaves) { |
| 3646 | CDir *dir = in->get_dirfrag(leaf); |
| 3647 | if (dir) { |
| 3648 | mdcache->dump_dir(f, dir, dentry_dump); |
| 3649 | } else { |
| 3650 | f->open_object_section("frag"); |
| 3651 | f->dump_stream("frag") << leaf; |
| 3652 | f->dump_string("status", "dirfrag not in cache"); |
| 3653 | f->close_section(); |
| 3654 | } |
| 3655 | } |
| 3656 | f->close_section(); |
| 3657 | } |
| 3658 | |
| 3659 | void MDSRank::dump_status(Formatter *f) const |
| 3660 | { |
nothing calls this directly
no test coverage detected