From: Patrick Donnelly Date: Tue, 11 Apr 2017 19:06:22 +0000 (-0400) Subject: mds: simplify loops to range-for X-Git-Tag: v12.0.3~38^2~34 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=2d2b387372df0f5c851b6a07485f96faf7bea1ea;p=ceph.git mds: simplify loops to range-for No functional change. Signed-off-by: Patrick Donnelly --- diff --git a/src/mds/MDBalancer.cc b/src/mds/MDBalancer.cc index 4914e7655171..f52abe0f61c2 100644 --- a/src/mds/MDBalancer.cc +++ b/src/mds/MDBalancer.cc @@ -337,14 +337,10 @@ void MDBalancer::export_empties() { dout(5) << "export_empties checking for empty imports" << dendl; - for (map >::iterator it = mds->mdcache->subtrees.begin(); - it != mds->mdcache->subtrees.end(); - ++it) { - CDir *dir = it->first; - if (!dir->is_auth() || - dir->is_ambiguous_auth() || - dir->is_freezing() || - dir->is_frozen()) + std::set subtrees; + mds->mdcache->get_fullauth_subtrees(subtrees); + for (auto &dir : subtrees) { + if (dir->is_freezing() || dir->is_frozen()) continue; if (!dir->inode->is_base() && diff --git a/src/mds/MDCache.cc b/src/mds/MDCache.cc index 88832279d2fd..49577fc99b88 100644 --- a/src/mds/MDCache.cc +++ b/src/mds/MDCache.cc @@ -1257,19 +1257,15 @@ void MDCache::verify_subtree_bounds(CDir *dir, const set& bounds) if (bounds != subtrees[dir]) { dout(0) << "verify_subtree_bounds failed" << dendl; set b = bounds; - for (set::iterator p = subtrees[dir].begin(); - p != subtrees[dir].end(); - ++p) { - if (bounds.count(*p)) { - b.erase(*p); + for (auto &cd : subtrees[dir]) { + if (bounds.count(cd)) { + b.erase(cd); continue; } - dout(0) << " missing bound " << **p << dendl; + dout(0) << " missing bound " << *cd << dendl; } - for (set::iterator p = b.begin(); - p != b.end(); - ++p) - dout(0) << " extra bound " << **p << dendl; + for (const auto &cd : b) + dout(0) << " extra bound " << *cd << dendl; } assert(bounds == subtrees[dir]); } @@ -1281,10 +1277,8 @@ void MDCache::verify_subtree_bounds(CDir *dir, const list& bounds) // make sure that any bounds i do have are properly noted as such. int failed = 0; - for (list::const_iterator p = bounds.begin(); - p != bounds.end(); - ++p) { - CDir *bd = get_dirfrag(*p); + for (const auto &fg : bounds) { + CDir *bd = get_dirfrag(fg); if (!bd) continue; if (subtrees[dir].count(bd) == 0) { dout(0) << "verify_subtree_bounds failed: extra bound " << *bd << dendl; diff --git a/src/mds/Migrator.cc b/src/mds/Migrator.cc index e55a3b266db0..65b698118b3f 100644 --- a/src/mds/Migrator.cc +++ b/src/mds/Migrator.cc @@ -1700,10 +1700,7 @@ void Migrator::export_reverse(CDir *dir) } // unpin bounds - for (set::iterator p = bounds.begin(); - p != bounds.end(); - ++p) { - CDir *bd = *p; + for (const auto &bd : bounds) { bd->put(CDir::PIN_EXPORTBOUND); bd->state_clear(CDir::STATE_EXPORTBOUND); }