From: Yan, Zheng Date: Mon, 23 Jan 2017 14:11:32 +0000 (+0800) Subject: mds: avoid journal unnessary dirfrags in ESubtreeMap X-Git-Tag: v12.0.0~43^2~2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=a9b959dfb7a0b6bcd90345f15cf5d0c37c3b0d2f;p=ceph.git mds: avoid journal unnessary dirfrags in ESubtreeMap EMetaBlob::add_dir_contex() skips adding inodes that has already been journaled in the last ESubtreeMap. The log replay code only replays the first ESubtreeMap. For the rest ESubtreeMap, it just verifies subtree map in the cache matches the ESubtreeMap. If unnessary inodes were included in non-first ESubtreeMap, these inodes do not get added to the cache, the log replay code can find these inodes are missing when replaying the rest events in the log segment. Signed-off-by: "Yan, Zheng" --- diff --git a/src/mds/MDCache.cc b/src/mds/MDCache.cc index 3beae2ea7a1..8f278fdde8d 100644 --- a/src/mds/MDCache.cc +++ b/src/mds/MDCache.cc @@ -2506,6 +2506,8 @@ ESubtreeMap *MDCache::create_subtree_map() mydir = myin->get_dirfrag(frag_t()); } + list maybe; + // include all auth subtrees, and their bounds. // and a spanning tree to tie it to the root. for (map >::iterator p = subtrees.begin(); @@ -2532,6 +2534,15 @@ ESubtreeMap *MDCache::create_subtree_map() } le->subtrees[dir->dirfrag()].clear(); + + if (dir->get_dir_auth().second != CDIR_AUTH_UNKNOWN && + le->ambiguous_subtrees.count(dir->dirfrag()) == 0 && + p->second.empty()) { + dout(10) << " maybe journal " << *dir << dendl; + maybe.push_back(dir); + continue; + } + le->metablob.add_dir_context(dir, EMetaBlob::TO_ROOT); le->metablob.add_dir(dir, false); @@ -2643,6 +2654,18 @@ ESubtreeMap *MDCache::create_subtree_map() } } } + + for (list::iterator p = maybe.begin(); p != maybe.end(); ++p) { + CDir *dir = *p; + if (le->subtrees.count(dir->dirfrag())) { + // not swallowed by above code + le->metablob.add_dir_context(dir, EMetaBlob::TO_ROOT); + le->metablob.add_dir(dir, false); + } else { + dout(10) << "simplify: not journal " << *dir << dendl; + } + } + dout(15) << " subtrees " << le->subtrees << dendl; dout(15) << " ambiguous_subtrees " << le->ambiguous_subtrees << dendl;