dump_cache(NULL, f);
}
+void MDCache::dump_cache(const string& dump_root, int depth, Formatter *f)
+{
+ dump_cache(NULL, f, dump_root, depth);
+}
+
/**
* Dump the metadata cache, either to a Formatter, if
* provided, else to a plain text file.
*/
-void MDCache::dump_cache(const char *fn, Formatter *f)
+void MDCache::dump_cache(const char *fn, Formatter *f,
+ const string& dump_root, int depth)
{
int r = 0;
int fd = -1;
return;
}
}
-
+
for (ceph::unordered_map<vinodeno_t,CInode*>::iterator it = inode_map.begin();
it != inode_map.end();
++it) {
CInode *in = it->second;
+
+ if (!dump_root.empty()) {
+ string ipath;
+ if (in->is_root())
+ ipath = "/";
+ else
+ in->make_path_string(ipath);
+
+ if (dump_root.length() > ipath.length() ||
+ !equal(dump_root.begin(), dump_root.end(), ipath.begin()))
+ continue;
+
+ if (depth >= 0 &&
+ count(ipath.begin() + dump_root.length(), ipath.end(), '/') > depth)
+ continue;
+ }
+
if (f) {
f->open_object_section("inode");
in->dump(f);
std::string s = ss.str();
r = safe_write(fd, s.c_str(), s.length());
if (r < 0) {
- goto out;
+ goto out;
}
}
void notify_osdmap_changed();
protected:
- void dump_cache(const char *fn, Formatter *f);
+ void dump_cache(const char *fn, Formatter *f,
+ const std::string& dump_root = "",
+ int depth = -1);
public:
void dump_cache() {dump_cache(NULL, NULL);}
void dump_cache(const std::string &filename);
void dump_cache(Formatter *f);
+ void dump_cache(const std::string& dump_root, int depth, Formatter *f);
void dump_resolve_status(Formatter *f) const;
void dump_rejoin_status(Formatter *f) const;
asok_hook,
"dump metadata cache (optionally to a file)");
assert(r == 0);
+ r = admin_socket->register_command("dump tree",
+ "dump tree "
+ "name=root,type=CephString,req=true "
+ "name=depth,type=CephInt,req=false ",
+ asok_hook,
+ "dump metadata cache for subtree");
+ assert(r == 0);
r = admin_socket->register_command("session evict",
"session evict name=client_id,type=CephString",
asok_hook,
admin_socket->unregister_command("flush_path");
admin_socket->unregister_command("export dir");
admin_socket->unregister_command("dump cache");
+ admin_socket->unregister_command("dump tree");
admin_socket->unregister_command("session evict");
admin_socket->unregister_command("osdmap barrier");
admin_socket->unregister_command("session ls");
} else {
mdcache->dump_cache(path);
}
+ } else if (command == "dump tree") {
+ string root;
+ int64_t depth;
+ cmd_getval(g_ceph_context, cmdmap, "root", root);
+ if (!cmd_getval(g_ceph_context, cmdmap, "depth", depth))
+ depth = -1;
+ {
+ Mutex::Locker l(mds_lock);
+ mdcache->dump_cache(root, depth, f);
+ }
} else if (command == "force_readonly") {
mds_lock.Lock();
mdcache->force_readonly();