summaryrefslogtreecommitdiffstats
path: root/src/mds
diff options
context:
space:
mode:
Diffstat (limited to 'src/mds')
-rw-r--r--src/mds/Beacon.cc2
-rw-r--r--src/mds/CDentry.cc2
-rw-r--r--src/mds/CDir.cc7
-rw-r--r--src/mds/CInode.cc7
-rw-r--r--src/mds/Capability.cc15
-rw-r--r--src/mds/Capability.h1
-rw-r--r--src/mds/FSMap.cc8
-rw-r--r--src/mds/FSMap.h1
-rw-r--r--src/mds/MDCache.cc249
-rw-r--r--src/mds/MDCache.h2
-rw-r--r--src/mds/MDLog.cc131
-rw-r--r--src/mds/MDLog.h16
-rw-r--r--src/mds/MDSContext.cc2
-rw-r--r--src/mds/MDSRank.cc98
-rw-r--r--src/mds/OpenFileTable.cc8
-rw-r--r--src/mds/OpenFileTable.h5
-rw-r--r--src/mds/PurgeQueue.cc19
-rw-r--r--src/mds/PurgeQueue.h1
-rw-r--r--src/mds/SessionMap.h1
-rw-r--r--src/mds/SimpleLock.cc7
-rw-r--r--src/mds/SimpleLock.h12
-rw-r--r--src/mds/flock.cc44
-rw-r--r--src/mds/flock.h3
-rw-r--r--src/mds/journal.cc13
-rw-r--r--src/mds/mdstypes.cc26
-rw-r--r--src/mds/mdstypes.h17
26 files changed, 416 insertions, 281 deletions
diff --git a/src/mds/Beacon.cc b/src/mds/Beacon.cc
index 059b540feb0..642d3428a27 100644
--- a/src/mds/Beacon.cc
+++ b/src/mds/Beacon.cc
@@ -17,6 +17,7 @@
#include "common/likely.h"
#include "common/HeartbeatMap.h"
+#include "include/compat.h" // for ceph_pthread_setname()
#include "include/stringify.h"
#include "include/util.h"
@@ -73,6 +74,7 @@ void Beacon::init(const MDSMap &mdsmap)
_notify_mdsmap(mdsmap);
sender = std::thread([this]() {
+ ceph_pthread_setname(pthread_self(), "beacon");
std::unique_lock<std::mutex> lock(mutex);
bool sent;
while (!finished) {
diff --git a/src/mds/CDentry.cc b/src/mds/CDentry.cc
index 942bd9a9ec6..13b59eb8cdc 100644
--- a/src/mds/CDentry.cc
+++ b/src/mds/CDentry.cc
@@ -724,7 +724,7 @@ bool CDentry::check_corruption(bool load)
dout(1) << "loaded already corrupt dentry: " << *this << dendl;
corrupt_first_loaded = true;
} else {
- derr << "newly corrupt dentry to be committed: " << *this << dendl;
+ derr << "newly corrupt dentry to be committed: " << *this << " with next_snap: " << next_snap << dendl;
}
if (g_conf().get_val<bool>("mds_go_bad_corrupt_dentry")) {
dir->go_bad_dentry(last, get_name());
diff --git a/src/mds/CDir.cc b/src/mds/CDir.cc
index f000da7928a..76e9fee68f8 100644
--- a/src/mds/CDir.cc
+++ b/src/mds/CDir.cc
@@ -1319,7 +1319,7 @@ void CDir::take_dentry_waiting(std::string_view dname, snapid_t first, snapid_t
<< it->first.snapid
<< " on " << *this << dendl;
std::copy(it->second.begin(), it->second.end(), std::back_inserter(ls));
- waiting_on_dentry.erase(it++);
+ it = waiting_on_dentry.erase(it);
}
if (waiting_on_dentry.empty())
@@ -2823,8 +2823,6 @@ void CDir::_committed(int r, version_t v)
auto it = waiting_for_commit.begin();
while (it != waiting_for_commit.end()) {
- auto _it = it;
- ++_it;
if (it->first > committed_version) {
dout(10) << " there are waiters for " << it->first << ", committing again" << dendl;
_commit(it->first, -1);
@@ -2834,8 +2832,7 @@ void CDir::_committed(int r, version_t v)
for (const auto &waiter : it->second)
t.push_back(waiter);
mdcache->mds->queue_waiters(t);
- waiting_for_commit.erase(it);
- it = _it;
+ it = waiting_for_commit.erase(it);
if (!(++count % mdcache->mds->heartbeat_reset_grace()))
mdcache->mds->heartbeat_reset();
diff --git a/src/mds/CInode.cc b/src/mds/CInode.cc
index 0e9b6996ad2..dfad411d323 100644
--- a/src/mds/CInode.cc
+++ b/src/mds/CInode.cc
@@ -4589,8 +4589,11 @@ void InodeStoreBase::dump(Formatter *f) const
for (const auto& [key, val] : *xattrs) {
f->open_object_section("xattr");
f->dump_string("key", key);
- std::string v(val.c_str(), val.length());
- f->dump_string("val", v);
+ if (val.length()) {
+ f->dump_string("val", std::string(val.c_str(), val.length()));
+ } else {
+ f->dump_string("val", "");
+ }
f->close_section();
}
}
diff --git a/src/mds/Capability.cc b/src/mds/Capability.cc
index 9a3d093f9eb..ea636b7059a 100644
--- a/src/mds/Capability.cc
+++ b/src/mds/Capability.cc
@@ -73,14 +73,8 @@ void Capability::Export::dump(ceph::Formatter *f) const
void Capability::Export::generate_test_instances(std::list<Capability::Export*>& ls)
{
- ls.push_back(new Export);
- ls.push_back(new Export);
- ls.back()->wanted = 1;
- ls.back()->issued = 2;
- ls.back()->pending = 3;
- ls.back()->client_follows = 4;
- ls.back()->mseq = 5;
- ls.back()->last_issue_stamp = utime_t(6, 7);
+ ls.push_back(new Export());
+ ls.push_back(new Export(1, 2, 3, 4, 5, 6, 7, utime_t(8, 9), 10));
}
void Capability::Import::encode(ceph::buffer::list &bl) const
@@ -108,6 +102,11 @@ void Capability::Import::dump(ceph::Formatter *f) const
f->dump_unsigned("migrate_seq", mseq);
}
+void Capability::Import::generate_test_instances(std::list<Capability::Import*>& ls)
+{
+ ls.push_back(new Import());
+ ls.push_back(new Import(1, 2, 3));
+}
/*
* Capability::revoke_info
*/
diff --git a/src/mds/Capability.h b/src/mds/Capability.h
index 9680895a5c8..9adcf3b25b9 100644
--- a/src/mds/Capability.h
+++ b/src/mds/Capability.h
@@ -100,6 +100,7 @@ public:
void encode(ceph::buffer::list &bl) const;
void decode(ceph::buffer::list::const_iterator &p);
void dump(ceph::Formatter *f) const;
+ static void generate_test_instances(std::list<Import*>& ls);
int64_t cap_id = 0;
ceph_seq_t issue_seq = 0;
diff --git a/src/mds/FSMap.cc b/src/mds/FSMap.cc
index 88d7fda7c10..7e4df884ca1 100644
--- a/src/mds/FSMap.cc
+++ b/src/mds/FSMap.cc
@@ -115,6 +115,14 @@ void MirrorInfo::dump(ceph::Formatter *f) const {
f->close_section(); // peers
}
+void MirrorInfo::generate_test_instances(std::list<MirrorInfo*>& ls) {
+ ls.push_back(new MirrorInfo());
+ ls.push_back(new MirrorInfo());
+ ls.back()->mirrored = true;
+ ls.back()->peers.insert(Peer());
+ ls.back()->peers.insert(Peer());
+}
+
void MirrorInfo::print(std::ostream& out) const {
out << "[peers=" << peers << "]" << std::endl;
}
diff --git a/src/mds/FSMap.h b/src/mds/FSMap.h
index 518d6273e44..49f1b48d696 100644
--- a/src/mds/FSMap.h
+++ b/src/mds/FSMap.h
@@ -169,6 +169,7 @@ struct MirrorInfo {
Peers peers;
void dump(ceph::Formatter *f) const;
+ static void generate_test_instances(std::list<MirrorInfo*>& ls);
void print(std::ostream& out) const;
void encode(ceph::buffer::list &bl) const;
diff --git a/src/mds/MDCache.cc b/src/mds/MDCache.cc
index c433c77b453..eb2b529dcfa 100644
--- a/src/mds/MDCache.cc
+++ b/src/mds/MDCache.cc
@@ -960,17 +960,15 @@ void MDCache::adjust_subtree_auth(CDir *dir, mds_authority_t auth, bool adjust_p
dir->set_dir_auth(auth);
// move items nested beneath me, under me.
- set<CDir*>::iterator p = subtrees[root].begin();
+ auto p = subtrees[root].begin();
while (p != subtrees[root].end()) {
- set<CDir*>::iterator next = p;
- ++next;
if (get_subtree_root((*p)->get_parent_dir()) == dir) {
// move under me
dout(10) << " claiming child bound " << **p << dendl;
subtrees[dir].insert(*p);
- subtrees[root].erase(p);
- }
- p = next;
+ p = subtrees[root].erase(p);
+ } else
+ ++p;
}
// i am a bound of the parent subtree.
@@ -1113,17 +1111,15 @@ void MDCache::adjust_bounded_subtree_auth(CDir *dir, const set<CDir*>& bounds, m
dir->set_dir_auth(auth);
// move items nested beneath me, under me.
- set<CDir*>::iterator p = subtrees[root].begin();
+ auto p = subtrees[root].begin();
while (p != subtrees[root].end()) {
- set<CDir*>::iterator next = p;
- ++next;
if (get_subtree_root((*p)->get_parent_dir()) == dir) {
// move under me
dout(10) << " claiming child bound " << **p << dendl;
subtrees[dir].insert(*p);
- subtrees[root].erase(p);
- }
- p = next;
+ p = subtrees[root].erase(p);
+ } else
+ ++p;
}
// i am a bound of the parent subtree.
@@ -1172,8 +1168,8 @@ void MDCache::adjust_bounded_subtree_auth(CDir *dir, const set<CDir*>& bounds, m
}
// merge stray bounds?
while (!subtrees[dir].empty()) {
- set<CDir*> copy = subtrees[dir];
- for (set<CDir*>::iterator p = copy.begin(); p != copy.end(); ++p) {
+ const auto copy = subtrees[dir];
+ for (auto p = copy.begin(); p != copy.end(); ++p) {
if (bounds.count(*p) == 0) {
CDir *stray = *p;
dout(10) << " swallowing extra subtree at " << *stray << dendl;
@@ -1214,7 +1210,7 @@ void MDCache::get_force_dirfrag_bound_set(const vector<dirfrag_t>& dfs, set<CDir
}
dout(10) << " by ino: " << byino << dendl;
- for (map<inodeno_t,fragset_t>::iterator p = byino.begin(); p != byino.end(); ++p) {
+ for (auto p = byino.begin(); p != byino.end(); ++p) {
p->second.simplify();
CInode *diri = get_inode(p->first);
if (!diri)
@@ -1222,7 +1218,7 @@ void MDCache::get_force_dirfrag_bound_set(const vector<dirfrag_t>& dfs, set<CDir
dout(10) << " checking fragset " << p->second.get() << " on " << *diri << dendl;
fragtree_t tmpdft;
- for (set<frag_t>::iterator q = p->second.begin(); q != p->second.end(); ++q)
+ for (auto q = p->second.begin(); q != p->second.end(); ++q)
tmpdft.force_to_leaf(g_ceph_context, *q);
for (const auto& fg : p->second) {
@@ -1267,7 +1263,7 @@ void MDCache::map_dirfrag_set(const list<dirfrag_t>& dfs, set<CDir*>& result)
ino_fragset[df.ino].insert_raw(df.frag);
}
// get frags
- for (map<inodeno_t, fragset_t>::iterator p = ino_fragset.begin();
+ for (auto p = ino_fragset.begin();
p != ino_fragset.end();
++p) {
p->second.simplify();
@@ -1347,7 +1343,7 @@ void MDCache::get_wouldbe_subtree_bounds(CDir *dir, set<CDir*>& bounds)
} else {
// find them
CDir *root = get_subtree_root(dir);
- for (set<CDir*>::iterator p = subtrees[root].begin();
+ for (auto p = subtrees[root].begin();
p != subtrees[root].end();
++p) {
CDir *t = *p;
@@ -1415,7 +1411,7 @@ void MDCache::adjust_subtree_after_rename(CInode *diri, CDir *olddir, bool pop)
CDir *newdir = diri->get_parent_dir();
if (pop) {
- map<CInode*,list<pair<CDir*,CDir*> > >::iterator p = projected_subtree_renames.find(diri);
+ auto p = projected_subtree_renames.find(diri);
ceph_assert(p != projected_subtree_renames.end());
ceph_assert(!p->second.empty());
ceph_assert(p->second.front().first == olddir);
@@ -1815,7 +1811,7 @@ void MDCache::project_rstat_inode_to_frag(const MutationRef& mut,
if (cur->last != CEPH_NOSNAP) {
ceph_assert(cur->dirty_old_rstats.empty());
- set<snapid_t>::const_iterator q = snaps.lower_bound(std::max(first, floor));
+ auto q = snaps.lower_bound(std::max(first, floor));
if (q == snaps.end() || *q > cur->last)
return;
}
@@ -2487,7 +2483,7 @@ void MDCache::logged_leader_update(metareqid_t reqid)
*/
void MDCache::finish_committed_leaders()
{
- for (map<metareqid_t, uleader>::iterator p = uncommitted_leaders.begin();
+ for (auto p = uncommitted_leaders.begin();
p != uncommitted_leaders.end();
++p) {
p->second.recovering = false;
@@ -2536,16 +2532,16 @@ void MDCache::_move_subtree_map_bound(dirfrag_t df, dirfrag_t oldparent, dirfrag
map<dirfrag_t,vector<dirfrag_t> >& subtrees)
{
if (subtrees.count(oldparent)) {
- vector<dirfrag_t>& v = subtrees[oldparent];
+ auto& v = subtrees[oldparent];
dout(10) << " removing " << df << " from " << oldparent << " bounds " << v << dendl;
- for (vector<dirfrag_t>::iterator it = v.begin(); it != v.end(); ++it)
+ for (auto it = v.begin(); it != v.end(); ++it)
if (*it == df) {
v.erase(it);
break;
}
}
if (subtrees.count(newparent)) {
- vector<dirfrag_t>& v = subtrees[newparent];
+ auto& v = subtrees[newparent];
dout(10) << " adding " << df << " to " << newparent << " bounds " << v << dendl;
v.push_back(df);
}
@@ -2766,7 +2762,7 @@ void MDCache::send_peer_resolves()
map<mds_rank_t, ref_t<MMDSResolve>> resolves;
if (mds->is_resolve()) {
- for (map<metareqid_t, upeer>::iterator p = uncommitted_peers.begin();
+ for (auto p = uncommitted_peers.begin();
p != uncommitted_peers.end();
++p) {
mds_rank_t leader = p->second.leader;
@@ -2777,7 +2773,7 @@ void MDCache::send_peer_resolves()
} else {
set<mds_rank_t> resolve_set;
mds->mdsmap->get_mds_set(resolve_set, MDSMap::STATE_RESOLVE);
- for (ceph::unordered_map<metareqid_t, MDRequestRef>::iterator p = active_requests.begin();
+ for (auto p = active_requests.begin();
p != active_requests.end();
++p) {
MDRequestRef& mdr = p->second;
@@ -2828,7 +2824,7 @@ void MDCache::send_subtree_resolves()
}
map<mds_rank_t, ref_t<MMDSResolve>> resolves;
- for (set<mds_rank_t>::iterator p = recovery_set.begin();
+ for (auto p = recovery_set.begin();
p != recovery_set.end();
++p) {
if (*p == mds->get_nodeid())
@@ -2841,7 +2837,7 @@ void MDCache::send_subtree_resolves()
map<dirfrag_t, vector<dirfrag_t> > my_ambig_imports;
// known
- for (map<CDir*,set<CDir*> >::iterator p = subtrees.begin();
+ for (auto p = subtrees.begin();
p != subtrees.end();
++p) {
CDir *dir = p->first;
@@ -2858,7 +2854,7 @@ void MDCache::send_subtree_resolves()
set<CDir*> bounds;
get_subtree_bounds(dir, bounds);
vector<dirfrag_t> dfls;
- for (set<CDir*>::iterator q = bounds.begin(); q != bounds.end(); ++q)
+ for (auto q = bounds.begin(); q != bounds.end(); ++q)
dfls.push_back((*q)->dirfrag());
my_ambig_imports[dir->dirfrag()] = dfls;
@@ -2870,7 +2866,7 @@ void MDCache::send_subtree_resolves()
}
// bounds too
vector<dirfrag_t> dfls;
- for (set<CDir*>::iterator q = subtrees[dir].begin();
+ for (auto q = subtrees[dir].begin();
q != subtrees[dir].end();
++q) {
CDir *bound = *q;
@@ -2883,7 +2879,7 @@ void MDCache::send_subtree_resolves()
}
// ambiguous
- for (map<dirfrag_t, vector<dirfrag_t> >::iterator p = my_ambiguous_imports.begin();
+ for (auto p = my_ambiguous_imports.begin();
p != my_ambiguous_imports.end();
++p) {
my_ambig_imports[p->first] = p->second;
@@ -2896,9 +2892,9 @@ void MDCache::send_subtree_resolves()
while (i < p->second.size()) {
dirfrag_t b = p->second[i];
if (my_subtrees.count(b)) {
- vector<dirfrag_t>& bb = my_subtrees[b];
+ auto& bb = my_subtrees[b];
dout(10) << " simplify: " << p->first << " swallowing " << b << " with bounds " << bb << dendl;
- for (vector<dirfrag_t>::iterator r = bb.begin(); r != bb.end(); ++r)
+ for (auto r = bb.begin(); r != bb.end(); ++r)
p->second.push_back(*r);
my_subtrees.erase(b);
p->second.erase(p->second.begin() + i);
@@ -2963,7 +2959,7 @@ void MDCache::handle_mds_failure(mds_rank_t who)
// clean up any requests peer to/from this node
list<MDRequestRef> finish;
- for (ceph::unordered_map<metareqid_t, MDRequestRef>::iterator p = active_requests.begin();
+ for (auto p = active_requests.begin();
p != active_requests.end();
++p) {
MDRequestRef& mdr = p->second;
@@ -3061,7 +3057,7 @@ void MDCache::handle_mds_failure(mds_rank_t who)
}
}
- for (map<metareqid_t, uleader>::iterator p = uncommitted_leaders.begin();
+ for (auto p = uncommitted_leaders.begin();
p != uncommitted_leaders.end();
++p) {
// The failed MDS may have already committed the peer update
@@ -3080,7 +3076,7 @@ void MDCache::handle_mds_failure(mds_rank_t who)
kick_find_ino_peers(who);
kick_open_ino_peers(who);
- for (map<dirfrag_t,fragment_info_t>::iterator p = fragments.begin();
+ for (auto p = fragments.begin();
p != fragments.end(); ) {
dirfrag_t df = p->first;
fragment_info_t& info = p->second;
@@ -3089,18 +3085,17 @@ void MDCache::handle_mds_failure(mds_rank_t who)
if (info.notify_ack_waiting.erase(who) &&
info.notify_ack_waiting.empty()) {
fragment_drop_locks(info);
- fragment_maybe_finish(p++);
+ p = fragment_maybe_finish(p);
} else {
++p;
}
continue;
}
- ++p;
dout(10) << "cancelling fragment " << df << " bit " << info.bits << dendl;
std::vector<CDir*> dirs;
info.dirs.swap(dirs);
- fragments.erase(df);
+ p = fragments.erase(p);
fragment_unmark_unfreeze_dirs(dirs);
}
@@ -3126,7 +3121,7 @@ void MDCache::handle_mds_recovery(mds_rank_t who)
MDSContext::vec waiters;
// wake up any waiters in their subtrees
- for (map<CDir*,set<CDir*> >::iterator p = subtrees.begin();
+ for (auto p = subtrees.begin();
p != subtrees.end();
++p) {
CDir *dir = p->first;
@@ -3241,7 +3236,7 @@ void MDCache::handle_resolve(const cref_t<MMDSResolve> &m)
map<client_t,Capability::Export> cap_exports = inode_caps.cap_exports;
ceph_assert(get_inode(ino));
- for (map<client_t,Capability::Export>::iterator q = cap_exports.begin();
+ for (auto q = cap_exports.begin();
q != cap_exports.end();
++q) {
Capability::Import& im = rejoin_imported_caps[from][ino][q->first];
@@ -3283,10 +3278,8 @@ void MDCache::handle_resolve(const cref_t<MMDSResolve> &m)
if (mds->is_clientreplay() || mds->is_active() || mds->is_stopping()) {
survivor = true;
// check for any import success/failure (from this node)
- map<dirfrag_t, vector<dirfrag_t> >::iterator p = my_ambiguous_imports.begin();
+ auto p = my_ambiguous_imports.begin();
while (p != my_ambiguous_imports.end()) {
- map<dirfrag_t, vector<dirfrag_t> >::iterator next = p;
- ++next;
CDir *dir = get_dirfrag(p->first);
ceph_assert(dir);
dout(10) << "checking ambiguous import " << *dir << dendl;
@@ -3305,7 +3298,7 @@ void MDCache::handle_resolve(const cref_t<MMDSResolve> &m)
bool inside = true;
set<CDir*> bounds;
get_force_dirfrag_bound_set(q.second, bounds);
- for (set<CDir*>::iterator p = bounds.begin(); p != bounds.end(); ++p) {
+ for (auto p = bounds.begin(); p != bounds.end(); ++p) {
CDir *bound = *p;
if (bound->contains(dir)) {
inside = false; // nope, bound is dir or parent of dir, not inside.
@@ -3316,7 +3309,7 @@ void MDCache::handle_resolve(const cref_t<MMDSResolve> &m)
claimed_by_sender = true;
}
- my_ambiguous_imports.erase(p); // no longer ambiguous.
+ p = my_ambiguous_imports.erase(p); // no longer ambiguous.
if (claimed_by_sender) {
dout(7) << "ambiguous import failed on " << *dir << dendl;
migrator->import_reverse(dir);
@@ -3324,8 +3317,8 @@ void MDCache::handle_resolve(const cref_t<MMDSResolve> &m)
dout(7) << "ambiguous import succeeded on " << *dir << dendl;
migrator->import_finish(dir, true);
}
- }
- p = next;
+ } else
+ ++p;
}
}
@@ -3507,9 +3500,9 @@ void MDCache::add_uncommitted_peer(metareqid_t reqid, LogSegment *ls, mds_rank_t
if (su == nullptr) {
return;
}
- for(set<CInode*>::iterator p = su->olddirs.begin(); p != su->olddirs.end(); ++p)
+ for(auto p = su->olddirs.begin(); p != su->olddirs.end(); ++p)
uncommitted_peer_rename_olddir[*p]++;
- for(set<CInode*>::iterator p = su->unlinked.begin(); p != su->unlinked.end(); ++p)
+ for(auto p = su->unlinked.begin(); p != su->unlinked.end(); ++p)
uncommitted_peer_unlink[*p]++;
}
@@ -3533,9 +3526,9 @@ void MDCache::finish_uncommitted_peer(metareqid_t reqid, bool assert_exist)
return;
}
// discard the non-auth subtree we renamed out of
- for(set<CInode*>::iterator p = su->olddirs.begin(); p != su->olddirs.end(); ++p) {
+ for(auto p = su->olddirs.begin(); p != su->olddirs.end(); ++p) {
CInode *diri = *p;
- map<CInode*, int>::iterator it = uncommitted_peer_rename_olddir.find(diri);
+ auto it = uncommitted_peer_rename_olddir.find(diri);
ceph_assert(it != uncommitted_peer_rename_olddir.end());
it->second--;
if (it->second == 0) {
@@ -3553,9 +3546,9 @@ void MDCache::finish_uncommitted_peer(metareqid_t reqid, bool assert_exist)
ceph_assert(it->second > 0);
}
// removed the inodes that were unlinked by peer update
- for(set<CInode*>::iterator p = su->unlinked.begin(); p != su->unlinked.end(); ++p) {
+ for(auto p = su->unlinked.begin(); p != su->unlinked.end(); ++p) {
CInode *in = *p;
- map<CInode*, int>::iterator it = uncommitted_peer_unlink.find(in);
+ auto it = uncommitted_peer_unlink.find(in);
ceph_assert(it != uncommitted_peer_unlink.end());
it->second--;
if (it->second == 0) {
@@ -3598,13 +3591,13 @@ void MDCache::disambiguate_other_imports()
bool recovering = !(mds->is_clientreplay() || mds->is_active() || mds->is_stopping());
// other nodes' ambiguous imports
- for (map<mds_rank_t, map<dirfrag_t, vector<dirfrag_t> > >::iterator p = other_ambiguous_imports.begin();
+ for (auto p = other_ambiguous_imports.begin();
p != other_ambiguous_imports.end();
++p) {
mds_rank_t who = p->first;
dout(10) << "ambiguous imports for mds." << who << dendl;
- for (map<dirfrag_t, vector<dirfrag_t> >::iterator q = p->second.begin();
+ for (auto q = p->second.begin();
q != p->second.end();
++q) {
dout(10) << " ambiguous import " << q->first << " bounds " << q->second << dendl;
@@ -3639,7 +3632,7 @@ void MDCache::disambiguate_my_imports()
// my ambiguous imports
mds_authority_t me_ambig(mds->get_nodeid(), mds->get_nodeid());
while (!my_ambiguous_imports.empty()) {
- map<dirfrag_t, vector<dirfrag_t> >::iterator q = my_ambiguous_imports.begin();
+ auto q = my_ambiguous_imports.begin();
CDir *dir = get_dirfrag(q->first);
ceph_assert(dir);
@@ -3667,7 +3660,7 @@ void MDCache::disambiguate_my_imports()
mds->mdlog->flush();
// verify all my subtrees are unambiguous!
- for (map<CDir*,set<CDir*> >::iterator p = subtrees.begin();
+ for (auto p = subtrees.begin();
p != subtrees.end();
++p) {
CDir *dir = p->first;
@@ -3692,7 +3685,7 @@ void MDCache::add_ambiguous_import(CDir *base, const set<CDir*>& bounds)
{
// make a list
vector<dirfrag_t> binos;
- for (set<CDir*>::iterator p = bounds.begin();
+ for (auto p = bounds.begin();
p != bounds.end();
++p)
binos.push_back((*p)->dirfrag());
@@ -3849,14 +3842,14 @@ void MDCache::recalc_auth_bits(bool replay)
}
set<CInode*> subtree_inodes;
- for (map<CDir*,set<CDir*> >::iterator p = subtrees.begin();
+ for (auto p = subtrees.begin();
p != subtrees.end();
++p) {
if (p->first->dir_auth.first == mds->get_nodeid())
subtree_inodes.insert(p->first->inode);
}
- for (map<CDir*,set<CDir*> >::iterator p = subtrees.begin();
+ for (auto p = subtrees.begin();
p != subtrees.end();
++p) {
if (p->first->inode->is_mdsdir()) {
@@ -4079,7 +4072,7 @@ void MDCache::rejoin_send_rejoins()
++q;
} else {
// remove reconnect with no session
- p.second.second.erase(q++);
+ q = p.second.second.erase(q);
}
}
rejoins[target]->cap_exports[p.first] = p.second.second;
@@ -4096,7 +4089,7 @@ void MDCache::rejoin_send_rejoins()
// check all subtrees
- for (map<CDir*, set<CDir*> >::iterator p = subtrees.begin();
+ for (auto p = subtrees.begin();
p != subtrees.end();
++p) {
CDir *dir = p->first;
@@ -4166,7 +4159,7 @@ void MDCache::rejoin_send_rejoins()
if (!mds->is_rejoin()) {
// i am survivor. send strong rejoin.
// note request remote_auth_pins, xlocks
- for (ceph::unordered_map<metareqid_t, MDRequestRef>::iterator p = active_requests.begin();
+ for (auto p = active_requests.begin();
p != active_requests.end();
++p) {
MDRequestRef& mdr = p->second;
@@ -4582,7 +4575,7 @@ void MDCache::handle_cache_rejoin_weak(const cref_t<MMDSCacheRejoin> &weak)
}
// weak base inodes? (root, stray, etc.)
- for (set<vinodeno_t>::iterator p = weak->weak_inodes.begin();
+ for (auto p = weak->weak_inodes.begin();
p != weak->weak_inodes.end();
++p) {
CInode *in = get_inode(*p);
@@ -4616,7 +4609,7 @@ void MDCache::handle_cache_rejoin_weak(const cref_t<MMDSCacheRejoin> &weak)
rejoin_scour_survivor_replicas(from, ack, acked_inodes, gather_locks);
mds->send_message(ack, weak->get_connection());
- for (set<SimpleLock*>::iterator p = gather_locks.begin(); p != gather_locks.end(); ++p) {
+ for (auto p = gather_locks.begin(); p != gather_locks.end(); ++p) {
if (!(*p)->is_stable())
mds->locker->eval_gather(*p);
}
@@ -5184,12 +5177,12 @@ void MDCache::handle_cache_rejoin_ack(const cref_t<MMDSCacheRejoin> &ack)
auto bp = ack->imported_caps.cbegin();
decode(peer_imported, bp);
- for (map<inodeno_t,map<client_t,Capability::Import> >::iterator p = peer_imported.begin();
+ for (auto p = peer_imported.begin();
p != peer_imported.end();
++p) {
auto& ex = cap_exports.at(p->first);
ceph_assert(ex.first == from);
- for (map<client_t,Capability::Import>::iterator q = p->second.begin();
+ for (auto q = p->second.begin();
q != p->second.end();
++q) {
auto r = ex.second.find(q->first);
@@ -5271,7 +5264,7 @@ void MDCache::rejoin_trim_undef_inodes()
dout(10) << "rejoin_trim_undef_inodes" << dendl;
while (!rejoin_undef_inodes.empty()) {
- set<CInode*>::iterator p = rejoin_undef_inodes.begin();
+ auto p = rejoin_undef_inodes.begin();
CInode *in = *p;
rejoin_undef_inodes.erase(p);
@@ -5496,12 +5489,12 @@ bool MDCache::process_imported_caps()
}
// process caps that were exported by peer rename
- for (map<inodeno_t,pair<mds_rank_t,map<client_t,Capability::Export> > >::iterator p = rejoin_peer_exports.begin();
+ for (auto p = rejoin_peer_exports.begin();
p != rejoin_peer_exports.end();
++p) {
CInode *in = get_inode(p->first);
ceph_assert(in);
- for (map<client_t,Capability::Export>::iterator q = p->second.second.begin();
+ for (auto q = p->second.second.begin();
q != p->second.second.end();
++q) {
auto r = rejoin_session_map.find(q->first);
@@ -5568,7 +5561,7 @@ bool MDCache::process_imported_caps()
}
}
}
- cap_imports.erase(p++); // remove and move on
+ p = cap_imports.erase(p); // remove and move on
}
} else {
trim_non_auth();
@@ -5690,7 +5683,7 @@ void MDCache::prepare_realm_merge(SnapRealm *realm, SnapRealm *parent_realm,
for (auto p = realm->inodes_with_caps.begin(); !p.end(); ++p)
split_inos.push_back((*p)->ino());
- for (set<SnapRealm*>::iterator p = realm->open_children.begin();
+ for (auto p = realm->open_children.begin();
p != realm->open_children.end();
++p)
split_realms.push_back((*p)->inode->ino());
@@ -5737,12 +5730,12 @@ void MDCache::clean_open_file_lists()
{
dout(10) << "clean_open_file_lists" << dendl;
- for (map<uint64_t,LogSegment*>::iterator p = mds->mdlog->segments.begin();
+ for (auto p = mds->mdlog->segments.begin();
p != mds->mdlog->segments.end();
++p) {
LogSegment *ls = p->second;
- elist<CInode*>::iterator q = ls->open_files.begin(member_offset(CInode, item_open_file));
+ auto q = ls->open_files.begin(member_offset(CInode, item_open_file));
while (!q.end()) {
CInode *in = *q;
++q;
@@ -5828,7 +5821,7 @@ void MDCache::export_remaining_imported_caps()
mds->heartbeat_reset();
}
- for (map<inodeno_t, MDSContext::vec >::iterator p = cap_reconnect_waiters.begin();
+ for (auto p = cap_reconnect_waiters.begin();
p != cap_reconnect_waiters.end();
++p)
mds->queue_waiters(p->second);
@@ -5869,7 +5862,7 @@ Capability* MDCache::try_reconnect_cap(CInode *in, Session *session)
dout(15) << " chose lock states on " << *in << dendl;
}
- map<inodeno_t, MDSContext::vec >::iterator it =
+ auto it =
cap_reconnect_waiters.find(in->ino());
if (it != cap_reconnect_waiters.end()) {
mds->queue_waiters(it->second);
@@ -5956,7 +5949,7 @@ void MDCache::open_snaprealms()
}
}
- rejoin_pending_snaprealms.erase(it++);
+ it = rejoin_pending_snaprealms.erase(it);
in->put(CInode::PIN_OPENINGSNAPPARENTS);
send_snaps(splits);
@@ -6094,10 +6087,10 @@ void MDCache::rejoin_send_acks()
dout(7) << "rejoin_send_acks" << dendl;
// replicate stray
- for (map<mds_rank_t, set<CInode*> >::iterator p = rejoin_unlinked_inodes.begin();
+ for (auto p = rejoin_unlinked_inodes.begin();
p != rejoin_unlinked_inodes.end();
++p) {
- for (set<CInode*>::iterator q = p->second.begin();
+ for (auto q = p->second.begin();
q != p->second.end();
++q) {
CInode *in = *q;
@@ -6127,7 +6120,7 @@ void MDCache::rejoin_send_acks()
// send acks to everyone in the recovery set
map<mds_rank_t,ref_t<MMDSCacheRejoin>> acks;
- for (set<mds_rank_t>::iterator p = recovery_set.begin();
+ for (auto p = recovery_set.begin();
p != recovery_set.end();
++p) {
if (rejoin_ack_sent.count(*p))
@@ -6138,7 +6131,7 @@ void MDCache::rejoin_send_acks()
rejoin_ack_sent = recovery_set;
// walk subtrees
- for (map<CDir*,set<CDir*> >::iterator p = subtrees.begin();
+ for (auto p = subtrees.begin();
p != subtrees.end();
++p) {
CDir *dir = p->first;
@@ -6236,7 +6229,7 @@ void MDCache::rejoin_send_acks()
}
// include inode base for any inodes whose scatterlocks may have updated
- for (set<CInode*>::iterator p = rejoin_potential_updated_scatterlocks.begin();
+ for (auto p = rejoin_potential_updated_scatterlocks.begin();
p != rejoin_potential_updated_scatterlocks.end();
++p) {
CInode *in = *p;
@@ -6663,7 +6656,7 @@ void MDCache::truncate_inode_finish(CInode *in, LogSegment *ls)
{
dout(10) << "truncate_inode_finish " << *in << dendl;
- set<CInode*>::iterator p = ls->truncating_inodes.find(in);
+ auto p = ls->truncating_inodes.find(in);
ceph_assert(p != ls->truncating_inodes.end());
ls->truncating_inodes.erase(p);
@@ -6719,7 +6712,7 @@ void MDCache::remove_recovered_truncate(CInode *in, LogSegment *ls)
dout(20) << "remove_recovered_truncate " << *in << " in log segment "
<< ls->seq << "/" << ls->offset << dendl;
// if we have the logseg the truncate started in, it must be in our list.
- set<CInode*>::iterator p = ls->truncating_inodes.find(in);
+ auto p = ls->truncating_inodes.find(in);
ceph_assert(p != ls->truncating_inodes.end());
ls->truncating_inodes.erase(p);
in->put(CInode::PIN_TRUNCATING);
@@ -6728,11 +6721,11 @@ void MDCache::remove_recovered_truncate(CInode *in, LogSegment *ls)
void MDCache::start_recovered_truncates()
{
dout(10) << "start_recovered_truncates" << dendl;
- for (map<uint64_t,LogSegment*>::iterator p = mds->mdlog->segments.begin();
+ for (auto p = mds->mdlog->segments.begin();
p != mds->mdlog->segments.end();
++p) {
LogSegment *ls = p->second;
- for (set<CInode*>::iterator q = ls->truncating_inodes.begin();
+ for (auto q = ls->truncating_inodes.begin();
q != ls->truncating_inodes.end();
++q) {
CInode *in = *q;
@@ -7006,7 +6999,7 @@ std::pair<bool, uint64_t> MDCache::trim(uint64_t count)
// Other rank's base inodes (when I'm stopping)
if (mds->is_stopping()) {
- for (set<CInode*>::iterator p = base_inodes.begin();
+ for (auto p = base_inodes.begin();
p != base_inodes.end();) {
CInode *base_in = *p;
++p;
@@ -7278,7 +7271,7 @@ void MDCache::trim_non_auth()
dout(7) << "trim_non_auth" << dendl;
// temporarily pin all subtree roots
- for (map<CDir*, set<CDir*> >::iterator p = subtrees.begin();
+ for (auto p = subtrees.begin();
p != subtrees.end();
++p)
p->first->get(CDir::PIN_SUBTREETEMP);
@@ -7349,7 +7342,7 @@ void MDCache::trim_non_auth()
lru.lru_touch_entire_pintail();
// unpin all subtrees
- for (map<CDir*, set<CDir*> >::iterator p = subtrees.begin();
+ for (auto p = subtrees.begin();
p != subtrees.end();
++p)
p->first->put(CDir::PIN_SUBTREETEMP);
@@ -7461,7 +7454,7 @@ void MDCache::try_trim_non_auth_subtree(CDir *dir)
// can we now trim child subtrees?
set<CDir*> bounds;
get_subtree_bounds(dir, bounds);
- for (set<CDir*>::iterator p = bounds.begin(); p != bounds.end(); ++p) {
+ for (auto p = bounds.begin(); p != bounds.end(); ++p) {
CDir *bd = *p;
if (bd->get_dir_auth().first != mds->get_nodeid() && // we are not auth
bd->get_num_any() == 0 && // and empty
@@ -7746,7 +7739,7 @@ void MDCache::handle_cache_expire(const cref_t<MCacheExpire> &m)
}
}
- for (set<SimpleLock*>::iterator p = gather_locks.begin(); p != gather_locks.end(); ++p) {
+ for (auto p = gather_locks.begin(); p != gather_locks.end(); ++p) {
if (!(*p)->is_stable())
mds->locker->eval_gather(*p);
}
@@ -9292,7 +9285,7 @@ void MDCache::do_open_ino_peer(inodeno_t ino, open_ino_info_t& info)
info.auth_hint = MDS_RANK_NONE;
}
} else {
- for (set<mds_rank_t>::iterator p = active.begin(); p != active.end(); ++p)
+ for (auto p = active.begin(); p != active.end(); ++p)
if (*p != whoami && info.checked.count(*p) == 0) {
peer = *p;
break;
@@ -9405,7 +9398,7 @@ void MDCache::kick_open_ino_peers(mds_rank_t who)
{
dout(10) << "kick_open_ino_peers mds." << who << dendl;
- for (map<inodeno_t, open_ino_info_t>::iterator p = opening_inodes.begin();
+ for (auto p = opening_inodes.begin();
p != opening_inodes.end();
++p) {
open_ino_info_t& info = p->second;
@@ -9546,7 +9539,7 @@ void MDCache::_do_find_ino_peer(find_ino_peer_info_t& fip)
m = fip.hint;
fip.hint = MDS_RANK_NONE;
} else {
- for (set<mds_rank_t>::iterator p = active.begin(); p != active.end(); ++p)
+ for (auto p = active.begin(); p != active.end(); ++p)
if (*p != mds->get_nodeid() &&
fip.checked.count(*p) == 0) {
m = *p;
@@ -9645,7 +9638,7 @@ void MDCache::handle_find_ino_reply(const cref_t<MMDSFindInoReply> &m)
void MDCache::kick_find_ino_peers(mds_rank_t who)
{
// find_ino_peers requests we should move on from
- for (map<ceph_tid_t,find_ino_peer_info_t>::iterator p = find_ino_peer.begin();
+ for (auto p = find_ino_peer.begin();
p != find_ino_peer.end();
++p) {
find_ino_peer_info_t& fip = p->second;
@@ -9665,7 +9658,7 @@ void MDCache::kick_find_ino_peers(mds_rank_t who)
int MDCache::get_num_client_requests()
{
int count = 0;
- for (ceph::unordered_map<metareqid_t, MDRequestRef>::iterator p = active_requests.begin();
+ for (auto p = active_requests.begin();
p != active_requests.end();
++p) {
MDRequestRef& mdr = p->second;
@@ -9766,7 +9759,7 @@ MDRequestRef MDCache::request_start_internal(int op)
MDRequestRef MDCache::request_get(metareqid_t rid)
{
- ceph::unordered_map<metareqid_t, MDRequestRef>::iterator p = active_requests.find(rid);
+ auto p = active_requests.find(rid);
ceph_assert(p != active_requests.end());
dout(7) << "request_get " << rid << " " << *p->second << dendl;
return p->second;
@@ -10435,7 +10428,7 @@ void MDCache::discover_path(CDir *base,
void MDCache::kick_discovers(mds_rank_t who)
{
- for (map<ceph_tid_t,discover_info_t>::iterator p = discovers.begin();
+ for (auto p = discovers.begin();
p != discovers.end();
++p) {
if (p->second.mds != who)
@@ -10772,7 +10765,7 @@ void MDCache::handle_discover_reply(const cref_t<MDiscoverReply> &m)
// decrement discover counters
if (m->get_tid()) {
- map<ceph_tid_t,discover_info_t>::iterator p = discovers.find(m->get_tid());
+ auto p = discovers.find(m->get_tid());
if (p != discovers.end()) {
dout(10) << " found tid " << m->get_tid() << dendl;
discovers.erase(p);
@@ -11178,7 +11171,7 @@ int MDCache::send_dir_updates(CDir *dir, bool bcast)
}
mds_rank_t whoami = mds->get_nodeid();
- for (set<mds_rank_t>::iterator it = who.begin();
+ for (auto it = who.begin();
it != who.end();
++it) {
if (*it == whoami) continue;
@@ -11351,7 +11344,7 @@ void MDCache::send_dentry_unlink(CDentry *dn, CDentry *straydn, const MDRequestR
CInode *strayin = straydn->get_linkage()->get_inode();
strayin->encode_snap_blob(snapbl);
}
- for (set<mds_rank_t>::iterator it = replicas.begin();
+ for (auto it = replicas.begin();
it != replicas.end();
++it) {
// don't tell (rmdir) witnesses; they already know
@@ -11588,7 +11581,7 @@ void MDCache::adjust_dir_fragments(CInode *diri,
set<CDir*> bounds;
bounds.swap(subtrees[dir]);
subtrees.erase(dir);
- for (set<CDir*>::iterator p = bounds.begin();
+ for (auto p = bounds.begin();
p != bounds.end();
++p) {
CDir *frag = get_subtree_root((*p)->get_parent_dir());
@@ -11627,11 +11620,11 @@ void MDCache::adjust_dir_fragments(CInode *diri,
for (const auto& dir : srcfrags) {
ceph_assert(dir->is_subtree_root());
dout(10) << " taking srcfrag subtree bounds from " << *dir << dendl;
- map<CDir*, set<CDir*> >::iterator q = subtrees.find(dir);
- set<CDir*>::iterator r = q->second.begin();
+ auto q = subtrees.find(dir);
+ auto r = q->second.begin();
while (r != subtrees[dir].end()) {
new_bounds.insert(*r);
- subtrees[dir].erase(r++);
+ r = subtrees[dir].erase(r);
}
subtrees.erase(q);
@@ -11835,7 +11828,7 @@ public:
void MDCache::fragment_mark_and_complete(const MDRequestRef& mdr)
{
dirfrag_t basedirfrag = mdr->more()->fragment_base;
- map<dirfrag_t,fragment_info_t>::iterator it = fragments.find(basedirfrag);
+ auto it = fragments.find(basedirfrag);
if (it == fragments.end() || it->second.mdr != mdr) {
dout(7) << "fragment_mark_and_complete " << basedirfrag << " must have aborted" << dendl;
request_finish(mdr);
@@ -11938,8 +11931,7 @@ void MDCache::fragment_unmark_unfreeze_dirs(const std::vector<CDir*>& dirs)
bool MDCache::fragment_are_all_frozen(CDir *dir)
{
ceph_assert(dir->is_frozen_dir());
- map<dirfrag_t,fragment_info_t>::iterator p;
- for (p = fragments.lower_bound(dirfrag_t(dir->ino(), 0));
+ for (auto p = fragments.lower_bound(dirfrag_t(dir->ino(), 0));
p != fragments.end() && p->first.ino == dir->ino();
++p) {
if (p->first.frag.contains(dir->get_frag()))
@@ -11951,8 +11943,7 @@ bool MDCache::fragment_are_all_frozen(CDir *dir)
void MDCache::fragment_freeze_inc_num_waiters(CDir *dir)
{
- map<dirfrag_t,fragment_info_t>::iterator p;
- for (p = fragments.lower_bound(dirfrag_t(dir->ino(), 0));
+ for (auto p = fragments.lower_bound(dirfrag_t(dir->ino(), 0));
p != fragments.end() && p->first.ino == dir->ino();
++p) {
if (p->first.frag.contains(dir->get_frag())) {
@@ -11971,7 +11962,7 @@ void MDCache::find_stale_fragment_freeze()
utime_t cutoff = now;
cutoff -= g_conf()->mds_freeze_tree_timeout;
- for (map<dirfrag_t,fragment_info_t>::iterator p = fragments.begin();
+ for (auto p = fragments.begin();
p != fragments.end(); ) {
dirfrag_t df = p->first;
fragment_info_t& info = p->second;
@@ -12060,7 +12051,7 @@ public:
void MDCache::fragment_frozen(const MDRequestRef& mdr, int r)
{
dirfrag_t basedirfrag = mdr->more()->fragment_base;
- map<dirfrag_t,fragment_info_t>::iterator it = fragments.find(basedirfrag);
+ auto it = fragments.find(basedirfrag);
if (it == fragments.end() || it->second.mdr != mdr || r < 0) {
dout(7) << "fragment_frozen " << basedirfrag << " must have aborted; rc=" << r << dendl;
request_finish(mdr);
@@ -12079,7 +12070,7 @@ void MDCache::fragment_frozen(const MDRequestRef& mdr, int r)
void MDCache::dispatch_fragment_dir(const MDRequestRef& mdr, bool abort_if_freezing)
{
dirfrag_t basedirfrag = mdr->more()->fragment_base;
- map<dirfrag_t,fragment_info_t>::iterator it = fragments.find(basedirfrag);
+ auto it = fragments.find(basedirfrag);
if (it == fragments.end() || it->second.mdr != mdr) {
dout(7) << __func__ << ": " << basedirfrag << " must have aborted" << dendl;
request_finish(mdr);
@@ -12402,12 +12393,12 @@ void MDCache::fragment_drop_locks(fragment_info_t& info)
//info.mdr.reset();
}
-void MDCache::fragment_maybe_finish(const fragment_info_iterator& it)
+MDCache::fragment_info_iterator MDCache::fragment_maybe_finish(const fragment_info_iterator it)
{
ceph_assert(kill_dirfrag_at != dirfrag_killpoint::FRAGMENT_MAYBE_FINISH);
if (!it->second.finishing)
- return;
+ return it;
// unmark & auth_unpin
for (const auto &dir : it->second.resultfrags) {
@@ -12421,7 +12412,7 @@ void MDCache::fragment_maybe_finish(const fragment_info_iterator& it)
mds->balancer->maybe_fragment(dir, false);
}
- fragments.erase(it);
+ return fragments.erase(it);
}
@@ -12522,7 +12513,7 @@ void MDCache::finish_uncommitted_fragment(dirfrag_t basedirfrag, int op)
{
dout(10) << "finish_uncommitted_fragments: base dirfrag " << basedirfrag
<< " op " << EFragment::op_name(op) << dendl;
- map<dirfrag_t, ufragment>::iterator it = uncommitted_fragments.find(basedirfrag);
+ auto it = uncommitted_fragments.find(basedirfrag);
if (it != uncommitted_fragments.end()) {
ufragment& uf = it->second;
if (op != EFragment::OP_FINISH && !uf.old_frags.empty()) {
@@ -12539,7 +12530,7 @@ void MDCache::rollback_uncommitted_fragment(dirfrag_t basedirfrag, frag_vec_t&&
{
dout(10) << "rollback_uncommitted_fragment: base dirfrag " << basedirfrag
<< " old_frags (" << old_frags << ")" << dendl;
- map<dirfrag_t, ufragment>::iterator it = uncommitted_fragments.find(basedirfrag);
+ auto it = uncommitted_fragments.find(basedirfrag);
if (it != uncommitted_fragments.end()) {
ufragment& uf = it->second;
if (!uf.old_frags.empty()) {
@@ -12575,7 +12566,7 @@ struct C_MDC_FragmentRollback : public MDCacheLogContext {
void MDCache::rollback_uncommitted_fragments()
{
dout(10) << "rollback_uncommitted_fragments: " << uncommitted_fragments.size() << " pending" << dendl;
- for (map<dirfrag_t, ufragment>::iterator p = uncommitted_fragments.begin();
+ for (auto p = uncommitted_fragments.begin();
p != uncommitted_fragments.end();
++p) {
ufragment &uf = p->second;
@@ -12722,7 +12713,7 @@ void MDCache::show_subtrees(int dbl, bool force_print)
// root frags
std::vector<CDir*> basefrags;
- for (set<CInode*>::iterator p = base_inodes.begin();
+ for (auto p = base_inodes.begin();
p != base_inodes.end();
++p)
(*p)->get_dirfrags(basefrags);
@@ -12760,13 +12751,11 @@ void MDCache::show_subtrees(int dbl, bool force_print)
seen.insert(dir);
// nested items?
- if (!subtrees[dir].empty()) {
- for (set<CDir*>::iterator p = subtrees[dir].begin();
- p != subtrees[dir].end();
- ++p) {
- //dout(25) << " saw sub " << **p << dendl;
- q.push_front(pair<CDir*,int>(*p, d+1));
- }
+ for (auto p = subtrees[dir].begin();
+ p != subtrees[dir].end();
+ ++p) {
+ //dout(25) << " saw sub " << **p << dendl;
+ q.push_front(pair<CDir*,int>(*p, d+1));
}
}
@@ -12831,7 +12820,7 @@ void MDCache::show_subtrees(int dbl, bool force_print)
else
indent += " ";
- for (set<CDir*>::iterator p = subtrees[dir].begin();
+ for (auto p = subtrees[dir].begin();
p != subtrees[dir].end();
++p)
q.push_front(pair<CDir*,int>(*p, d+2));
@@ -12840,7 +12829,7 @@ void MDCache::show_subtrees(int dbl, bool force_print)
// verify there isn't stray crap in subtree map
int lost = 0;
- for (map<CDir*, set<CDir*> >::iterator p = subtrees.begin();
+ for (auto p = subtrees.begin();
p != subtrees.end();
++p) {
if (subtrees_seen.count(p->first)) continue;
diff --git a/src/mds/MDCache.h b/src/mds/MDCache.h
index 0b01c9ab859..3c5d7e5e4f4 100644
--- a/src/mds/MDCache.h
+++ b/src/mds/MDCache.h
@@ -1485,7 +1485,7 @@ private:
void fragment_frozen(const MDRequestRef& mdr, int r);
void fragment_unmark_unfreeze_dirs(const std::vector<CDir*>& dirs);
void fragment_drop_locks(fragment_info_t &info);
- void fragment_maybe_finish(const fragment_info_iterator& it);
+ fragment_info_iterator fragment_maybe_finish(const fragment_info_iterator it);
void dispatch_fragment_dir(const MDRequestRef& mdr, bool abort_if_freezing=false);
void _fragment_logged(const MDRequestRef& mdr);
void _fragment_stored(const MDRequestRef& mdr);
diff --git a/src/mds/MDLog.cc b/src/mds/MDLog.cc
index 40d893d6262..0be568433ef 100644
--- a/src/mds/MDLog.cc
+++ b/src/mds/MDLog.cc
@@ -146,13 +146,63 @@ class C_MDL_WriteError : public MDSIOContextBase {
};
+class C_MDL_WriteHead : public MDSIOContextBase {
+public:
+ explicit C_MDL_WriteHead(MDLog* m)
+ : MDSIOContextBase(true)
+ , mdlog(m)
+ {}
+ void print(ostream& out) const override {
+ out << "mdlog_write_head";
+ }
+protected:
+ void finish(int r) override {
+ mdlog->finish_head_waiters();
+ }
+ MDSRank *get_mds() override {return mdlog->mds;}
+
+ MDLog *mdlog;
+};
+
+void MDLog::finish_head_waiters()
+{
+ ceph_assert(ceph_mutex_is_locked_by_me(mds->mds_lock));
+
+ auto&& last_committed = journaler->get_last_committed();
+ auto& expire_pos = last_committed.expire_pos;
+
+ dout(20) << __func__ << " expire_pos=" << std::hex << expire_pos << dendl;
+
+ {
+ auto last = waiting_for_expire.upper_bound(expire_pos);
+ for (auto it = waiting_for_expire.begin(); it != last; it++) {
+ finish_contexts(g_ceph_context, it->second);
+ }
+ waiting_for_expire.erase(waiting_for_expire.begin(), last);
+ }
+}
+
void MDLog::write_head(MDSContext *c)
{
- Context *fin = NULL;
- if (c != NULL) {
- fin = new C_IO_Wrapper(mds, c);
+ ceph_assert(ceph_mutex_is_locked_by_me(mds->mds_lock));
+
+ auto&& last_written = journaler->get_last_written();
+ auto expire_pos = journaler->get_expire_pos();
+ dout(10) << __func__ << " last_written=" << last_written << " current expire_pos=" << std::hex << expire_pos << dendl;
+
+ if (last_written.expire_pos < expire_pos) {
+ if (c != NULL) {
+ dout(25) << __func__ << " queueing waiter " << c << dendl;
+ waiting_for_expire[expire_pos].push_back(c);
+ }
+
+ auto* fin = new C_MDL_WriteHead(this);
+ journaler->write_head(fin);
+ } else {
+ if (c) {
+ c->complete(0);
+ }
}
- journaler->write_head(fin);
}
uint64_t MDLog::get_read_pos() const
@@ -174,6 +224,8 @@ uint64_t MDLog::get_safe_pos() const
void MDLog::create(MDSContext *c)
{
+ ceph_assert(ceph_mutex_is_locked_by_me(mds->mds_lock));
+
dout(5) << "create empty log" << dendl;
C_GatherBuilder gather(g_ceph_context);
@@ -287,6 +339,8 @@ LogSegment* MDLog::_start_new_segment(SegmentBoundary* sb)
logger->set(l_mdl_seg, segments.size());
sb->set_seq(event_seq);
+ dout(20) << __func__ << ": starting new segment " << *ls << dendl;
+
// Adjust to next stray dir
if (!mds->is_stopping()) {
mds->mdcache->advance_stray();
@@ -583,17 +637,6 @@ void MDLog::shutdown()
}
}
-class C_OFT_Committed : public MDSInternalContext {
- MDLog *mdlog;
- uint64_t seq;
-public:
- C_OFT_Committed(MDLog *l, uint64_t s) :
- MDSInternalContext(l->mds), mdlog(l), seq(s) {}
- void finish(int ret) override {
- mdlog->trim_expired_segments();
- }
-};
-
void MDLog::try_to_commit_open_file_table(uint64_t last_seq)
{
ceph_assert(ceph_mutex_is_locked_by_me(submit_mutex));
@@ -608,8 +651,7 @@ void MDLog::try_to_commit_open_file_table(uint64_t last_seq)
if (mds->mdcache->open_file_table.is_any_dirty() ||
last_seq > mds->mdcache->open_file_table.get_committed_log_seq()) {
submit_mutex.unlock();
- mds->mdcache->open_file_table.commit(new C_OFT_Committed(this, last_seq),
- last_seq, CEPH_MSG_PRIO_HIGH);
+ mds->mdcache->open_file_table.commit(nullptr, last_seq, CEPH_MSG_PRIO_HIGH);
submit_mutex.lock();
}
}
@@ -642,7 +684,7 @@ void MDLog::trim()
max_ev = events_per_segment + 1;
}
- submit_mutex.lock();
+ std::unique_lock locker{submit_mutex};
// trim!
dout(10) << "trim "
@@ -653,7 +695,6 @@ void MDLog::trim()
<< dendl;
if (segments.empty()) {
- submit_mutex.unlock();
return;
}
@@ -723,22 +764,23 @@ void MDLog::trim()
new_expiring_segments++;
expiring_segments.insert(ls);
expiring_events += ls->num_events;
- submit_mutex.unlock();
+ locker.unlock();
uint64_t last_seq = ls->seq;
try_expire(ls, op_prio);
log_trim_counter.hit();
trim_end = ceph::coarse_mono_clock::now();
- submit_mutex.lock();
+ locker.lock();
p = segments.lower_bound(last_seq + 1);
}
}
+ ceph_assert(locker.owns_lock());
+
try_to_commit_open_file_table(get_last_segment_seq());
- // discard expired segments and unlock submit_mutex
- _trim_expired_segments();
+ _trim_expired_segments(locker);
}
class C_MaybeExpiredSegment : public MDSInternalContext {
@@ -760,17 +802,18 @@ class C_MaybeExpiredSegment : public MDSInternalContext {
* Like MDLog::trim, but instead of trimming to max_segments, trim all but the latest
* segment.
*/
-int MDLog::trim_all()
+int MDLog::trim_to(SegmentBoundary::seq_t seq)
{
- submit_mutex.lock();
+ std::unique_lock locker(submit_mutex);
dout(10) << __func__ << ": "
- << segments.size()
+ << seq
+ << " " << segments.size()
<< "/" << expiring_segments.size()
<< "/" << expired_segments.size() << dendl;
- uint64_t last_seq = 0;
- if (!segments.empty()) {
+ uint64_t last_seq = seq;
+ if (last_seq == 0 || !segments.empty()) {
last_seq = get_last_segment_seq();
try_to_commit_open_file_table(last_seq);
}
@@ -785,7 +828,7 @@ int MDLog::trim_all()
// Caller should have flushed journaler before calling this
if (pending_events.count(ls->seq)) {
dout(5) << __func__ << ": " << *ls << " has pending events" << dendl;
- submit_mutex.unlock();
+ locker.unlock();
return -CEPHFS_EAGAIN;
}
@@ -797,17 +840,17 @@ int MDLog::trim_all()
ceph_assert(expiring_segments.count(ls) == 0);
expiring_segments.insert(ls);
expiring_events += ls->num_events;
- submit_mutex.unlock();
+ locker.unlock();
uint64_t next_seq = ls->seq + 1;
try_expire(ls, CEPH_MSG_PRIO_DEFAULT);
- submit_mutex.lock();
+ locker.lock();
p = segments.lower_bound(next_seq);
}
}
- _trim_expired_segments();
+ _trim_expired_segments(locker);
return 0;
}
@@ -848,14 +891,12 @@ void MDLog::_maybe_expired(LogSegment *ls, int op_prio)
try_expire(ls, op_prio);
}
-void MDLog::_trim_expired_segments()
+void MDLog::_trim_expired_segments(auto& locker, MDSContext* ctx)
{
ceph_assert(ceph_mutex_is_locked_by_me(submit_mutex));
-
- uint64_t const oft_committed_seq = mds->mdcache->open_file_table.get_committed_log_seq();
+ ceph_assert(locker.owns_lock());
// trim expired segments?
- bool trimmed = false;
uint64_t end = 0;
for (auto it = segments.begin(); it != segments.end(); ++it) {
auto& [seq, ls] = *it;
@@ -891,7 +932,6 @@ void MDLog::_trim_expired_segments()
} else {
logger->set(l_mdl_expos, jexpire_pos);
}
- trimmed = true;
}
if (!expired_segments.count(ls)) {
@@ -899,26 +939,13 @@ void MDLog::_trim_expired_segments()
break;
}
- if (!mds_is_shutting_down && ls->seq >= oft_committed_seq) {
- dout(10) << __func__ << " defer expire for open file table committedseq " << oft_committed_seq
- << " <= " << ls->seq << "/" << ls->offset << dendl;
- break;
- }
-
end = seq;
dout(10) << __func__ << ": maybe expiring " << *ls << dendl;
}
- submit_mutex.unlock();
+ locker.unlock();
- if (trimmed)
- journaler->write_head(0);
-}
-
-void MDLog::trim_expired_segments()
-{
- submit_mutex.lock();
- _trim_expired_segments();
+ write_head(ctx);
}
void MDLog::_expired(LogSegment *ls)
diff --git a/src/mds/MDLog.h b/src/mds/MDLog.h
index 33eba835c40..e2ab4e686cd 100644
--- a/src/mds/MDLog.h
+++ b/src/mds/MDLog.h
@@ -133,6 +133,8 @@ public:
void kick_submitter();
void shutdown();
+ void finish_head_waiters();
+
void submit_entry(LogEvent *e, MDSLogContextBase* c = 0) {
std::lock_guard l(submit_mutex);
_submit_entry(e, c);
@@ -146,8 +148,14 @@ public:
return unflushed == 0;
}
- void trim_expired_segments();
- int trim_all();
+ void trim_expired_segments(MDSContext* ctx=nullptr) {
+ std::unique_lock locker(submit_mutex);
+ _trim_expired_segments(locker, ctx);
+ }
+ int trim_all() {
+ return trim_to(0);
+ }
+ int trim_to(SegmentBoundary::seq_t);
void create(MDSContext *onfinish); // fresh, empty log!
void open(MDSContext *onopen); // append() or replay() to follow!
@@ -285,7 +293,7 @@ private:
void try_expire(LogSegment *ls, int op_prio);
void _maybe_expired(LogSegment *ls, int op_prio);
void _expired(LogSegment *ls);
- void _trim_expired_segments();
+ void _trim_expired_segments(auto& locker, MDSContext* ctx=nullptr);
void write_head(MDSContext *onfinish);
void trim();
@@ -314,5 +322,7 @@ private:
// guarded by mds_lock
std::condition_variable_any cond;
std::atomic<bool> upkeep_log_trim_shutdown{false};
+
+ std::map<uint64_t, std::vector<Context*>> waiting_for_expire; // protected by mds_lock
};
#endif
diff --git a/src/mds/MDSContext.cc b/src/mds/MDSContext.cc
index 210c836b1fc..635e33f2d89 100644
--- a/src/mds/MDSContext.cc
+++ b/src/mds/MDSContext.cc
@@ -137,9 +137,11 @@ void MDSIOContextWrapper::finish(int r)
void C_IO_Wrapper::complete(int r)
{
if (async) {
+ dout(20) << "C_IO_Wrapper::complete " << r << " async" << dendl;
async = false;
get_mds()->finisher->queue(this, r);
} else {
+ dout(20) << "C_IO_Wrapper::complete " << r << " sync" << dendl;
MDSIOContext::complete(r);
}
}
diff --git a/src/mds/MDSRank.cc b/src/mds/MDSRank.cc
index 50c7175df80..c2f3544f97b 100644
--- a/src/mds/MDSRank.cc
+++ b/src/mds/MDSRank.cc
@@ -71,7 +71,7 @@ public:
}
void send() {
- ceph_assert(ceph_mutex_is_locked(mds->mds_lock));
+ ceph_assert(ceph_mutex_is_locked_by_me(mds->mds_lock));
dout(20) << __func__ << dendl;
@@ -97,11 +97,12 @@ private:
// I need to seal off the current segment, and then mark all
// previous segments for expiry
- auto sle = mdcache->create_subtree_map();
+ auto* sle = mdcache->create_subtree_map();
mdlog->submit_entry(sle);
+ seq = sle->get_seq();
Context *ctx = new LambdaContext([this](int r) {
- handle_flush_mdlog(r);
+ handle_clear_mdlog(r);
});
// Flush initially so that all the segments older than our new one
@@ -110,34 +111,8 @@ private:
mdlog->wait_for_safe(new MDSInternalContextWrapper(mds, ctx));
}
- void handle_flush_mdlog(int r) {
- dout(20) << __func__ << ": r=" << r << dendl;
-
- if (r != 0) {
- *ss << "Error " << r << " (" << cpp_strerror(r) << ") while flushing journal";
- complete(r);
- return;
- }
-
- clear_mdlog();
- }
-
- void clear_mdlog() {
- dout(20) << __func__ << dendl;
-
- Context *ctx = new LambdaContext([this](int r) {
- handle_clear_mdlog(r);
- });
-
- // Because we may not be the last wait_for_safe context on MDLog,
- // and subsequent contexts might wake up in the middle of our
- // later trim_all and interfere with expiry (by e.g. marking
- // dirs/dentries dirty on previous log segments), we run a second
- // wait_for_safe here. See #10368
- mdlog->wait_for_safe(new MDSInternalContextWrapper(mds, ctx));
- }
-
void handle_clear_mdlog(int r) {
+ ceph_assert(ceph_mutex_is_locked_by_me(mds->mds_lock));
dout(20) << __func__ << ": r=" << r << dendl;
if (r != 0) {
@@ -153,7 +128,7 @@ private:
// Put all the old log segments into expiring or expired state
dout(5) << __func__ << ": beginning segment expiry" << dendl;
- int ret = mdlog->trim_all();
+ int ret = mdlog->trim_to(seq);
if (ret != 0) {
*ss << "Error " << ret << " (" << cpp_strerror(ret) << ") while trimming log";
complete(ret);
@@ -177,60 +152,38 @@ private:
<< " segments to expire" << dendl;
if (!expiry_gather.has_subs()) {
- trim_segments();
+ trim_expired_segments();
return;
}
- Context *ctx = new LambdaContext([this](int r) {
- handle_expire_segments(r);
- });
+ /* Because this context may be finished with the MDLog::submit_mutex held,
+ * complete it in the MDS finisher thread.
+ */
+ Context *ctx = new C_OnFinisher(new LambdaContext([this,mds=mds](int r) {
+ ceph_assert(r == 0); // MDLog is not allowed to raise errors via
+ // wait_for_expiry
+ std::lock_guard locker(mds->mds_lock);
+ trim_expired_segments();
+ }), mds->finisher);
expiry_gather.set_finisher(new MDSInternalContextWrapper(mds, ctx));
expiry_gather.activate();
}
- void handle_expire_segments(int r) {
- dout(20) << __func__ << ": r=" << r << dendl;
-
- ceph_assert(r == 0); // MDLog is not allowed to raise errors via
- // wait_for_expiry
- trim_segments();
- }
-
- void trim_segments() {
- dout(20) << __func__ << dendl;
-
- Context *ctx = new C_OnFinisher(new LambdaContext([this](int) {
- std::lock_guard locker(mds->mds_lock);
- trim_expired_segments();
- }), mds->finisher);
- ctx->complete(0);
- }
-
void trim_expired_segments() {
+ ceph_assert(ceph_mutex_is_locked_by_me(mds->mds_lock));
dout(5) << __func__ << ": expiry complete, expire_pos/trim_pos is now "
<< std::hex << mdlog->get_journaler()->get_expire_pos() << "/"
<< mdlog->get_journaler()->get_trimmed_pos() << dendl;
// Now everyone I'm interested in is expired
- mdlog->trim_expired_segments();
+ auto* ctx = new MDSInternalContextWrapper(mds, new LambdaContext([this](int r) {
+ handle_write_head(r);
+ }));
+ mdlog->trim_expired_segments(ctx);
- dout(5) << __func__ << ": trim complete, expire_pos/trim_pos is now "
+ dout(5) << __func__ << ": trimming is complete; wait for journal head write. Journal expire_pos/trim_pos is now "
<< std::hex << mdlog->get_journaler()->get_expire_pos() << "/"
<< mdlog->get_journaler()->get_trimmed_pos() << dendl;
-
- write_journal_head();
- }
-
- void write_journal_head() {
- dout(20) << __func__ << dendl;
-
- Context *ctx = new LambdaContext([this](int r) {
- std::lock_guard locker(mds->mds_lock);
- handle_write_head(r);
- });
- // Flush the journal header so that readers will start from after
- // the flushed region
- mdlog->get_journaler()->write_head(ctx);
}
void handle_write_head(int r) {
@@ -244,12 +197,17 @@ private:
}
void finish(int r) override {
+ /* We don't need the mds_lock but MDLog::write_head takes an MDSContext so
+ * we are expected to have it.
+ */
+ ceph_assert(ceph_mutex_is_locked_by_me(mds->mds_lock));
dout(20) << __func__ << ": r=" << r << dendl;
on_finish->complete(r);
}
MDCache *mdcache;
MDLog *mdlog;
+ SegmentBoundary::seq_t seq = 0;
std::ostream *ss;
Context *on_finish;
@@ -3149,7 +3107,7 @@ void MDSRankDispatcher::evict_clients(
dout(20) << __func__ << " matched " << victims.size() << " sessions" << dendl;
if (victims.empty()) {
- on_finish(-ESRCH, "no hosts match", outbl);
+ on_finish(0, "no hosts match", outbl);
return;
}
diff --git a/src/mds/OpenFileTable.cc b/src/mds/OpenFileTable.cc
index 4322b6a8a7d..811c6aff8ad 100644
--- a/src/mds/OpenFileTable.cc
+++ b/src/mds/OpenFileTable.cc
@@ -283,6 +283,14 @@ void OpenFileTable::_commit_finish(int r, uint64_t log_seq, MDSContext *fin)
committed_log_seq = log_seq;
num_pending_commit--;
+ {
+ auto last = waiting_for_commit.upper_bound(log_seq);
+ for (auto it = waiting_for_commit.begin(); it != last; it++) {
+ finish_contexts(g_ceph_context, it->second);
+ }
+ waiting_for_commit.erase(waiting_for_commit.begin(), last);
+ }
+
if (fin)
fin->complete(r);
}
diff --git a/src/mds/OpenFileTable.h b/src/mds/OpenFileTable.h
index b18395213f5..a1b62012f79 100644
--- a/src/mds/OpenFileTable.h
+++ b/src/mds/OpenFileTable.h
@@ -50,6 +50,9 @@ public:
ceph_assert(!load_done);
waiting_for_load.push_back(c);
}
+ void wait_for_commit(uint64_t seq, Context* c) {
+ waiting_for_commit[seq].push_back(c);
+ }
bool prefetch_inodes();
bool is_prefetched() const { return prefetch_state == DONE; }
@@ -149,6 +152,8 @@ protected:
std::set<inodeno_t> destroyed_inos_set;
std::unique_ptr<PerfCounters> logger;
+
+ std::map<uint64_t, std::vector<Context*>> waiting_for_commit;
};
#endif
diff --git a/src/mds/PurgeQueue.cc b/src/mds/PurgeQueue.cc
index 639c7e85277..925bff16542 100644
--- a/src/mds/PurgeQueue.cc
+++ b/src/mds/PurgeQueue.cc
@@ -99,6 +99,17 @@ void PurgeItem::decode(bufferlist::const_iterator &p)
DECODE_FINISH(p);
}
+void PurgeItem::generate_test_instances(std::list<PurgeItem*>& ls) {
+ ls.push_back(new PurgeItem());
+ ls.push_back(new PurgeItem());
+ ls.back()->action = PurgeItem::PURGE_FILE;
+ ls.back()->ino = 1;
+ ls.back()->size = 2;
+ ls.back()->layout = file_layout_t();
+ ls.back()->old_pools = {1, 2};
+ ls.back()->snapc = SnapContext();
+ ls.back()->stamp = utime_t(3, 4);
+}
// if Objecter has any slow requests, take that as a hint and
// slow down our rate of purging
PurgeQueue::PurgeQueue(
@@ -225,9 +236,10 @@ void PurgeQueue::open(Context *completion)
// Journaler only guarantees entries before head write_pos have been
// fully flushed. Before appending new entries, we need to find and
// drop any partial written entry.
- if (journaler.last_committed.write_pos < journaler.get_write_pos()) {
+ auto&& last_committed = journaler.get_last_committed();
+ if (last_committed.write_pos < journaler.get_write_pos()) {
dout(4) << "recovering write_pos" << dendl;
- journaler.set_read_pos(journaler.last_committed.write_pos);
+ journaler.set_read_pos(last_committed.write_pos);
_recover();
return;
}
@@ -281,7 +293,8 @@ void PurgeQueue::_recover()
if (journaler.get_read_pos() == journaler.get_write_pos()) {
dout(4) << "write_pos recovered" << dendl;
// restore original read_pos
- journaler.set_read_pos(journaler.last_committed.expire_pos);
+ auto&& last_committed = journaler.get_last_committed();
+ journaler.set_read_pos(last_committed.expire_pos);
journaler.set_writeable();
recovered = true;
finish_contexts(g_ceph_context, waiting_for_recovery);
diff --git a/src/mds/PurgeQueue.h b/src/mds/PurgeQueue.h
index 7bc101e31c4..bbf260ae70d 100644
--- a/src/mds/PurgeQueue.h
+++ b/src/mds/PurgeQueue.h
@@ -61,6 +61,7 @@ public:
fragtree.dump(f);
f->close_section();
}
+ static void generate_test_instances(std::list<PurgeItem*>& ls);
std::string_view get_type_str() const;
diff --git a/src/mds/SessionMap.h b/src/mds/SessionMap.h
index 623f20a0eb7..9e82f00a9bf 100644
--- a/src/mds/SessionMap.h
+++ b/src/mds/SessionMap.h
@@ -574,7 +574,6 @@ public:
}
static void generate_test_instances(std::list<SessionMapStore*>& ls);
-
void reset_state()
{
session_map.clear();
diff --git a/src/mds/SimpleLock.cc b/src/mds/SimpleLock.cc
index da266e30dab..df61384a3ca 100644
--- a/src/mds/SimpleLock.cc
+++ b/src/mds/SimpleLock.cc
@@ -43,6 +43,13 @@ void SimpleLock::dump(ceph::Formatter *f) const {
f->close_section();
}
+void SimpleLock::generate_test_instances(std::list<SimpleLock*>& ls) {
+ ls.push_back(new SimpleLock);
+ ls.push_back(new SimpleLock);
+ ls.back()->set_state(LOCK_SYNC);
+}
+
+
int SimpleLock::get_wait_shift() const {
switch (get_type()) {
case CEPH_LOCK_DN: return 0;
diff --git a/src/mds/SimpleLock.h b/src/mds/SimpleLock.h
index 6f1d049ea0a..55621549a8f 100644
--- a/src/mds/SimpleLock.h
+++ b/src/mds/SimpleLock.h
@@ -175,6 +175,12 @@ public:
}
}
+ //for dencoder only
+ SimpleLock() :
+ type(nullptr),
+ parent(nullptr)
+ {}
+
SimpleLock(MDSCacheObject *o, const LockType *lt) :
type(lt),
parent(o)
@@ -199,8 +205,8 @@ public:
// parent
MDSCacheObject *get_parent() { return parent; }
- int get_type() const { return type->type; }
- const sm_t* get_sm() const { return type->sm; }
+ int get_type() const { return (type != nullptr) ? type->type : 0; }
+ const sm_t* get_sm() const { return (type != nullptr) ? type->sm : nullptr; }
int get_cap_shift() const;
int get_cap_mask() const;
@@ -493,6 +499,7 @@ public:
encode(empty_gather_set, bl);
ENCODE_FINISH(bl);
}
+
void decode(ceph::buffer::list::const_iterator& p) {
DECODE_START(2, p);
decode(state, p);
@@ -588,6 +595,7 @@ public:
* to formatter, or nothing if is_sync_and_unlocked.
*/
void dump(ceph::Formatter *f) const;
+ static void generate_test_instances(std::list<SimpleLock*>& ls);
virtual void print(std::ostream& out) const {
out << "(";
diff --git a/src/mds/flock.cc b/src/mds/flock.cc
index 69d579d3034..c126b0f0898 100644
--- a/src/mds/flock.cc
+++ b/src/mds/flock.cc
@@ -37,6 +37,50 @@ ceph_lock_state_t::~ceph_lock_state_t()
}
}
+void ceph_lock_state_t::dump(ceph::Formatter *f) const {
+ f->dump_int("type", type);
+ f->dump_int("held_locks", held_locks.size());
+ for (auto &p : held_locks) {
+ f->open_object_section("lock");
+ f->dump_int("start", p.second.start);
+ f->dump_int("length", p.second.length);
+ f->dump_int("client", p.second.client);
+ f->dump_int("owner", p.second.owner);
+ f->dump_int("pid", p.second.pid);
+ f->dump_int("type", p.second.type);
+ f->close_section();
+ }
+ f->dump_int("waiting_locks", waiting_locks.size());
+ for (auto &p : waiting_locks) {
+ f->open_object_section("lock");
+ f->dump_int("start", p.second.start);
+ f->dump_int("length", p.second.length);
+ f->dump_int("client", p.second.client);
+ f->dump_int("owner", p.second.owner);
+ f->dump_int("pid", p.second.pid);
+ f->dump_int("type", p.second.type);
+ f->close_section();
+ }
+ f->dump_int("client_held_lock_counts", client_held_lock_counts.size());
+ for (auto &p : client_held_lock_counts) {
+ f->open_object_section("client");
+ f->dump_int("client_id", p.first.v);
+ f->dump_int("count", p.second);
+ f->close_section();
+ }
+ f->dump_int("client_waiting_lock_counts", client_waiting_lock_counts.size());
+}
+
+
+void ceph_lock_state_t::generate_test_instances(std::list<ceph_lock_state_t*>& ls) {
+ ls.push_back(new ceph_lock_state_t(NULL, 0));
+ ls.push_back(new ceph_lock_state_t(NULL, 1));
+ ls.back()->held_locks.insert(std::make_pair(1, ceph_filelock()));
+ ls.back()->waiting_locks.insert(std::make_pair(1, ceph_filelock()));
+ ls.back()->client_held_lock_counts.insert(std::make_pair(1, 1));
+ ls.back()->client_waiting_lock_counts.insert(std::make_pair(1, 1));
+}
+
bool ceph_lock_state_t::is_waiting(const ceph_filelock &fl) const
{
auto p = waiting_locks.find(fl.start);
diff --git a/src/mds/flock.h b/src/mds/flock.h
index 915d912e1ee..6871f2decc5 100644
--- a/src/mds/flock.h
+++ b/src/mds/flock.h
@@ -71,6 +71,7 @@ inline bool operator!=(const ceph_filelock& l, const ceph_filelock& r) {
class ceph_lock_state_t {
public:
explicit ceph_lock_state_t(CephContext *cct_, int type_) : cct(cct_), type(type_) {}
+ ceph_lock_state_t() : cct(NULL), type(0) {}
~ceph_lock_state_t();
/**
* Check if a lock is on the waiting_locks list.
@@ -132,6 +133,8 @@ public:
decode(held_locks, bl);
decode(client_held_lock_counts, bl);
}
+ void dump(ceph::Formatter *f) const;
+ static void generate_test_instances(std::list<ceph_lock_state_t*>& ls);
bool empty() const {
return held_locks.empty() && waiting_locks.empty() &&
client_held_lock_counts.empty() &&
diff --git a/src/mds/journal.cc b/src/mds/journal.cc
index 40400ff4054..b7fc058692a 100644
--- a/src/mds/journal.cc
+++ b/src/mds/journal.cc
@@ -235,6 +235,14 @@ void LogSegment::try_to_expire(MDSRank *mds, MDSGatherBuilder &gather_bld, int o
}
}
+ auto const oft_cseq = mds->mdcache->open_file_table.get_committed_log_seq();
+ if (!mds->mdlog->is_capped() && seq >= oft_cseq) {
+ dout(10) << *this << ".try_to_expire"
+ << " defer expire for oft_committed_seq (" << oft_cseq
+ << ") <= seq (" << seq << ")" << dendl;
+ mds->mdcache->open_file_table.wait_for_commit(seq, gather_bld.new_sub());
+ }
+
ceph_assert(g_conf()->mds_kill_journal_expire_at != 3);
std::map<int64_t, std::vector<CInodeCommitOperations>> ops_vec_map;
@@ -346,9 +354,10 @@ void LogSegment::try_to_expire(MDSRank *mds, MDSGatherBuilder &gather_bld, int o
(*p)->add_waiter(CInode::WAIT_TRUNC, gather_bld.new_sub());
}
// purge inodes
- dout(10) << "try_to_expire waiting for purge of " << purging_inodes << dendl;
- if (purging_inodes.size())
+ if (purging_inodes.size()) {
+ dout(10) << "try_to_expire waiting for purge of " << purging_inodes << dendl;
set_purged_cb(gather_bld.new_sub());
+ }
if (gather_bld.has_subs()) {
dout(6) << "LogSegment(" << seq << "/" << offset << ").try_to_expire waiting" << dendl;
diff --git a/src/mds/mdstypes.cc b/src/mds/mdstypes.cc
index fce09baef81..680218e62e3 100644
--- a/src/mds/mdstypes.cc
+++ b/src/mds/mdstypes.cc
@@ -528,6 +528,15 @@ void feature_bitset_t::dump(Formatter *f) const {
f->dump_string("feature_bits", css->strv());
}
+void feature_bitset_t::generate_test_instances(std::list<feature_bitset_t*>& ls)
+{
+ ls.push_back(new feature_bitset_t());
+ ls.push_back(new feature_bitset_t());
+ ls.back()->_vec.push_back(1);
+ ls.back()->_vec.push_back(2);
+ ls.back()->_vec.push_back(3);
+}
+
void feature_bitset_t::print(ostream& out) const
{
std::ios_base::fmtflags f(out.flags());
@@ -564,6 +573,13 @@ void metric_spec_t::dump(Formatter *f) const {
f->dump_object("metric_flags", metric_flags);
}
+void metric_spec_t::generate_test_instances(std::list<metric_spec_t*>& ls)
+{
+ ls.push_back(new metric_spec_t());
+ ls.push_back(new metric_spec_t());
+ ls.back()->metric_flags = 1;
+}
+
void metric_spec_t::print(ostream& out) const
{
out << "{metric_flags: '" << metric_flags << "'}";
@@ -601,6 +617,16 @@ void client_metadata_t::dump(Formatter *f) const
f->dump_string(name.c_str(), val);
}
+void client_metadata_t::generate_test_instances(std::list<client_metadata_t*>& ls)
+{
+ ls.push_back(new client_metadata_t());
+ ls.push_back(new client_metadata_t());
+ ls.back()->kv_map["key1"] = "val1";
+ ls.back()->kv_map["key2"] = "val2";
+ ls.back()->features = 0x12345678;
+ ls.back()->metric_spec.metric_flags = 0x12345678;
+}
+
/*
* session_info_t
*/
diff --git a/src/mds/mdstypes.h b/src/mds/mdstypes.h
index 17a5bf7acae..3b8269006cb 100644
--- a/src/mds/mdstypes.h
+++ b/src/mds/mdstypes.h
@@ -349,6 +349,7 @@ public:
void decode(ceph::buffer::list::const_iterator &p);
void dump(ceph::Formatter *f) const;
void print(std::ostream& out) const;
+ static void generate_test_instances(std::list<feature_bitset_t*>& ls);
private:
void init_array(const std::vector<size_t>& v);
@@ -387,6 +388,7 @@ struct metric_spec_t {
void encode(ceph::buffer::list& bl) const;
void decode(ceph::buffer::list::const_iterator& p);
void dump(ceph::Formatter *f) const;
+ static void generate_test_instances(std::list<metric_spec_t*>& ls);
void print(std::ostream& out) const;
// set of metrics that a client is capable of forwarding
@@ -433,6 +435,7 @@ struct client_metadata_t {
void encode(ceph::buffer::list& bl) const;
void decode(ceph::buffer::list::const_iterator& p);
void dump(ceph::Formatter *f) const;
+ static void generate_test_instances(std::list<client_metadata_t*>& ls);
kv_map_t kv_map;
feature_bitset_t features;
@@ -634,7 +637,10 @@ struct metareqid_t {
void print(std::ostream& out) const {
out << name << ":" << tid;
}
-
+ static void generate_test_instances(std::list<metareqid_t*>& ls) {
+ ls.push_back(new metareqid_t);
+ ls.push_back(new metareqid_t(entity_name_t::CLIENT(123), 456));
+ }
entity_name_t name;
uint64_t tid = 0;
};
@@ -786,6 +792,15 @@ struct dirfrag_t {
decode(ino, bl);
decode(frag, bl);
}
+ void dump(ceph::Formatter *f) const {
+ f->dump_unsigned("ino", ino);
+ f->dump_unsigned("frag", frag);
+ }
+ static void generate_test_instances(std::list<dirfrag_t*>& ls) {
+ ls.push_back(new dirfrag_t);
+ ls.push_back(new dirfrag_t(1, frag_t()));
+ ls.push_back(new dirfrag_t(2, frag_t(3)));
+ }
inodeno_t ino = 0;
frag_t frag;