From ce8eefca13008a9cce3aedd67b11537145e1fd77 Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Sun, 21 Sep 2014 15:56:18 -0700 Subject: [PATCH] osd/ReplicatedPG: do not clone or preserve snapdir on cache_evict If we cache_evict a head in a cache pool, we need to prevent make_writeable() from cloning the head and finish_ctx() from preserving the snapdir object. Fixes: #8629 Backport: firefly Signed-off-by: Sage Weil --- src/osd/ReplicatedPG.cc | 9 ++++++++- src/osd/ReplicatedPG.h | 3 ++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/osd/ReplicatedPG.cc b/src/osd/ReplicatedPG.cc index 6d073755889a..cd47f9f860f6 100644 --- a/src/osd/ReplicatedPG.cc +++ b/src/osd/ReplicatedPG.cc @@ -3492,6 +3492,11 @@ int ReplicatedPG::do_osd_ops(OpContext *ctx, vector& ops) break; } result = _delete_oid(ctx, true); + if (result >= 0) { + // mark that this is a cache eviction to avoid triggering normal + // make_writeable() clone or snapdir object creation in finish_ctx() + ctx->cache_evict = true; + } osd->logger->inc(l_osd_tier_evict); } break; @@ -5054,6 +5059,7 @@ void ReplicatedPG::make_writeable(OpContext *ctx) if ((ctx->obs->exists && !ctx->obs->oi.is_whiteout()) && // head exist(ed) snapc.snaps.size() && // there are snaps + !ctx->cache_evict && snapc.snaps[0] > ctx->new_snapset.seq) { // existing object is old // clone hobject_t coid = soid; @@ -5375,7 +5381,8 @@ void ReplicatedPG::finish_ctx(OpContext *ctx, int log_op_type, bool maintain_ssc ctx->snapset_obc->obs.exists = false; } } - } else if (ctx->new_snapset.clones.size()) { + } else if (ctx->new_snapset.clones.size() && + !ctx->cache_evict) { // save snapset on _snap hobject_t snapoid(soid.oid, soid.get_key(), CEPH_SNAPDIR, soid.hash, info.pgid.pool(), soid.get_namespace()); diff --git a/src/osd/ReplicatedPG.h b/src/osd/ReplicatedPG.h index 918e2d335f11..57a84df1fecb 100644 --- a/src/osd/ReplicatedPG.h +++ b/src/osd/ReplicatedPG.h @@ -438,6 +438,7 @@ public: bool modify; // (force) modification (even if op_t is empty) bool user_modify; // user-visible modification bool undirty; // user explicitly un-dirtying this object + bool cache_evict; ///< true if this is a cache eviction // side effects list watch_connects; @@ -539,7 +540,7 @@ public: ReplicatedPG *_pg) : op(_op), reqid(_reqid), ops(_ops), obs(_obs), snapset(0), new_obs(_obs->oi, _obs->exists), - modify(false), user_modify(false), undirty(false), + modify(false), user_modify(false), undirty(false), cache_evict(false), bytes_written(0), bytes_read(0), user_at_version(0), current_osd_subop_num(0), op_t(NULL), -- 2.47.3