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 <sam.just@inktank.com>
This commit is contained in:
Samuel Just 2014-03-27 16:34:20 -07:00
parent 90c4540b5b
commit 78e9813c41
3 changed files with 22 additions and 7 deletions

View File

@ -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<pg_shard_t>::iterator i = backfill_targets.begin();
@ -7102,7 +7110,12 @@ SnapSetContext *ReplicatedPG::get_snapset_context(
map<hobject_t, SnapSetContext*>::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);

View File

@ -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);

View File

@ -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) { }
};