From: Samuel Just Date: Thu, 6 Mar 2014 20:05:07 +0000 (-0800) Subject: ReplicatedPG: clean up num_dirty adjustments X-Git-Tag: v0.78~74^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=refs%2Fpull%2F1391%2Fhead;p=ceph.git ReplicatedPG: clean up num_dirty adjustments Previously, a _delete_head() followed by a recreation on an object in the same transaction would result in num_dirty being decremented in _delete_head() without the flag being cleared. make_writeable() would then see exists and was_dirty and therefore not increment num_dirty resulting in a mismatch. Rather than trying to maintain the num_dirty number in _delete_head(), rollback_to(), and make_writeable(), it seems simpler to do the adjustment once in make_writeable based on undirty, ctx->obc->obs.oi, and ctx->new_obs->oi. Fixes: 7393 Signed-off-by: Samuel Just --- diff --git a/src/osd/ReplicatedPG.cc b/src/osd/ReplicatedPG.cc index 6c9d5ecf4841..b15fd0321a1c 100644 --- a/src/osd/ReplicatedPG.cc +++ b/src/osd/ReplicatedPG.cc @@ -4510,8 +4510,6 @@ inline int ReplicatedPG::_delete_head(OpContext *ctx, bool no_whiteout) } ctx->delta_stats.num_objects--; - if (oi.is_dirty()) - ctx->delta_stats.num_objects_dirty--; if (oi.is_whiteout()) { dout(20) << __func__ << " deleting whiteout on " << soid << dendl; ctx->delta_stats.num_whiteouts--; @@ -4625,7 +4623,6 @@ int ReplicatedPG::_rollback_to(OpContext *ctx, ceph_osd_op& op) if (!obs.exists) { obs.exists = true; //we're about to recreate it ctx->delta_stats.num_objects++; - ctx->delta_stats.num_objects_dirty++; } ctx->delta_stats.num_bytes -= obs.oi.size; ctx->delta_stats.num_bytes += rollback_to->obs.oi.size; @@ -4662,22 +4659,27 @@ void ReplicatedPG::make_writeable(OpContext *ctx) dout(20) << "make_writeable " << soid << " snapset=" << ctx->snapset << " snapc=" << snapc << dendl;; - bool was_dirty = ctx->new_obs.oi.is_dirty(); - + bool was_dirty = ctx->obc->obs.oi.is_dirty(); if (ctx->new_obs.exists) { // we will mark the object dirty - if (ctx->undirty) { + if (ctx->undirty && was_dirty) { dout(20) << " clearing DIRTY flag" << dendl; assert(ctx->new_obs.oi.is_dirty()); ctx->new_obs.oi.clear_flag(object_info_t::FLAG_DIRTY); --ctx->delta_stats.num_objects_dirty; osd->logger->inc(l_osd_tier_clean); - } else if (!ctx->new_obs.oi.test_flag(object_info_t::FLAG_DIRTY)) { + } else if (!was_dirty && !ctx->undirty) { dout(20) << " setting DIRTY flag" << dendl; ctx->new_obs.oi.set_flag(object_info_t::FLAG_DIRTY); ++ctx->delta_stats.num_objects_dirty; osd->logger->inc(l_osd_tier_dirty); } + } else { + if (was_dirty) { + dout(20) << " deletion, decrementing num_dirty and clearing flag" << dendl; + ctx->new_obs.oi.clear_flag(object_info_t::FLAG_DIRTY); + --ctx->delta_stats.num_objects_dirty; + } } // use newer snapc?