From 6ff6c19d651d07c8273a6f2a6938f0b7e8f9c1df Mon Sep 17 00:00:00 2001 From: Samuel Just Date: Sun, 6 Apr 2014 16:30:25 -0700 Subject: [PATCH] ReplicatedPG::make_writeable: check for evicted clone before adjusting for clone_overlap Fixes: #7964 Signed-off-by: Samuel Just --- src/osd/ReplicatedPG.cc | 26 +++++++++++++++++++++----- src/osd/ReplicatedPG.h | 3 +++ 2 files changed, 24 insertions(+), 5 deletions(-) diff --git a/src/osd/ReplicatedPG.cc b/src/osd/ReplicatedPG.cc index dc5123b74de7b..724b5394cecc5 100644 --- a/src/osd/ReplicatedPG.cc +++ b/src/osd/ReplicatedPG.cc @@ -4777,11 +4777,17 @@ void ReplicatedPG::make_writeable(OpContext *ctx) // update most recent clone_overlap and usage stats if (ctx->new_snapset.clones.size() > 0) { - interval_set &newest_overlap = ctx->new_snapset.clone_overlap.rbegin()->second; - ctx->modified_ranges.intersection_of(newest_overlap); - // modified_ranges is still in use by the clone - add_interval_usage(ctx->modified_ranges, ctx->delta_stats); - newest_overlap.subtract(ctx->modified_ranges); + /* we need to check whether the most recent clone exists, if it's been evicted, + * it's not included in the stats */ + hobject_t last_clone_oid = soid; + last_clone_oid.snap = ctx->new_snapset.clone_overlap.rbegin()->first; + if (is_present_clone(last_clone_oid)) { + interval_set &newest_overlap = ctx->new_snapset.clone_overlap.rbegin()->second; + ctx->modified_ranges.intersection_of(newest_overlap); + // modified_ranges is still in use by the clone + add_interval_usage(ctx->modified_ranges, ctx->delta_stats); + newest_overlap.subtract(ctx->modified_ranges); + } } // prepend transaction to op_t @@ -6185,6 +6191,16 @@ void ReplicatedPG::cancel_flush_ops(bool requeue) } } +bool ReplicatedPG::is_present_clone(hobject_t coid) +{ + if (pool.info.cache_mode == pg_pool_t::CACHEMODE_NONE) + return true; + if (is_missing_object(coid)) + return true; + ObjectContextRef obc = get_object_context(coid, false); + return obc && obc->obs.exists; +} + // ======================================================================== // rep op gather diff --git a/src/osd/ReplicatedPG.h b/src/osd/ReplicatedPG.h index 915151cfc2f65..895fe6fa4bff9 100644 --- a/src/osd/ReplicatedPG.h +++ b/src/osd/ReplicatedPG.h @@ -1190,6 +1190,9 @@ protected: void cancel_flush(FlushOpRef fop, bool requeue); void cancel_flush_ops(bool requeue); + /// @return false if clone is has been evicted + bool is_present_clone(hobject_t coid); + friend struct C_Flush; // -- scrub -- -- 2.39.5