summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/mds/CDir.cc8
-rw-r--r--src/mds/CInode.cc80
-rw-r--r--src/mds/CInode.h2
-rw-r--r--src/mds/MDCache.cc162
-rw-r--r--src/mds/MDCache.h6
-rw-r--r--src/mds/MDSRank.cc17
-rw-r--r--src/mds/Migrator.cc19
-rw-r--r--src/mds/OpenFileTable.cc24
-rw-r--r--src/mds/PurgeQueue.cc16
-rw-r--r--src/mds/ScrubStack.cc12
-rw-r--r--src/mds/Server.cc14
-rw-r--r--src/mds/events/EFragment.h2
-rw-r--r--src/mds/journal.cc17
13 files changed, 191 insertions, 188 deletions
diff --git a/src/mds/CDir.cc b/src/mds/CDir.cc
index 856bc70b592..b36ad59e336 100644
--- a/src/mds/CDir.cc
+++ b/src/mds/CDir.cc
@@ -992,7 +992,7 @@ void CDir::split(int bits, list<CDir*>& subs, MDSInternalContextBase::vec& waite
ceph_assert(replay || is_complete() || !is_auth());
- list<frag_t> frags;
+ frag_vec_t frags;
frag.split(bits, frags);
vector<CDir*> subfrags(1 << bits);
@@ -1015,8 +1015,8 @@ void CDir::split(int bits, list<CDir*>& subs, MDSInternalContextBase::vec& waite
// create subfrag dirs
int n = 0;
- for (list<frag_t>::iterator p = frags.begin(); p != frags.end(); ++p) {
- CDir *f = new CDir(inode, *p, cache, is_auth());
+ for (const auto& fg : frags) {
+ CDir *f = new CDir(inode, fg, cache, is_auth());
f->state_set(state & (MASK_STATE_FRAGMENT_KEPT | STATE_COMPLETE));
f->get_replicas() = get_replicas();
f->set_version(get_version());
@@ -1031,7 +1031,7 @@ void CDir::split(int bits, list<CDir*>& subs, MDSInternalContextBase::vec& waite
f->pop_auth_subtree_nested = pop_auth_subtree_nested;
f->pop_auth_subtree_nested.scale(fac);
- dout(10) << " subfrag " << *p << " " << *f << dendl;
+ dout(10) << " subfrag " << fg << " " << *f << dendl;
subfrags[n++] = f;
subs.push_back(f);
diff --git a/src/mds/CInode.cc b/src/mds/CInode.cc
index 00073664085..801b20a1e7f 100644
--- a/src/mds/CInode.cc
+++ b/src/mds/CInode.cc
@@ -636,13 +636,17 @@ frag_t InodeStoreBase::pick_dirfrag(std::string_view dn)
bool CInode::get_dirfrags_under(frag_t fg, list<CDir*>& ls)
{
bool all = true;
- std::list<frag_t> fglist;
- dirfragtree.get_leaves_under(fg, fglist);
- for (list<frag_t>::iterator p = fglist.begin(); p != fglist.end(); ++p)
- if (dirfrags.count(*p))
- ls.push_back(dirfrags[*p]);
- else
- all = false;
+ {
+ frag_vec_t leaves;
+ dirfragtree.get_leaves_under(fg, leaves);
+ for (const auto &leaf : leaves) {
+ if (auto it = dirfrags.find(leaf); it != dirfrags.end()) {
+ ls.push_back(it->second);
+ } else {
+ all = false;
+ }
+ }
+ }
if (all)
return all;
@@ -656,11 +660,14 @@ bool CInode::get_dirfrags_under(frag_t fg, list<CDir*>& ls)
}
all = true;
- tmpdft.get_leaves_under(fg, fglist);
- for (const auto &p : fglist) {
- if (!dirfrags.count(p)) {
- all = false;
- break;
+ {
+ frag_vec_t leaves;
+ tmpdft.get_leaves_under(fg, leaves);
+ for (const auto& leaf : leaves) {
+ if (!dirfrags.count(leaf)) {
+ all = false;
+ break;
+ }
}
}
@@ -692,10 +699,11 @@ void CInode::force_dirfrags()
}
if (bad) {
- list<frag_t> leaves;
+ frag_vec_t leaves;
dirfragtree.get_leaves(leaves);
- for (list<frag_t>::iterator p = leaves.begin(); p != leaves.end(); ++p)
- mdcache->get_force_dirfrag(dirfrag_t(ino(),*p), true);
+ for (const auto& leaf : leaves) {
+ mdcache->get_force_dirfrag(dirfrag_t(ino(), leaf), true);
+ }
}
verify_dirfrags();
@@ -2204,13 +2212,14 @@ void CInode::finish_scatter_gather_update(int type)
dout(20) << " final dirstat " << pi->dirstat << dendl;
if (dirstat_valid && !dirstat.same_sums(pi->dirstat)) {
- list<frag_t> ls;
- tmpdft.get_leaves_under(frag_t(), ls);
- for (list<frag_t>::iterator p = ls.begin(); p != ls.end(); ++p)
- if (!dirfrags.count(*p)) {
+ frag_vec_t leaves;
+ tmpdft.get_leaves_under(frag_t(), leaves);
+ for (const auto& leaf : leaves) {
+ if (!dirfrags.count(leaf)) {
dirstat_valid = false;
break;
}
+ }
if (dirstat_valid) {
if (state_test(CInode::STATE_REPAIRSTATS)) {
dout(20) << " dirstat mismatch, fixing" << dendl;
@@ -2314,13 +2323,14 @@ void CInode::finish_scatter_gather_update(int type)
dout(20) << " final rstat " << pi->rstat << dendl;
if (rstat_valid && !rstat.same_sums(pi->rstat)) {
- list<frag_t> ls;
- tmpdft.get_leaves_under(frag_t(), ls);
- for (list<frag_t>::iterator p = ls.begin(); p != ls.end(); ++p)
- if (!dirfrags.count(*p)) {
+ frag_vec_t leaves;
+ tmpdft.get_leaves_under(frag_t(), leaves);
+ for (const auto& leaf : leaves) {
+ if (!dirfrags.count(leaf)) {
rstat_valid = false;
break;
}
+ }
if (rstat_valid) {
if (state_test(CInode::STATE_REPAIRSTATS)) {
dout(20) << " rstat mismatch, fixing" << dendl;
@@ -4295,12 +4305,10 @@ next:
bool check_dirfrag_rstats() {
MDSGatherBuilder gather(g_ceph_context);
- std::list<frag_t> frags;
- in->dirfragtree.get_leaves(frags);
- for (list<frag_t>::iterator p = frags.begin();
- p != frags.end();
- ++p) {
- CDir *dir = in->get_or_open_dirfrag(in->mdcache, *p);
+ frag_vec_t leaves;
+ in->dirfragtree.get_leaves(leaves);
+ for (const auto& leaf : leaves) {
+ CDir *dir = in->get_or_open_dirfrag(in->mdcache, leaf);
dir->scrub_info();
if (!dir->scrub_infop->header)
dir->scrub_infop->header = in->scrub_infop->header;
@@ -4675,15 +4683,13 @@ void CInode::scrub_initialize(CDentry *scrub_parent,
if (get_projected_inode()->is_dir()) {
// fill in dirfrag_stamps with initial state
- std::list<frag_t> frags;
- dirfragtree.get_leaves(frags);
- for (std::list<frag_t>::iterator i = frags.begin();
- i != frags.end();
- ++i) {
+ frag_vec_t leaves;
+ dirfragtree.get_leaves(leaves);
+ for (const auto& leaf : leaves) {
if (header->get_force())
- scrub_infop->dirfrag_stamps[*i].reset();
+ scrub_infop->dirfrag_stamps[leaf].reset();
else
- scrub_infop->dirfrag_stamps[*i];
+ scrub_infop->dirfrag_stamps[leaf];
}
}
@@ -4727,7 +4733,7 @@ int CInode::scrub_dirfrag_next(frag_t* out_dirfrag)
return ENOENT;
}
-void CInode::scrub_dirfrags_scrubbing(list<frag_t>* out_dirfrags)
+void CInode::scrub_dirfrags_scrubbing(frag_vec_t* out_dirfrags)
{
ceph_assert(out_dirfrags != NULL);
ceph_assert(scrub_infop != NULL);
diff --git a/src/mds/CInode.h b/src/mds/CInode.h
index aa367b0e336..e4309c89fbc 100644
--- a/src/mds/CInode.h
+++ b/src/mds/CInode.h
@@ -343,7 +343,7 @@ class CInode : public MDSCacheObject, public InodeStoreBase, public Counter<CIno
* been returned from scrub_dirfrag_next but not sent back
* via scrub_dirfrag_finished.
*/
- void scrub_dirfrags_scrubbing(list<frag_t> *out_dirfrags);
+ void scrub_dirfrags_scrubbing(frag_vec_t *out_dirfrags);
/**
* Report to the CInode that a dirfrag it owns has been scrubbed. Call
* this for every frag_t returned from scrub_dirfrag_next().
diff --git a/src/mds/MDCache.cc b/src/mds/MDCache.cc
index 840b4e97233..9238ac21624 100644
--- a/src/mds/MDCache.cc
+++ b/src/mds/MDCache.cc
@@ -713,13 +713,12 @@ void MDCache::populate_mydir()
dout(20) << " stray num " << i << " is " << *strays[i] << dendl;
// open all frags
- list<frag_t> ls;
- strays[i]->dirfragtree.get_leaves(ls);
- for (list<frag_t>::iterator p = ls.begin(); p != ls.end(); ++p) {
- frag_t fg = *p;
- CDir *dir = strays[i]->get_dirfrag(fg);
+ frag_vec_t leaves;
+ strays[i]->dirfragtree.get_leaves(leaves);
+ for (const auto& leaf : leaves) {
+ CDir *dir = strays[i]->get_dirfrag(leaf);
if (!dir) {
- dir = strays[i]->get_or_open_dirfrag(this, fg);
+ dir = strays[i]->get_or_open_dirfrag(this, leaf);
}
// DamageTable applies special handling to strays: it will
@@ -1132,30 +1131,29 @@ void MDCache::get_force_dirfrag_bound_set(const vector<dirfrag_t>& dfs, set<CDir
for (set<frag_t>::iterator q = p->second.begin(); q != p->second.end(); ++q)
tmpdft.force_to_leaf(g_ceph_context, *q);
- for (set<frag_t>::iterator q = p->second.begin(); q != p->second.end(); ++q) {
- frag_t fg = *q;
- list<frag_t> fgls;
- diri->dirfragtree.get_leaves_under(fg, fgls);
- if (fgls.empty()) {
+ for (const auto& fg : p->second) {
+ frag_vec_t leaves;
+ diri->dirfragtree.get_leaves_under(fg, leaves);
+ if (leaves.empty()) {
bool all = true;
frag_t approx_fg = diri->dirfragtree[fg.value()];
- list<frag_t> ls;
- tmpdft.get_leaves_under(approx_fg, ls);
- for (list<frag_t>::iterator r = ls.begin(); r != ls.end(); ++r) {
- if (p->second.get().count(*r) == 0) {
+ frag_vec_t approx_leaves;
+ tmpdft.get_leaves_under(approx_fg, approx_leaves);
+ for (const auto& leaf : approx_leaves) {
+ if (p->second.get().count(leaf) == 0) {
// not bound, so the resolve message is from auth MDS of the dirfrag
- force_dir_fragment(diri, *r);
+ force_dir_fragment(diri, leaf);
all = false;
}
}
if (all)
- fgls.push_back(approx_fg);
+ leaves.push_back(approx_fg);
else
- diri->dirfragtree.get_leaves_under(fg, fgls);
+ diri->dirfragtree.get_leaves_under(fg, leaves);
}
- dout(10) << " frag " << fg << " contains " << fgls << dendl;
- for (list<frag_t>::iterator r = fgls.begin(); r != fgls.end(); ++r) {
- CDir *dir = diri->get_dirfrag(*r);
+ dout(10) << " frag " << fg << " contains " << leaves << dendl;
+ for (const auto& leaf : leaves) {
+ CDir *dir = diri->get_dirfrag(leaf);
if (dir)
bounds.insert(dir);
}
@@ -1191,15 +1189,16 @@ void MDCache::map_dirfrag_set(const list<dirfrag_t>& dfs, set<CDir*>& result)
if (!in)
continue;
- list<frag_t> fglist;
- for (set<frag_t>::iterator q = p->second.begin(); q != p->second.end(); ++q)
- in->dirfragtree.get_leaves_under(*q, fglist);
+ frag_vec_t fgs;
+ for (const auto& fg : p->second) {
+ in->dirfragtree.get_leaves_under(fg, fgs);
+ }
- dout(15) << "map_dirfrag_set " << p->second << " -> " << fglist
+ dout(15) << "map_dirfrag_set " << p->second << " -> " << fgs
<< " on " << *in << dendl;
- for (list<frag_t>::iterator q = fglist.begin(); q != fglist.end(); ++q) {
- CDir *dir = in->get_dirfrag(*q);
+ for (const auto& fg : fgs) {
+ CDir *dir = in->get_dirfrag(fg);
if (dir)
result.insert(dir);
}
@@ -4411,28 +4410,27 @@ void MDCache::handle_cache_rejoin_weak(const MMDSCacheRejoin::const_ref &weak)
dout(0) << " missing dir ino " << p.ino << dendl;
ceph_assert(diri);
- list<frag_t> ls;
+ frag_vec_t leaves;
if (diri->dirfragtree.is_leaf(p.frag)) {
- ls.push_back(p.frag);
+ leaves.push_back(p.frag);
} else {
- diri->dirfragtree.get_leaves_under(p.frag, ls);
- if (ls.empty())
- ls.push_back(diri->dirfragtree[p.frag.value()]);
+ diri->dirfragtree.get_leaves_under(p.frag, leaves);
+ if (leaves.empty())
+ leaves.push_back(diri->dirfragtree[p.frag.value()]);
}
- for (list<frag_t>::iterator q = ls.begin(); q != ls.end(); ++q) {
- frag_t fg = *q;
- CDir *dir = diri->get_dirfrag(fg);
+ for (const auto& leaf : leaves) {
+ CDir *dir = diri->get_dirfrag(leaf);
if (!dir) {
- dout(0) << " missing dir for " << p.frag << " (which maps to " << fg << ") on " << *diri << dendl;
+ dout(0) << " missing dir for " << p.frag << " (which maps to " << leaf << ") on " << *diri << dendl;
continue;
}
ceph_assert(dir);
if (dirs_to_share.count(dir)) {
- dout(10) << " already have " << p.frag << " -> " << fg << " " << *dir << dendl;
+ dout(10) << " already have " << p.frag << " -> " << leaf << " " << *dir << dendl;
} else {
dirs_to_share.insert(dir);
unsigned nonce = dir->add_replica(from);
- dout(10) << " have " << p.frag << " -> " << fg << " " << *dir << dendl;
+ dout(10) << " have " << p.frag << " -> " << leaf << " " << *dir << dendl;
if (ack) {
ack->add_strong_dirfrag(dir->dirfrag(), nonce, dir->dir_rep);
ack->add_dirfrag_base(dir);
@@ -4687,15 +4685,15 @@ void MDCache::handle_cache_rejoin_strong(const MMDSCacheRejoin::const_ref &stron
dir->dir_rep = p.second.dir_rep;
} else {
dout(10) << " frag " << dirfrag << " doesn't match dirfragtree " << *diri << dendl;
- list<frag_t> ls;
- diri->dirfragtree.get_leaves_under(dirfrag.frag, ls);
- if (ls.empty())
- ls.push_back(diri->dirfragtree[dirfrag.frag.value()]);
- dout(10) << " maps to frag(s) " << ls << dendl;
- for (list<frag_t>::iterator q = ls.begin(); q != ls.end(); ++q) {
- CDir *dir = diri->get_dirfrag(*q);
+ frag_vec_t leaves;
+ diri->dirfragtree.get_leaves_under(dirfrag.frag, leaves);
+ if (leaves.empty())
+ leaves.push_back(diri->dirfragtree[dirfrag.frag.value()]);
+ dout(10) << " maps to frag(s) " << leaves << dendl;
+ for (const auto& leaf : leaves) {
+ CDir *dir = diri->get_dirfrag(leaf);
if (!dir)
- dir = rejoin_invent_dirfrag(dirfrag_t(diri->ino(), *q));
+ dir = rejoin_invent_dirfrag(dirfrag_t(diri->ino(), leaf));
else
dout(10) << " have(approx) " << *dir << dendl;
dir->add_replica(from, p.second.nonce);
@@ -11471,8 +11469,8 @@ void MDCache::dispatch_fragment_dir(MDRequestRef& mdr)
diri->verify_dirfrags();
mds->queue_waiters(waiters);
- for (list<frag_t>::iterator p = le->orig_frags.begin(); p != le->orig_frags.end(); ++p)
- ceph_assert(!diri->dirfragtree.is_leaf(*p));
+ for (const auto& fg : le->orig_frags)
+ ceph_assert(!diri->dirfragtree.is_leaf(fg));
le->metablob.add_dir_context(*info.resultfrags.begin());
for (list<CDir*>::iterator p = info.resultfrags.begin();
@@ -11649,12 +11647,10 @@ void MDCache::_fragment_committed(dirfrag_t basedirfrag, const MDRequestRef& mdr
SnapContext nullsnapc;
object_locator_t oloc(mds->mdsmap->get_metadata_pool());
- for (list<frag_t>::iterator p = uf.old_frags.begin();
- p != uf.old_frags.end();
- ++p) {
- object_t oid = CInode::get_object_name(basedirfrag.ino, *p, "");
+ for (const auto& fg : uf.old_frags) {
+ object_t oid = CInode::get_object_name(basedirfrag.ino, fg, "");
ObjectOperation op;
- if (*p == frag_t()) {
+ if (fg == frag_t()) {
// backtrace object
dout(10) << " truncate orphan dirfrag " << oid << dendl;
op.truncate(0);
@@ -11803,7 +11799,7 @@ void MDCache::handle_fragment_notify(const MMDSFragmentNotify::const_ref &notify
}
}
-void MDCache::add_uncommitted_fragment(dirfrag_t basedirfrag, int bits, list<frag_t>& old_frags,
+void MDCache::add_uncommitted_fragment(dirfrag_t basedirfrag, int bits, const frag_vec_t& old_frags,
LogSegment *ls, bufferlist *rollback)
{
dout(10) << "add_uncommitted_fragment: base dirfrag " << basedirfrag << " bits " << bits << dendl;
@@ -11834,7 +11830,7 @@ void MDCache::finish_uncommitted_fragment(dirfrag_t basedirfrag, int op)
}
}
-void MDCache::rollback_uncommitted_fragment(dirfrag_t basedirfrag, list<frag_t>& old_frags)
+void MDCache::rollback_uncommitted_fragment(dirfrag_t basedirfrag, frag_vec_t&& old_frags)
{
dout(10) << "rollback_uncommitted_fragment: base dirfrag " << basedirfrag
<< " old_frags (" << old_frags << ")" << dendl;
@@ -11842,7 +11838,7 @@ void MDCache::rollback_uncommitted_fragment(dirfrag_t basedirfrag, list<frag_t>&
if (it != uncommitted_fragments.end()) {
ufragment& uf = it->second;
if (!uf.old_frags.empty()) {
- uf.old_frags.swap(old_frags);
+ uf.old_frags = std::move(old_frags);
uf.committed = true;
} else {
uf.ls->uncommitted_fragments.erase(basedirfrag);
@@ -11873,7 +11869,7 @@ void MDCache::rollback_uncommitted_fragments()
mds->mdlog->start_entry(le);
bool diri_auth = (diri->authority() != CDIR_AUTH_UNDEF);
- list<frag_t> old_frags;
+ frag_vec_t old_frags;
diri->dirfragtree.get_leaves_under(p->first.frag, old_frags);
list<CDir*> resultfrags;
@@ -11883,8 +11879,8 @@ void MDCache::rollback_uncommitted_fragments()
adjust_dir_fragments(diri, p->first.frag, -uf.bits, resultfrags, waiters, true);
} else {
auto bp = uf.rollback.cbegin();
- for (list<frag_t>::iterator q = uf.old_frags.begin(); q != uf.old_frags.end(); ++q) {
- CDir *dir = force_dir_fragment(diri, *q);
+ for (const auto& fg : uf.old_frags) {
+ CDir *dir = force_dir_fragment(diri, fg);
resultfrags.push_back(dir);
dirfrag_rollback rollback;
@@ -11931,8 +11927,9 @@ void MDCache::rollback_uncommitted_fragments()
if (g_conf()->mds_debug_frag)
diri->verify_dirfrags();
- for (list<frag_t>::iterator q = old_frags.begin(); q != old_frags.end(); ++q)
- ceph_assert(!diri->dirfragtree.is_leaf(*q));
+ for (const auto& leaf : old_frags) {
+ ceph_assert(!diri->dirfragtree.is_leaf(leaf));
+ }
mds->mdlog->submit_entry(le);
@@ -12600,7 +12597,6 @@ void MDCache::repair_inode_stats_work(MDRequestRef& mdr)
}
MutationImpl::LockOpVec lov;
- std::list<frag_t> frags;
if (mdr->ls) // already marked filelock/nestlock dirty ?
goto do_rdlocks;
@@ -12613,17 +12609,20 @@ void MDCache::repair_inode_stats_work(MDRequestRef& mdr)
// Fetch all dirfrags and mark filelock/nestlock dirty. This will tirgger
// the scatter-gather process, which will fix any fragstat/rstat errors.
- diri->dirfragtree.get_leaves(frags);
- for (list<frag_t>::iterator p = frags.begin(); p != frags.end(); ++p) {
- CDir *dir = diri->get_dirfrag(*p);
- if (!dir) {
- ceph_assert(mdr->is_auth_pinned(diri));
- dir = diri->get_or_open_dirfrag(this, *p);
- }
- if (dir->get_version() == 0) {
- ceph_assert(dir->is_auth());
- dir->fetch(new C_MDS_RetryRequest(this, mdr));
- return;
+ {
+ frag_vec_t leaves;
+ diri->dirfragtree.get_leaves(leaves);
+ for (const auto& leaf : leaves) {
+ CDir *dir = diri->get_dirfrag(leaf);
+ if (!dir) {
+ ceph_assert(mdr->is_auth_pinned(diri));
+ dir = diri->get_or_open_dirfrag(this, leaf);
+ }
+ if (dir->get_version() == 0) {
+ ceph_assert(dir->is_auth());
+ dir->fetch(new C_MDS_RetryRequest(this, mdr));
+ return;
+ }
}
}
@@ -12653,13 +12652,16 @@ do_rdlocks:
if (const sr_t *srnode = diri->get_projected_srnode(); srnode)
nest_info.rsnaps = srnode->snaps.size();
- diri->dirfragtree.get_leaves(frags);
- for (list<frag_t>::iterator p = frags.begin(); p != frags.end(); ++p) {
- CDir *dir = diri->get_dirfrag(*p);
- ceph_assert(dir);
- ceph_assert(dir->get_version() > 0);
- dir_info.add(dir->fnode.accounted_fragstat);
- nest_info.add(dir->fnode.accounted_rstat);
+ {
+ frag_vec_t leaves;
+ diri->dirfragtree.get_leaves(leaves);
+ for (const auto& leaf : leaves) {
+ CDir *dir = diri->get_dirfrag(leaf);
+ ceph_assert(dir);
+ ceph_assert(dir->get_version() > 0);
+ dir_info.add(dir->fnode.accounted_fragstat);
+ nest_info.add(dir->fnode.accounted_rstat);
+ }
}
if (!dir_info.same_sums(diri->inode.dirstat) ||
diff --git a/src/mds/MDCache.h b/src/mds/MDCache.h
index cd3eef20937..e161b539fa9 100644
--- a/src/mds/MDCache.h
+++ b/src/mds/MDCache.h
@@ -1122,7 +1122,7 @@ private:
bool committed;
LogSegment *ls;
MDSInternalContextBase::vec waiters;
- list<frag_t> old_frags;
+ frag_vec_t old_frags;
bufferlist rollback;
ufragment() : bits(0), committed(false), ls(NULL) {}
};
@@ -1183,10 +1183,10 @@ private:
void handle_fragment_notify(const MMDSFragmentNotify::const_ref &m);
void handle_fragment_notify_ack(const MMDSFragmentNotifyAck::const_ref &m);
- void add_uncommitted_fragment(dirfrag_t basedirfrag, int bits, list<frag_t>& old_frag,
+ void add_uncommitted_fragment(dirfrag_t basedirfrag, int bits, const frag_vec_t& old_frag,
LogSegment *ls, bufferlist *rollback=NULL);
void finish_uncommitted_fragment(dirfrag_t basedirfrag, int op);
- void rollback_uncommitted_fragment(dirfrag_t basedirfrag, list<frag_t>& old_frags);
+ void rollback_uncommitted_fragment(dirfrag_t basedirfrag, frag_vec_t&& old_frags);
public:
void wait_for_uncommitted_fragment(dirfrag_t dirfrag, MDSInternalContextBase *c) {
ceph_assert(uncommitted_fragments.count(dirfrag));
diff --git a/src/mds/MDSRank.cc b/src/mds/MDSRank.cc
index f9bbbb649f0..fb0e462dab6 100644
--- a/src/mds/MDSRank.cc
+++ b/src/mds/MDSRank.cc
@@ -2929,18 +2929,17 @@ bool MDSRank::command_dirfrag_ls(
}
f->open_array_section("frags");
- std::list<frag_t> frags;
+ frag_vec_t leaves;
// NB using get_leaves_under instead of get_dirfrags to give
// you the list of what dirfrags may exist, not which are in cache
- in->dirfragtree.get_leaves_under(frag_t(), frags);
- for (std::list<frag_t>::iterator i = frags.begin();
- i != frags.end(); ++i) {
+ in->dirfragtree.get_leaves_under(frag_t(), leaves);
+ for (const auto& leaf : leaves) {
f->open_object_section("frag");
- f->dump_int("value", i->value());
- f->dump_int("bits", i->bits());
- std::ostringstream frag_str;
- frag_str << std::hex << i->value() << "/" << std::dec << i->bits();
- f->dump_string("str", frag_str.str());
+ f->dump_int("value", leaf.value());
+ f->dump_int("bits", leaf.bits());
+ CachedStackStringStream ss;
+ ss.get_stream() << std::hex << leaf.value() << "/" << std::dec << leaf.bits();
+ f->dump_string("str", ss.strv());
f->close_section();
}
f->close_section();
diff --git a/src/mds/Migrator.cc b/src/mds/Migrator.cc
index db82bc3cf1c..e0de6be9f56 100644
--- a/src/mds/Migrator.cc
+++ b/src/mds/Migrator.cc
@@ -2523,18 +2523,17 @@ void Migrator::handle_export_prep(const MExportDirPrep::const_ref &m, bool did_a
ceph_assert(in);
// map fragset into a frag_t list, based on the inode fragtree
- list<frag_t> fglist;
- for (set<frag_t>::iterator q = p->second.begin(); q != p->second.end(); ++q)
- in->dirfragtree.get_leaves_under(*q, fglist);
- dout(10) << " bound inode " << p->first << " fragset " << p->second << " maps to " << fglist << dendl;
+ frag_vec_t leaves;
+ for (const auto& frag : p->second) {
+ in->dirfragtree.get_leaves_under(frag, leaves);
+ }
+ dout(10) << " bound inode " << p->first << " fragset " << p->second << " maps to " << leaves << dendl;
- for (list<frag_t>::iterator q = fglist.begin();
- q != fglist.end();
- ++q) {
- CDir *bound = cache->get_dirfrag(dirfrag_t(p->first, *q));
+ for (const auto& leaf : leaves) {
+ CDir *bound = cache->get_dirfrag(dirfrag_t(p->first, leaf));
if (!bound) {
- dout(7) << " opening bounding dirfrag " << *q << " on " << *in << dendl;
- cache->open_remote_dirfrag(in, *q, cf.build());
+ dout(7) << " opening bounding dirfrag " << leaf << " on " << *in << dendl;
+ cache->open_remote_dirfrag(in, leaf, cf.build());
return;
}
diff --git a/src/mds/OpenFileTable.cc b/src/mds/OpenFileTable.cc
index d9777581f0a..703e86c9d1a 100644
--- a/src/mds/OpenFileTable.cc
+++ b/src/mds/OpenFileTable.cc
@@ -422,13 +422,13 @@ void OpenFileTable::commit(MDSInternalContextBase *c, uint64_t log_seq, int op_p
}
for (auto& it : dirty_items) {
- list<frag_t> fgls;
+ frag_vec_t frags;
auto p = anchor_map.find(it.first);
if (p != anchor_map.end()) {
for (auto q = dirfrags.lower_bound(dirfrag_t(it.first, 0));
q != dirfrags.end() && q->ino == it.first;
++q)
- fgls.push_back(q->frag);
+ frags.push_back(q->frag);
}
if (first_commit) {
@@ -439,7 +439,7 @@ void OpenFileTable::commit(MDSInternalContextBase *c, uint64_t log_seq, int op_p
bool same = p->second == q->second;
if (same) {
auto r = loaded_dirfrags.lower_bound(dirfrag_t(it.first, 0));
- for (auto fg : fgls) {
+ for (const auto& fg : frags) {
if (r == loaded_dirfrags.end() || !(*r == dirfrag_t(it.first, fg))) {
same = false;
break;
@@ -494,7 +494,7 @@ void OpenFileTable::commit(MDSInternalContextBase *c, uint64_t log_seq, int op_p
if (p != anchor_map.end()) {
bufferlist bl;
encode(p->second, bl);
- encode(fgls, bl);
+ encode(frags, bl);
ctl.write_size += bl.length() + len + 2 * sizeof(__u32);
ctl.to_update[key].swap(bl);
@@ -711,9 +711,9 @@ void OpenFileTable::_load_finish(int op_r, int header_r, int values_r,
anchor.omap_idx = idx;
anchor.auth = MDS_RANK_NONE;
- list<frag_t> fgls;
- decode(fgls, p);
- for (auto fg : fgls)
+ frag_vec_t frags;
+ decode(frags, p);
+ for (const auto& fg : frags)
loaded_dirfrags.insert(loaded_dirfrags.end(), dirfrag_t(anchor.ino, fg));
if (loaded_anchor_map.size() > count)
@@ -1042,13 +1042,13 @@ void OpenFileTable::_prefetch_dirfrags()
if (dir->is_auth() && !dir->is_complete())
fetch_queue.push_back(dir);
} else {
- list<frag_t> fgls;
- diri->dirfragtree.get_leaves_under(df.frag, fgls);
- for (auto fg : fgls) {
+ frag_vec_t leaves;
+ diri->dirfragtree.get_leaves_under(df.frag, leaves);
+ for (const auto& leaf : leaves) {
if (diri->is_auth()) {
- dir = diri->get_or_open_dirfrag(mdcache, fg);
+ dir = diri->get_or_open_dirfrag(mdcache, leaf);
} else {
- dir = diri->get_dirfrag(fg);
+ dir = diri->get_dirfrag(leaf);
}
if (dir && dir->is_auth() && !dir->is_complete())
fetch_queue.push_back(dir);
diff --git a/src/mds/PurgeQueue.cc b/src/mds/PurgeQueue.cc
index f5113a8b33c..1b053013775 100644
--- a/src/mds/PurgeQueue.cc
+++ b/src/mds/PurgeQueue.cc
@@ -307,12 +307,12 @@ uint32_t PurgeQueue::_calculate_ops(const PurgeItem &item) const
uint32_t ops_required = 0;
if (item.action == PurgeItem::PURGE_DIR) {
// Directory, count dirfrags to be deleted
- std::list<frag_t> ls;
+ frag_vec_t leaves;
if (!item.fragtree.is_leaf(frag_t())) {
- item.fragtree.get_leaves(ls);
+ item.fragtree.get_leaves(leaves);
}
// One for the root, plus any leaves
- ops_required = 1 + ls.size();
+ ops_required = 1 + leaves.size();
} else {
// File, work out concurrent Filer::purge deletes
const uint64_t num = (item.size > 0) ?
@@ -472,12 +472,12 @@ void PurgeQueue::_execute_item(
}
} else if (item.action == PurgeItem::PURGE_DIR) {
object_locator_t oloc(metadata_pool);
- std::list<frag_t> frags;
+ frag_vec_t leaves;
if (!item.fragtree.is_leaf(frag_t()))
- item.fragtree.get_leaves(frags);
- frags.push_back(frag_t());
- for (const auto &frag : frags) {
- object_t oid = CInode::get_object_name(item.ino, frag, "");
+ item.fragtree.get_leaves(leaves);
+ leaves.push_back(frag_t());
+ for (const auto &leaf : leaves) {
+ object_t oid = CInode::get_object_name(item.ino, leaf, "");
dout(10) << " remove dirfrag " << oid << dendl;
objecter->remove(oid, oloc, nullsnapc,
ceph::real_clock::now(),
diff --git a/src/mds/ScrubStack.cc b/src/mds/ScrubStack.cc
index ec3a5b7901f..2b864e5e536 100644
--- a/src/mds/ScrubStack.cc
+++ b/src/mds/ScrubStack.cc
@@ -138,22 +138,20 @@ void ScrubStack::scrub_dir_inode(CInode *in,
ceph_assert(header != nullptr);
if (header->get_recursive()) {
- list<frag_t> scrubbing_frags;
+ frag_vec_t scrubbing_frags;
list<CDir*> scrubbing_cdirs;
in->scrub_dirfrags_scrubbing(&scrubbing_frags);
dout(20) << __func__ << " iterating over " << scrubbing_frags.size()
<< " scrubbing frags" << dendl;
- for (list<frag_t>::iterator i = scrubbing_frags.begin();
- i != scrubbing_frags.end();
- ++i) {
+ for (const auto& fg : scrubbing_frags) {
// turn frags into CDir *
- CDir *dir = in->get_dirfrag(*i);
+ CDir *dir = in->get_dirfrag(fg);
if (dir) {
scrubbing_cdirs.push_back(dir);
dout(25) << __func__ << " got CDir " << *dir << " presently scrubbing" << dendl;
} else {
- in->scrub_dirfrag_finished(*i);
- dout(25) << __func__ << " missing dirfrag " << *i << " skip scrubbing" << dendl;
+ in->scrub_dirfrag_finished(fg);
+ dout(25) << __func__ << " missing dirfrag " << fg << " skip scrubbing" << dendl;
}
}
diff --git a/src/mds/Server.cc b/src/mds/Server.cc
index c01e6cbe5ee..0e6f8e4b96e 100644
--- a/src/mds/Server.cc
+++ b/src/mds/Server.cc
@@ -7494,15 +7494,13 @@ void Server::handle_client_rename(MDRequestRef& mdr)
dout(10) << "srci is remote dir, setting stickydirs and opening all frags" << dendl;
mdr->set_stickydirs(srci);
- list<frag_t> frags;
- srci->dirfragtree.get_leaves(frags);
- for (list<frag_t>::iterator p = frags.begin();
- p != frags.end();
- ++p) {
- CDir *dir = srci->get_dirfrag(*p);
+ frag_vec_t leaves;
+ srci->dirfragtree.get_leaves(leaves);
+ for (const auto& leaf : leaves) {
+ CDir *dir = srci->get_dirfrag(leaf);
if (!dir) {
- dout(10) << " opening " << *p << " under " << *srci << dendl;
- mdcache->open_remote_dirfrag(srci, *p, new C_MDS_RetryRequest(mdcache, mdr));
+ dout(10) << " opening " << leaf << " under " << *srci << dendl;
+ mdcache->open_remote_dirfrag(srci, leaf, new C_MDS_RetryRequest(mdcache, mdr));
return;
}
}
diff --git a/src/mds/events/EFragment.h b/src/mds/events/EFragment.h
index 6204fcb7777..483c4b49a6b 100644
--- a/src/mds/events/EFragment.h
+++ b/src/mds/events/EFragment.h
@@ -33,7 +33,7 @@ public:
inodeno_t ino;
frag_t basefrag;
__s32 bits{0}; // positive for split (from basefrag), negative for merge (to basefrag)
- list<frag_t> orig_frags;
+ frag_vec_t orig_frags;
bufferlist rollback;
EFragment() : LogEvent(EVENT_FRAGMENT) { }
diff --git a/src/mds/journal.cc b/src/mds/journal.cc
index 7b9bbd5a032..7f1d0e7cd6f 100644
--- a/src/mds/journal.cc
+++ b/src/mds/journal.cc
@@ -1372,10 +1372,10 @@ void EMetaBlob::replay(MDSRank *mds, LogSegment *logseg, MDSlaveUpdate *slaveup)
if (olddir->authority() != CDIR_AUTH_UNDEF &&
renamed_diri->authority() == CDIR_AUTH_UNDEF) {
ceph_assert(slaveup); // auth to non-auth, must be slave prepare
- list<frag_t> leaves;
+ frag_vec_t leaves;
renamed_diri->dirfragtree.get_leaves(leaves);
- for (list<frag_t>::iterator p = leaves.begin(); p != leaves.end(); ++p) {
- CDir *dir = renamed_diri->get_dirfrag(*p);
+ for (const auto& leaf : leaves) {
+ CDir *dir = renamed_diri->get_dirfrag(leaf);
ceph_assert(dir);
if (dir->get_dir_auth() == CDIR_AUTH_UNDEF)
// preserve subtree bound until slave commit
@@ -2672,7 +2672,6 @@ void EFragment::replay(MDSRank *mds)
list<CDir*> resultfrags;
MDSInternalContextBase::vec waiters;
- list<frag_t> old_frags;
// in may be NULL if it wasn't in our cache yet. if it's a prepare
// it will be once we replay the metablob , but first we need to
@@ -2687,19 +2686,21 @@ void EFragment::replay(MDSRank *mds)
mds->mdcache->adjust_dir_fragments(in, basefrag, bits, resultfrags, waiters, true);
break;
- case OP_ROLLBACK:
+ case OP_ROLLBACK: {
+ frag_vec_t old_frags;
if (in) {
in->dirfragtree.get_leaves_under(basefrag, old_frags);
if (orig_frags.empty()) {
// old format EFragment
mds->mdcache->adjust_dir_fragments(in, basefrag, -bits, resultfrags, waiters, true);
} else {
- for (list<frag_t>::iterator p = orig_frags.begin(); p != orig_frags.end(); ++p)
- mds->mdcache->force_dir_fragment(in, *p);
+ for (const auto& fg : orig_frags)
+ mds->mdcache->force_dir_fragment(in, fg);
}
}
- mds->mdcache->rollback_uncommitted_fragment(dirfrag_t(ino, basefrag), old_frags);
+ mds->mdcache->rollback_uncommitted_fragment(dirfrag_t(ino, basefrag), std::move(old_frags));
break;
+ }
case OP_COMMIT:
case OP_FINISH: