From: Yan, Zheng Date: Tue, 11 Sep 2018 09:04:10 +0000 (+0800) Subject: Revert "mds: adjust export size after renaming directory into freezing subtree" X-Git-Tag: v14.1.0~1090^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=35a2d7a9dfad6707310f4ec1ee6350c08204bd9e;p=ceph.git Revert "mds: adjust export size after renaming directory into freezing subtree" This reverts commit a7076fae36fe085faed2f4a7eeade7cfcd1a2f2e. Previous commit changes the way to freeze subtree. If a directory get renamed into into freezing subtree, the renamed inode's dirfrags do not become freezing. So this commit is no longer needed. Conflicts: src/mds/Migrator.cc src/mds/Migrator.h Signed-off-by: "Yan, Zheng" --- diff --git a/src/mds/CDir.cc b/src/mds/CDir.cc index 8d0307a336d3..3973fd6b432a 100644 --- a/src/mds/CDir.cc +++ b/src/mds/CDir.cc @@ -3053,23 +3053,6 @@ bool CDir::can_auth_pin(int *err_ret) const return !err; } -CDir *CDir::get_freezing_tree_root() -{ - if (num_freezing_trees == 0) - return nullptr; - CDir *dir = this; - while (true) { - if (dir->is_freezing_tree_root()) - return dir; - if (dir->is_subtree_root()) - return nullptr; - if (dir->inode->parent) - dir = dir->inode->parent->dir; - else - return nullptr; - } -} - class C_Dir_AuthUnpin : public CDirContext { public: explicit C_Dir_AuthUnpin(CDir *d) : CDirContext(d) {} diff --git a/src/mds/CDir.h b/src/mds/CDir.h index a4490e062f04..6b03e063b42b 100644 --- a/src/mds/CDir.h +++ b/src/mds/CDir.h @@ -747,7 +747,6 @@ public: } bool is_freezing_tree_root() const { return state & STATE_FREEZINGTREE; } bool is_freezing_dir() const { return state & STATE_FREEZINGDIR; } - CDir *get_freezing_tree_root(); bool is_frozen() const override { return is_frozen_dir() || is_frozen_tree(); } bool is_frozen_tree() const { diff --git a/src/mds/MDSRank.h b/src/mds/MDSRank.h index b5b5579f8eb5..f88ee4caf33f 100644 --- a/src/mds/MDSRank.h +++ b/src/mds/MDSRank.h @@ -309,10 +309,6 @@ class MDSRank { finished_queue.push_back(c); progress_thread.signal(); } - void queue_waiter_front(MDSInternalContextBase *c) { - finished_queue.push_back(c); - progress_thread.signal(); - } void queue_waiters(MDSInternalContextBase::vec& ls) { MDSInternalContextBase::vec v; v.swap(ls); diff --git a/src/mds/Migrator.cc b/src/mds/Migrator.cc index 1b06e344ff79..db82bc3cf1c6 100644 --- a/src/mds/Migrator.cc +++ b/src/mds/Migrator.cc @@ -1105,7 +1105,6 @@ void Migrator::dispatch_export_dir(MDRequestRef& mdr, int count) it->second.last_cum_auth_pins_change = ceph_clock_now(); it->second.approx_size = results.front().second; - it->second.orig_size = it->second.approx_size; total_exporting_size += it->second.approx_size; // start the freeze, but hold it up with an auth_pin. @@ -1156,95 +1155,6 @@ void Migrator::dispatch_export_dir(MDRequestRef& mdr, int count) export_try_cancel(dir); } -void Migrator::restart_export_dir(CDir *dir, uint64_t tid) -{ - auto it = export_state.find(dir); - if (it == export_state.end() || it->second.tid != tid) - return; - if (it->second.state != EXPORT_DISCOVERING && - it->second.state != EXPORT_FREEZING) - return; - - dout(7) << "restart_export_dir " << *dir << dendl; - - std::shared_ptr parent; - parent.swap(it->second.parent); - if (!parent) - export_queue.emplace_front(dir->dirfrag(), it->second.peer); - - export_try_cancel(dir); - - if (parent) - child_export_finish(parent, true); -} - -class C_MDC_RestartExportDir : public MigratorContext { - CDir *dir; - uint64_t tid; -public: - C_MDC_RestartExportDir(Migrator *m, CDir *d, uint64_t t) : - MigratorContext(m), dir(d), tid(t) {} - void finish(int r) override { - mig->restart_export_dir(dir, tid); - } -}; - -bool Migrator::adjust_export_size(export_state_t &stat, CDir *dir) -{ - if (dir->state_test(CDir::STATE_EXPORTING) || - dir->is_freezing_dir() || dir->is_frozen_dir()) - return false; - - if (stat.approx_size >= max_export_size && - stat.approx_size >= stat.orig_size * 2) - return false; - - vector > results; - maybe_split_export(dir, max_export_size, true, results); - if (results.size() == 1 && results.front().first == dir) { - auto size = results.front().second; - stat.approx_size += size; - total_exporting_size += size; - return true; - } - - return false; -} - -void Migrator::adjust_export_after_rename(CInode* diri, CDir *olddir) -{ - CDir *newdir = diri->get_parent_dir(); - if (newdir == olddir) - return; - - CDir *freezing_dir = newdir->get_freezing_tree_root(); - CDir *old_freezing_dir = olddir->get_freezing_tree_root(); - if (!freezing_dir || freezing_dir == old_freezing_dir) - return; - - dout(7) << "adjust_export_after_rename " << *diri << dendl; - - auto &stat = export_state.at(freezing_dir); - ceph_assert(stat.state == EXPORT_DISCOVERING || - stat.state == EXPORT_FREEZING); - - if (g_conf()->mds_thrash_exports) { - if (rand() % 3 == 0) { - mds->queue_waiter_front(new C_MDC_RestartExportDir(this, freezing_dir, stat.tid)); - return; - } - } - - vector ls; - diri->get_nested_dirfrags(ls); - for (auto d : ls) { - if (!adjust_export_size(stat, d)) { - mds->queue_waiter_front(new C_MDC_RestartExportDir(this, freezing_dir, stat.tid)); - return; - } - } -} - void Migrator::child_export_finish(std::shared_ptr& parent, bool success) { if (success) diff --git a/src/mds/Migrator.h b/src/mds/Migrator.h index de1638d776a5..6a0095a802d0 100644 --- a/src/mds/Migrator.h +++ b/src/mds/Migrator.h @@ -130,7 +130,6 @@ protected: map > peer_imported; MutationRef mut; size_t approx_size = 0; - size_t orig_size = 0; // for freeze tree deadlock detection utime_t last_cum_auth_pins_change; int last_cum_auth_pins = 0; @@ -319,9 +318,6 @@ public: void maybe_split_export(CDir* dir, uint64_t max_size, bool null_okay, vector >& results); - void restart_export_dir(CDir *dir, uint64_t tid); - bool adjust_export_size(export_state_t &stat, CDir *dir); - void adjust_export_after_rename(CInode* diri, CDir *olddir); void child_export_finish(std::shared_ptr& parent, bool success); void get_export_lock_set(CDir *dir, MutationImpl::LockOpVec& lov); diff --git a/src/mds/Server.cc b/src/mds/Server.cc index f88724d252e8..ba2508d119d5 100644 --- a/src/mds/Server.cc +++ b/src/mds/Server.cc @@ -8122,13 +8122,9 @@ void Server::_rename_apply(MDRequestRef& mdr, CDentry *srcdn, CDentry *destdn, C mdr->apply(); // update subtree map? - if (destdnl->is_primary() && in->is_dir()) { + if (destdnl->is_primary() && in->is_dir()) mdcache->adjust_subtree_after_rename(in, srcdn->get_dir(), true); - if (destdn->is_auth()) - mdcache->migrator->adjust_export_after_rename(in, srcdn->get_dir()); - } - if (straydn && oldin->is_dir()) mdcache->adjust_subtree_after_rename(oldin, destdn->get_dir(), true);