return true;
}
+void 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();
+}
+
void MDCache::handle_mdsmap(const MDSMap &mdsmap, const MDSMap &oldmap) {
const mds_rank_t max_mds = mdsmap.get_max_mds();
void clean_open_file_lists();
void dump_openfiles(Formatter *f);
bool dump_inode(Formatter *f, uint64_t number);
+ void dump_dir(Formatter *f, CDir *dir, bool dentry_dump=false);
void rejoin_start(MDSContext *rejoin_done_);
void rejoin_gather_finish();
asok_hook,
"dump inode by inode number");
ceph_assert(r == 0);
+ r = admin_socket->register_command("dump dir "
+ "name=path,type=CephString,req=true "
+ "name=dentry_dump,type=CephBool,req=false",
+ asok_hook,
+ "dump directory by path");
+ ceph_assert(r == 0);
r = admin_socket->register_command("exit",
asok_hook,
"Terminate this MDS");
command_openfiles_ls(f);
} else if (command == "dump inode") {
command_dump_inode(f, cmdmap, *css);
+ } else if (command == "dump dir") {
+ command_dump_dir(f, cmdmap, *css);
} else if (command == "damage ls") {
std::lock_guard l(mds_lock);
damage_table.dump(f);
}
}
+void MDSRank::command_dump_dir(Formatter *f, const cmdmap_t &cmdmap, std::ostream &ss)
+{
+ std::lock_guard l(mds_lock);
+ std::string path;
+ bool got = cmd_getval(cmdmap, "path", path);
+ if (!got) {
+ ss << "missing path argument";
+ return;
+ }
+
+ bool dentry_dump = false;
+ cmd_getval(cmdmap, "dentry_dump", dentry_dump);
+
+ CInode *in = mdcache->cache_traverse(filepath(path.c_str()));
+ if (!in) {
+ ss << "directory inode not in cache";
+ return;
+ }
+
+ f->open_array_section("dirs");
+ frag_vec_t leaves;
+ in->dirfragtree.get_leaves_under(frag_t(), leaves);
+ for (const auto& leaf : leaves) {
+ CDir *dir = in->get_dirfrag(leaf);
+ if (dir)
+ mdcache->dump_dir(f, dir, dentry_dump);
+ }
+ f->close_section();
+}
+
void MDSRank::dump_status(Formatter *f) const
{
f->dump_string("fs_name", std::string(mdsmap->get_fs_name()));
void command_openfiles_ls(Formatter *f);
void command_dump_tree(const cmdmap_t &cmdmap, std::ostream &ss, Formatter *f);
void command_dump_inode(Formatter *f, const cmdmap_t &cmdmap, std::ostream &ss);
+ void command_dump_dir(Formatter *f, const cmdmap_t &cmdmap, std::ostream &ss);
void command_cache_drop(uint64_t timeout, Formatter *f, Context *on_finish);
// FIXME the state machine logic should be separable from the dispatch