From: Samuel Just Date: Sat, 7 Dec 2019 00:37:27 +0000 (-0800) Subject: PrimaryLogPG: drop replica obc cache upon repop X-Git-Tag: v15.1.0~411^2~2 X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=671c763af35eaed1b8dae824a0b07e44dc5a8aa0;p=ceph.git PrimaryLogPG: drop replica obc cache upon repop Signed-off-by: Samuel Just --- diff --git a/src/common/shared_cache.hpp b/src/common/shared_cache.hpp index b8623d9de09e3..5b860fad729b5 100644 --- a/src/common/shared_cache.hpp +++ b/src/common/shared_cache.hpp @@ -172,6 +172,23 @@ public: } } + /* Clears weakrefs in the interval [from, to] -- note that to is inclusive */ + void clear_range( + const K& from, + const K& to) { + list vals; // release any refs we have after we drop the lock + { + std::lock_guard l{lock}; + auto from_iter = weak_refs.lower_bound(from); + auto to_iter = weak_refs.upper_bound(to); + for (auto i = from_iter; i != to_iter; ) { + vals.push_back(i->second.first.lock()); + lru_remove((i++)->first); + } + } + } + + void purge(const K &key) { VPtr val; // release any ref we have after we drop the lock { diff --git a/src/osd/PrimaryLogPG.cc b/src/osd/PrimaryLogPG.cc index 6e77d927851c5..b7ce5dca3a61b 100644 --- a/src/osd/PrimaryLogPG.cc +++ b/src/osd/PrimaryLogPG.cc @@ -491,6 +491,20 @@ void PrimaryLogPG::schedule_recovery_work( osd->queue_recovery_context(this, c); } +void PrimaryLogPG::replica_clear_repop_obc( + const vector &logv, + ObjectStore::Transaction &t) +{ + for (auto &&e: logv) { + /* Have to blast all clones, they share a snapset */ + object_contexts.clear_range( + e.soid.get_object_boundary(), e.soid.get_head()); + ceph_assert( + snapset_contexts.find(e.soid.get_head()) == + snapset_contexts.end()); + } +} + bool PrimaryLogPG::should_send_op( pg_shard_t peer, const hobject_t &hoid) { diff --git a/src/osd/PrimaryLogPG.h b/src/osd/PrimaryLogPG.h index 4ca01b2f61ebe..c8ba20b966014 100644 --- a/src/osd/PrimaryLogPG.h +++ b/src/osd/PrimaryLogPG.h @@ -474,11 +474,18 @@ public: projected_log.skip_can_rollback_to_to_head(); projected_log.trim(cct, last->version, nullptr, nullptr, nullptr); } + if (!is_primary() && !is_ec_pg()) { + replica_clear_repop_obc(logv, t); + } recovery_state.append_log( logv, trim_to, roll_forward_to, min_last_complete_ondisk, t, transaction_applied, async); } + void replica_clear_repop_obc( + const vector &logv, + ObjectStore::Transaction &t); + void op_applied(const eversion_t &applied_version) override; bool should_send_op(