From: Sage Weil Date: Sun, 17 Sep 2017 22:10:53 +0000 (-0500) Subject: osd/PG: move some osd logic into handle_pg_trim X-Git-Tag: v13.0.1~634^2~32 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=ea169c1bf22d7335c018d90d3e7464a93dfa7e4f;p=ceph.git osd/PG: move some osd logic into handle_pg_trim Signed-off-by: Sage Weil --- diff --git a/src/osd/OSD.cc b/src/osd/OSD.cc index 9cbce15c9b53..342051a1c6a0 100644 --- a/src/osd/OSD.cc +++ b/src/osd/OSD.cc @@ -8391,29 +8391,7 @@ void OSD::handle_pg_trim(OpRequestRef op) dout(10) << " don't have pg " << m->pgid << dendl; return; } - - if (m->epoch < pg->info.history.same_interval_since) { - dout(10) << *pg << " got old trim to " << m->trim_to << ", ignoring" << dendl; - pg->unlock(); - return; - } - - if (pg->is_primary()) { - // peer is informing us of their last_complete_ondisk - dout(10) << *pg << " replica osd." << from << " lcod " << m->trim_to << dendl; - pg->peer_last_complete_ondisk[pg_shard_t(from, m->pgid.shard)] = - m->trim_to; - // trim log when the pg is recovered - pg->calc_min_last_complete_ondisk(); - } else { - // primary is instructing us to trim - ObjectStore::Transaction t; - pg->pg_log.trim(m->trim_to, pg->info); - pg->dirty_info = true; - pg->write_if_dirty(t); - int tr = store->queue_transaction(pg->osr.get(), std::move(t), NULL); - assert(tr == 0); - } + pg->handle_pg_trim(m->epoch, from, m->pgid.shard, m->trim_to); pg->unlock(); } diff --git a/src/osd/PG.cc b/src/osd/PG.cc index ba8e17315028..36058c439b64 100644 --- a/src/osd/PG.cc +++ b/src/osd/PG.cc @@ -3076,6 +3076,31 @@ void PG::trim_log() } } +void PG::handle_pg_trim(epoch_t epoch, int from, shard_id_t shard, eversion_t trim_to) +{ + if (epoch < info.history.same_interval_since) { + dout(10) << " got old trim to " << trim_to << ", ignoring" << dendl; + return; + } + + if (is_primary()) { + // peer is informing us of their last_complete_ondisk + dout(10) << " replica osd." << from << " lcod " << trim_to << dendl; + peer_last_complete_ondisk[pg_shard_t(from, shard)] = trim_to; + + // trim log when the pg is recovered + calc_min_last_complete_ondisk(); + } else { + // primary is instructing us to trim + ObjectStore::Transaction t; + pg_log.trim(trim_to, info); + dirty_info = true; + write_if_dirty(t); + int tr = osd->store->queue_transaction(osr.get(), std::move(t), NULL); + assert(tr == 0); + } +} + void PG::add_log_entry(const pg_log_entry_t& e, bool applied) { // raise last_complete only if we were previously up to date diff --git a/src/osd/PG.h b/src/osd/PG.h index f37707e3f491..4c64a0e60010 100644 --- a/src/osd/PG.h +++ b/src/osd/PG.h @@ -408,6 +408,8 @@ public: void handle_loaded(RecoveryCtx *rctx); void handle_query_state(Formatter *f); + void handle_pg_trim(epoch_t epoch, int from, shard_id_t shard, eversion_t trim_to); + virtual void get_watchers(std::list *ls) = 0; void dump_pgstate_history(Formatter *f);