From ed69a3277dee3db71cb2be9910fa1113d449fb58 Mon Sep 17 00:00:00 2001 From: "Yan, Zheng" Date: Mon, 6 Feb 2017 17:15:40 +0800 Subject: [PATCH] mds: cleanup ambiguous slave update when master mds fails When auth mds of rename source dentry fails, slave updates in witness mds become ambiguous. Witnesses need to ask the master if they should rollback the updates. This type of rollback is special, corresponding MDRequest struct need to be preserved after rollback. If the master mds also fails, slave updates in witness mds are no longer special. Corresponding MDRequest struct need to be cleanup after rollback. see commit e62e48bb for more information. Signed-off-by: "Yan, Zheng" --- src/mds/MDCache.cc | 3 +++ src/mds/MDCache.h | 14 ++++++++------ 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/src/mds/MDCache.cc b/src/mds/MDCache.cc index 3884415a7d3..c5936dd65d8 100644 --- a/src/mds/MDCache.cc +++ b/src/mds/MDCache.cc @@ -2890,6 +2890,9 @@ void MDCache::handle_mds_failure(mds_rank_t who) if (mdr->slave_to_mds == who) { if (mdr->slave_did_prepare()) { dout(10) << " slave request " << *mdr << " uncommitted, will resolve shortly" << dendl; + if (is_ambiguous_slave_update(p->first, mdr->slave_to_mds)) + remove_ambiguous_slave_update(p->first, mdr->slave_to_mds); + if (!mdr->more()->waiting_on_slave.empty()) { assert(mdr->more()->srcdn_auth_mds == mds->get_nodeid()); // will rollback, no need to wait diff --git a/src/mds/MDCache.h b/src/mds/MDCache.h index ab131c79b92..fc3b5fcc557 100644 --- a/src/mds/MDCache.h +++ b/src/mds/MDCache.h @@ -452,17 +452,19 @@ public: void remove_inode_recursive(CInode *in); bool is_ambiguous_slave_update(metareqid_t reqid, mds_rank_t master) { - return ambiguous_slave_updates.count(master) && - ambiguous_slave_updates[master].count(reqid); + auto p = ambiguous_slave_updates.find(master); + return p != ambiguous_slave_updates.end() && p->second.count(reqid); } void add_ambiguous_slave_update(metareqid_t reqid, mds_rank_t master) { ambiguous_slave_updates[master].insert(reqid); } void remove_ambiguous_slave_update(metareqid_t reqid, mds_rank_t master) { - assert(ambiguous_slave_updates[master].count(reqid)); - ambiguous_slave_updates[master].erase(reqid); - if (ambiguous_slave_updates[master].empty()) - ambiguous_slave_updates.erase(master); + auto p = ambiguous_slave_updates.find(master); + auto q = p->second.find(reqid); + assert(q != p->second.end()); + p->second.erase(q); + if (p->second.empty()) + ambiguous_slave_updates.erase(p); } void add_rollback(metareqid_t reqid, mds_rank_t master) { -- 2.47.3