| 3313 | } |
| 3314 | |
| 3315 | void MDSRank::command_dump_tree(const cmdmap_t &cmdmap, std::ostream &ss, Formatter *f) |
| 3316 | { |
| 3317 | std::string path; |
| 3318 | cmd_getval(cmdmap, "path", path); |
| 3319 | std::string root; |
| 3320 | cmd_getval(cmdmap, "root", root); |
| 3321 | int64_t depth; |
| 3322 | if (!cmd_getval(cmdmap, "depth", depth)) { |
| 3323 | depth = -1; |
| 3324 | } |
| 3325 | if (root.empty()) { |
| 3326 | root = "/"; |
| 3327 | } |
| 3328 | |
| 3329 | auto dump = [&](Formatter *f) { |
| 3330 | std::lock_guard l(mds_lock); |
| 3331 | CInode *in = mdcache->cache_traverse(filepath(root.c_str())); |
| 3332 | if (!in) { |
| 3333 | ss << "inode for path '" << filepath(root.c_str()) << "' is not in cache"; |
| 3334 | return; |
| 3335 | } |
| 3336 | f->open_array_section("inodes"); |
| 3337 | mdcache->dump_tree(in, 0, depth, f); |
| 3338 | f->close_section(); |
| 3339 | }; |
| 3340 | |
| 3341 | if (!path.empty()) { |
| 3342 | auto ff = JSONFormatterFile(path, false); |
| 3343 | dump(&ff); |
| 3344 | f->open_object_section("result"); |
| 3345 | f->dump_string("path", path); |
| 3346 | f->close_section(); |
| 3347 | } else { |
| 3348 | dump(f); |
| 3349 | } |
| 3350 | } |
| 3351 | |
| 3352 | CDir *MDSRank::_command_dirfrag_get( |
| 3353 | const cmdmap_t &cmdmap, |
nothing calls this directly
no test coverage detected