From bc893f55d847df3cb1d36758e02051dee97e1225 Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Tue, 17 Dec 2013 12:33:54 -0800 Subject: [PATCH] osd/ReplicatedPG: fix undirty on clean object Return success, but do not screw up the stats. Signed-off-by: Sage Weil --- src/osd/ReplicatedPG.cc | 10 +++++++--- src/test/librados/tier.cc | 5 +++++ 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/src/osd/ReplicatedPG.cc b/src/osd/ReplicatedPG.cc index f1df651bf7e..e17b67070e9 100644 --- a/src/osd/ReplicatedPG.cc +++ b/src/osd/ReplicatedPG.cc @@ -2885,9 +2885,12 @@ int ReplicatedPG::do_osd_ops(OpContext *ctx, vector& ops) case CEPH_OSD_OP_UNDIRTY: ++ctx->num_write; { - ctx->undirty = true; // see make_writeable() - ctx->modify = true; - ctx->delta_stats.num_wr++; + if (oi.is_dirty()) { + ctx->undirty = true; // see make_writeable() + ctx->modify = true; + ctx->delta_stats.num_wr++; + } + result = 0; } break; @@ -4161,6 +4164,7 @@ void ReplicatedPG::make_writeable(OpContext *ctx) // we will mark the object dirty if (ctx->undirty) { 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; } else if (!ctx->new_obs.oi.test_flag(object_info_t::FLAG_DIRTY)) { diff --git a/src/test/librados/tier.cc b/src/test/librados/tier.cc index d0ab530f034..e12db70f872 100644 --- a/src/test/librados/tier.cc +++ b/src/test/librados/tier.cc @@ -61,6 +61,11 @@ TEST(LibRadosTier, Dirty) { op.undirty(); ASSERT_EQ(0, ioctx.operate("foo", &op)); } + { + ObjectWriteOperation op; + op.undirty(); + ASSERT_EQ(0, ioctx.operate("foo", &op)); // still 0 if already clean + } { bool dirty = false; int r = -1;