From: Yan, Zheng Date: Mon, 20 Mar 2017 08:27:45 +0000 (+0800) Subject: mds: handle target mds failure when stopping mds exports strays X-Git-Tag: v12.0.2~112^2~5 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=8c5100c2a37957f6b18c68cb20f95704d4be917d;p=ceph.git mds: handle target mds failure when stopping mds exports strays Signed-off-by: "Yan, Zheng" --- diff --git a/src/mds/MDCache.cc b/src/mds/MDCache.cc index 1a2e199bc008..03b40c3701d5 100644 --- a/src/mds/MDCache.cc +++ b/src/mds/MDCache.cc @@ -2998,6 +2998,10 @@ void MDCache::handle_mds_failure(mds_rank_t who) fragment_unmark_unfreeze_dirs(dirs); } + // MDCache::shutdown_export_strays() always exports strays to mds.0 + if (who == mds_rank_t(0)) + shutdown_exported_strays.clear(); + show_subtrees(); } @@ -7592,12 +7596,14 @@ bool MDCache::shutdown_pass() bool MDCache::shutdown_export_strays() { - if (mds->get_nodeid() == 0) return true; + if (mds->get_nodeid() == 0) + return true; dout(10) << "shutdown_export_strays" << dendl; + bool mds0_active = mds->mdsmap->is_active(mds_rank_t(0)); + bool done = true; - static set exported_strays; list dfs; for (int i = 0; i < NUM_STRAY; ++i) { @@ -7615,6 +7621,8 @@ bool MDCache::shutdown_export_strays() if (!dir->is_complete()) { dir->fetch(0); done = false; + if (!mds0_active) + break; } for (CDir::map_t::iterator p = dir->items.begin(); @@ -7622,8 +7630,11 @@ bool MDCache::shutdown_export_strays() ++p) { CDentry *dn = p->second; CDentry::linkage_t *dnl = dn->get_linkage(); - if (dnl->is_null()) continue; + if (dnl->is_null()) + continue; done = false; + if (!mds0_active) + break; if (dn->state_test(CDentry::STATE_PURGING)) { // Don't try to migrate anything that is actually @@ -7631,9 +7642,8 @@ bool MDCache::shutdown_export_strays() continue; } - // FIXME: we'll deadlock if a rename fails. - if (exported_strays.count(dnl->get_inode()->ino()) == 0) { - exported_strays.insert(dnl->get_inode()->ino()); + if (shutdown_exported_strays.count(dnl->get_inode()->ino()) == 0) { + shutdown_exported_strays.insert(dnl->get_inode()->ino()); stray_manager.migrate_stray(dn, mds_rank_t(0)); // send to root! } else { dout(10) << "already exporting " << *dn << dendl; diff --git a/src/mds/MDCache.h b/src/mds/MDCache.h index a1ef2283948e..27f12bbb08c8 100644 --- a/src/mds/MDCache.h +++ b/src/mds/MDCache.h @@ -702,6 +702,9 @@ public: utime_t last_recall_state; // shutdown +private: + set shutdown_exported_strays; +public: void shutdown_start(); void shutdown_check(); bool shutdown_pass();