From 78e9813c41336aa96150f92cc046e969549890b3 Mon Sep 17 00:00:00 2001 From: Samuel Just Date: Thu, 27 Mar 2014 16:34:20 -0700 Subject: [PATCH] ReplicatedPG: do not create snapdir on head eviction Head eviction implies that no clones are present. Also, add an exists flag to SnapSetContext in order prevent an ssc from a recent eviction from preventing a snap read from activating the promotion machinery. Fixes: #7858 Signed-off-by: Samuel Just --- src/osd/ReplicatedPG.cc | 23 ++++++++++++++++++----- src/osd/ReplicatedPG.h | 2 +- src/osd/osd_types.h | 4 +++- 3 files changed, 22 insertions(+), 7 deletions(-) diff --git a/src/osd/ReplicatedPG.cc b/src/osd/ReplicatedPG.cc index 3f729b28421a6..85ef5e2b7ea5b 100644 --- a/src/osd/ReplicatedPG.cc +++ b/src/osd/ReplicatedPG.cc @@ -4975,7 +4975,7 @@ int ReplicatedPG::prepare_transaction(OpContext *ctx) return result; } -void ReplicatedPG::finish_ctx(OpContext *ctx, int log_op_type) +void ReplicatedPG::finish_ctx(OpContext *ctx, int log_op_type, bool maintain_ssc) { const hobject_t& soid = ctx->obs->oi.soid; dout(20) << __func__ << " " << soid << " " << ctx @@ -4985,7 +4985,7 @@ void ReplicatedPG::finish_ctx(OpContext *ctx, int log_op_type) // snapset bufferlist bss; - if (soid.snap == CEPH_NOSNAP) { + if (soid.snap == CEPH_NOSNAP && maintain_ssc) { ::encode(ctx->new_snapset, bss); assert(ctx->new_obs.exists == ctx->new_snapset.head_exists); @@ -5136,7 +5136,15 @@ void ReplicatedPG::finish_ctx(OpContext *ctx, int log_op_type) // apply new object state. ctx->obc->obs = ctx->new_obs; - ctx->obc->ssc->snapset = ctx->new_snapset; + + if (!maintain_ssc && soid.is_head()) { + ctx->obc->ssc->exists = false; + ctx->obc->ssc->snapset = SnapSet(); + } else { + ctx->obc->ssc->exists = true; + ctx->obc->ssc->snapset = ctx->new_snapset; + } + info.stats.stats.add(ctx->delta_stats, ctx->obs->oi.category); for (set::iterator i = backfill_targets.begin(); @@ -7102,7 +7110,12 @@ SnapSetContext *ReplicatedPG::get_snapset_context( map::iterator p = snapset_contexts.find( oid.get_snapdir()); if (p != snapset_contexts.end()) { - ssc = p->second; + if (can_create || p->second->exists) { + ssc = p->second; + ssc->exists = true; + } else { + return NULL; + } } else { bufferlist bv; if (!attrs) { @@ -10862,7 +10875,7 @@ bool ReplicatedPG::agent_maybe_evict(ObjectContextRef& obc) assert(ctx->new_obs.exists); int r = _delete_oid(ctx, true); assert(r == 0); - finish_ctx(ctx, pg_log_entry_t::DELETE); + finish_ctx(ctx, pg_log_entry_t::DELETE, false); simple_repop_submit(repop); osd->logger->inc(l_osd_tier_evict); osd->logger->inc(l_osd_agent_evict); diff --git a/src/osd/ReplicatedPG.h b/src/osd/ReplicatedPG.h index 4d6000da8c4a1..915151cfc2f65 100644 --- a/src/osd/ReplicatedPG.h +++ b/src/osd/ReplicatedPG.h @@ -990,7 +990,7 @@ protected: const hobject_t& head, const hobject_t& coid, object_info_t *poi); void execute_ctx(OpContext *ctx); - void finish_ctx(OpContext *ctx, int log_op_type); + void finish_ctx(OpContext *ctx, int log_op_type, bool maintain_ssc=true); void reply_ctx(OpContext *ctx, int err); void reply_ctx(OpContext *ctx, int err, eversion_t v, version_t uv); void make_writeable(OpContext *ctx); diff --git a/src/osd/osd_types.h b/src/osd/osd_types.h index e055281ccea50..0fff4ccb64b4d 100644 --- a/src/osd/osd_types.h +++ b/src/osd/osd_types.h @@ -2595,8 +2595,10 @@ struct SnapSetContext { int ref; bool registered; SnapSet snapset; + bool exists; - SnapSetContext(const hobject_t& o) : oid(o), ref(0), registered(false) { } + SnapSetContext(const hobject_t& o) : + oid(o), ref(0), registered(false), exists(true) { } }; -- 2.39.5