From: Simon Gao Date: Tue, 11 Feb 2020 09:24:09 +0000 (+0800) Subject: mds: optimize function, get_force_dirfrag_bound_set by using get_dirfrags_under X-Git-Tag: v17.0.0~2817^2 X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=820ff537865d9daf492a64bfc72428ecf74bb8fe;p=ceph.git mds: optimize function, get_force_dirfrag_bound_set by using get_dirfrags_under The frags of inode have been simplified. so the var named all is always false. Using the func, get_dirfrags_under, simplifies the logic. We've optimized this function before. Signed-off-by: Simon Gao --- diff --git a/src/mds/MDCache.cc b/src/mds/MDCache.cc index ca9fd8d7ee979..2aac3d99ce71e 100644 --- a/src/mds/MDCache.cc +++ b/src/mds/MDCache.cc @@ -1166,7 +1166,6 @@ void MDCache::get_force_dirfrag_bound_set(const vector& dfs, setdirfragtree.get_leaves_under(fg, leaves); if (leaves.empty()) { - bool all = true; frag_t approx_fg = diri->dirfragtree[fg.value()]; frag_vec_t approx_leaves; tmpdft.get_leaves_under(approx_fg, approx_leaves); @@ -1174,20 +1173,13 @@ void MDCache::get_force_dirfrag_bound_set(const vector& dfs, setsecond.get().count(leaf) == 0) { // not bound, so the resolve message is from auth MDS of the dirfrag force_dir_fragment(diri, leaf); - all = false; } } - if (all) - leaves.push_back(approx_fg); - else - diri->dirfragtree.get_leaves_under(fg, leaves); - } - dout(10) << " frag " << fg << " contains " << leaves << dendl; - for (const auto& leaf : leaves) { - CDir *dir = diri->get_dirfrag(leaf); - if (dir) - bounds.insert(dir); } + + auto&& [complete, sibs] = diri->get_dirfrags_under(fg); + for (const auto& sib : sibs) + bounds.insert(sib); } } }