From c12ba5764f55242e36e4b1049bede7c12d529f43 Mon Sep 17 00:00:00 2001 From: Xiubo Li Date: Fri, 24 Dec 2021 12:50:23 +0800 Subject: [PATCH] mds: dump tree '/' when the path is empty The `get subtrees` will return the path '' for the '0x1', and if we pass '' to the `dump tree ''` command, the MDS will crash. Fixes: https://tracker.ceph.com/issues/53726 Signed-off-by: Xiubo Li (cherry picked from commit cc80cea0db697ceec7a8c4d5dacc4840e661834e) --- src/mds/MDSRank.cc | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/mds/MDSRank.cc b/src/mds/MDSRank.cc index d850c1741ac3c..edc3052c362d7 100644 --- a/src/mds/MDSRank.cc +++ b/src/mds/MDSRank.cc @@ -3095,6 +3095,9 @@ void MDSRank::command_dump_tree(const cmdmap_t &cmdmap, std::ostream &ss, Format std::string root; int64_t depth; cmd_getval(cmdmap, "root", root); + if (root.empty()) { + root = "/"; + } if (!cmd_getval(cmdmap, "depth", depth)) depth = -1; std::lock_guard l(mds_lock); -- 2.39.5