From 9e33bf129bdb2fbea9b637f832cdf8b59065aff5 Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Thu, 18 Jun 2009 16:38:39 -0700 Subject: [PATCH] osd: don't trim pg log if degraded Also be a bit more verbose about pg_trim_to changes. --- src/osd/PG.h | 1 + src/osd/ReplicatedPG.cc | 11 +++++++---- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/osd/PG.h b/src/osd/PG.h index 029576514c15b..52ce2324a1e77 100644 --- a/src/osd/PG.h +++ b/src/osd/PG.h @@ -847,6 +847,7 @@ public: bool is_replay() const { return state_test(PG_STATE_REPLAY); } //bool is_complete() { return state_test(PG_STATE_COMPLETE); } bool is_clean() const { return state_test(PG_STATE_CLEAN); } + bool is_degraded() const { return state_test(PG_STATE_DEGRADED); } bool is_stray() const { return state_test(PG_STATE_STRAY); } bool is_scrubbing() const { return state_test(PG_STATE_SCRUBBING); } diff --git a/src/osd/ReplicatedPG.cc b/src/osd/ReplicatedPG.cc index 288168943b0ac..06db0dd5a928b 100644 --- a/src/osd/ReplicatedPG.cc +++ b/src/osd/ReplicatedPG.cc @@ -415,10 +415,13 @@ void ReplicatedPG::do_pg_op(MOSDOp *op) void ReplicatedPG::calc_trim_to() { - if (is_clean() || - log.top.version - log.bottom.version > info.stats.num_objects) { - pg_trim_to = min_last_complete_ondisk; - if (pg_trim_to != eversion_t()) { + if (!is_degraded() && + (is_clean() || + log.top.version - log.bottom.version > info.stats.num_objects)) { + if (min_last_complete_ondisk != eversion_t() && + min_last_complete_ondisk != pg_trim_to) { + dout(10) << "calc_trim_to " << pg_trim_to << " -> " << min_last_complete_ondisk << dendl; + pg_trim_to = min_last_complete_ondisk; assert(pg_trim_to >= log.bottom); assert(pg_trim_to <= log.top); } -- 2.39.5