From 6b126a6919e21e160808b777646b3de07296e7a8 Mon Sep 17 00:00:00 2001 From: "Yan, Zheng" Date: Fri, 17 Nov 2017 09:22:04 +0800 Subject: [PATCH] mds: adjust subtree popularity when import fails Signed-off-by: "Yan, Zheng" --- src/common/DecayCounter.h | 4 +++- src/mds/CDir.cc | 13 +++++++++++++ src/mds/CDir.h | 1 + src/mds/Migrator.cc | 10 +++------- 4 files changed, 20 insertions(+), 8 deletions(-) diff --git a/src/common/DecayCounter.h b/src/common/DecayCounter.h index e45aed8d2f2a5..620db834f1fe9 100644 --- a/src/common/DecayCounter.h +++ b/src/common/DecayCounter.h @@ -115,10 +115,12 @@ public: void adjust(double a) { val += a; + if (val < 0) + val = 0; } void adjust(utime_t now, const DecayRate& rate, double a) { decay(now, rate); - val += a; + adjust(a); } void scale(double f) { val *= f; diff --git a/src/mds/CDir.cc b/src/mds/CDir.cc index 4e9ba084c96ba..48b10c8c4bbe9 100644 --- a/src/mds/CDir.cc +++ b/src/mds/CDir.cc @@ -2562,7 +2562,20 @@ void CDir::decode_import(bufferlist::iterator& blp, utime_t now, LogSegment *ls) } } +void CDir::abort_import(utime_t now) +{ + assert(is_auth()); + state_clear(CDir::STATE_AUTH); + remove_bloom(); + clear_replica_map(); + set_replica_nonce(CDir::EXPORT_NONCE); + if (is_dirty()) + mark_clean(); + pop_auth_subtree_nested.sub(now, cache->decayrate, pop_auth_subtree); + pop_me.zero(now); + pop_auth_subtree.zero(now); +} /******************************** diff --git a/src/mds/CDir.h b/src/mds/CDir.h index fab780d2fd4f0..472845042fcb2 100644 --- a/src/mds/CDir.h +++ b/src/mds/CDir.h @@ -703,6 +703,7 @@ public: put(PIN_TEMPEXPORTING); } void decode_import(bufferlist::iterator& blp, utime_t now, LogSegment *ls); + void abort_import(utime_t now); // -- auth pins -- bool can_auth_pin() const override { return is_auth() && !(is_frozen() || is_freezing()); } diff --git a/src/mds/Migrator.cc b/src/mds/Migrator.cc index 1bd52948ae511..2ed79d2124f4d 100644 --- a/src/mds/Migrator.cc +++ b/src/mds/Migrator.cc @@ -2600,6 +2600,8 @@ void Migrator::import_reverse(CDir *dir) import_state_t& stat = import_state[dir->dirfrag()]; stat.state = IMPORT_ABORTING; + utime_t now = ceph_clock_now(); + set bounds; cache->get_subtree_bounds(dir, bounds); @@ -2630,13 +2632,7 @@ void Migrator::import_reverse(CDir *dir) q.pop_front(); // dir - assert(cur->is_auth()); - cur->state_clear(CDir::STATE_AUTH); - cur->remove_bloom(); - cur->clear_replica_map(); - cur->set_replica_nonce(CDir::EXPORT_NONCE); - if (cur->is_dirty()) - cur->mark_clean(); + cur->abort_import(now); for (auto &p : *cur) { CDentry *dn = p.second; -- 2.39.5