Skip to content

Commit

Permalink
osd/ReplicatedPG: do not clone or preserve snapdir on cache_evict
Browse files Browse the repository at this point in the history
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 <sage@redhat.com>
(cherry picked from commit ce8eefc)
  • Loading branch information
liewegas committed Oct 17, 2014
1 parent 88e6014 commit 1228658
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
9 changes: 8 additions & 1 deletion src/osd/ReplicatedPG.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3353,6 +3353,11 @@ int ReplicatedPG::do_osd_ops(OpContext *ctx, vector<OSDOp>& 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;
Expand Down Expand Up @@ -4836,6 +4841,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;
Expand Down Expand Up @@ -5156,7 +5162,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());
Expand Down
3 changes: 2 additions & 1 deletion src/osd/ReplicatedPG.h
Original file line number Diff line number Diff line change
Expand Up @@ -438,6 +438,7 @@ class ReplicatedPG : public PG, public PGBackend::Listener {
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_info_t> watch_connects;
Expand Down Expand Up @@ -539,7 +540,7 @@ class ReplicatedPG : public PG, public PGBackend::Listener {
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),
Expand Down

0 comments on commit 1228658

Please sign in to comment.