From b134a629863b4601892db03d7c4377040d556bdd Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Thu, 13 Nov 2014 22:32:20 -0800 Subject: [PATCH] osd/ReplicatedPG: allow whiteout deletion with IGNORE_CACHE flag If the client specifies IGNORE_CACHE, allow a regular DELETE to zap a whiteout. Expand test case to verify this works. Signed-off-by: Sage Weil (cherry picked from commit 34e4d24) Conflicts: src/test/librados/tier.cc replaced NObjectIterator -> ObjectIterator replaced cache_ioctx.nobjects_begin -> cache_ioctx.objects_begin replaced cache_ioctx.nobjects_end -> cache_ioctx.objects_end replace it->get_oid() with it->first for it of type ObjectIterator --- src/osd/ReplicatedPG.cc | 6 +++++- src/osd/ReplicatedPG.h | 2 ++ src/test/librados/tier.cc | 33 +++++++++++++++++++++++++++++++++ 3 files changed, 40 insertions(+), 1 deletion(-) diff --git a/src/osd/ReplicatedPG.cc b/src/osd/ReplicatedPG.cc index 4229cefcf6b98..d7a3f1ec20866 100644 --- a/src/osd/ReplicatedPG.cc +++ b/src/osd/ReplicatedPG.cc @@ -1538,6 +1538,10 @@ void ReplicatedPG::do_op(OpRequestRef op) return; } + if (m->get_flags() & CEPH_OSD_FLAG_IGNORE_CACHE) { + ctx->ignore_cache = true; + } + if ((op->may_read()) && (obc->obs.oi.is_lost())) { // This object is lost. Reading from it returns an error. dout(20) << __func__ << ": object " << obc->obs.oi.soid @@ -3992,7 +3996,7 @@ int ReplicatedPG::do_osd_ops(OpContext *ctx, vector& ops) // Cannot delete an object with watchers result = -EBUSY; } else { - result = _delete_oid(ctx, false); + result = _delete_oid(ctx, ctx->ignore_cache); } break; diff --git a/src/osd/ReplicatedPG.h b/src/osd/ReplicatedPG.h index c8e1c4b3ca649..c6de400548675 100644 --- a/src/osd/ReplicatedPG.h +++ b/src/osd/ReplicatedPG.h @@ -439,6 +439,7 @@ public: bool user_modify; // user-visible modification bool undirty; // user explicitly un-dirtying this object bool cache_evict; ///< true if this is a cache eviction + bool ignore_cache; ///< true if IGNORE_CACHE flag is set // side effects list watch_connects; @@ -541,6 +542,7 @@ public: op(_op), reqid(_reqid), ops(_ops), obs(_obs), snapset(0), new_obs(_obs->oi, _obs->exists), modify(false), user_modify(false), undirty(false), cache_evict(false), + ignore_cache(false), bytes_written(0), bytes_read(0), user_at_version(0), current_osd_subop_num(0), op_t(NULL), diff --git a/src/test/librados/tier.cc b/src/test/librados/tier.cc index 145cdaed04ae7..32dff184ad75c 100644 --- a/src/test/librados/tier.cc +++ b/src/test/librados/tier.cc @@ -624,7 +624,24 @@ TEST_F(LibRadosTwoPoolsPP, Whiteout) { ASSERT_TRUE(it == cache_ioctx.objects_end()); } + // delete a whiteout and verify it goes away ASSERT_EQ(-ENOENT, ioctx.remove("foo")); + { + ObjectWriteOperation op; + op.remove(); + librados::AioCompletion *completion = cluster.aio_create_completion(); + ASSERT_EQ(0, ioctx.aio_operate("bar", completion, &op, + librados::OPERATION_IGNORE_CACHE)); + completion->wait_for_safe(); + ASSERT_EQ(0, completion->get_return_value()); + completion->release(); + + ObjectIterator it = cache_ioctx.objects_begin(); + ASSERT_TRUE(it != cache_ioctx.objects_end()); + ASSERT_TRUE(it->first == string("foo")); + ++it; + ASSERT_TRUE(it == cache_ioctx.objects_end()); + } // recreate an object and verify we can read it { @@ -2725,7 +2742,23 @@ TEST_F(LibRadosTwoPoolsECPP, Whiteout) { ASSERT_TRUE(it == cache_ioctx.objects_end()); } + // delete a whiteout and verify it goes away ASSERT_EQ(-ENOENT, ioctx.remove("foo")); + { + ObjectWriteOperation op; + op.remove(); + librados::AioCompletion *completion = cluster.aio_create_completion(); + ASSERT_EQ(0, ioctx.aio_operate("bar", completion, &op, + librados::OPERATION_IGNORE_CACHE)); + completion->wait_for_safe(); + ASSERT_EQ(0, completion->get_return_value()); + completion->release(); + + ObjectIterator it = cache_ioctx.objects_begin(); + ASSERT_TRUE(it != cache_ioctx.objects_end()); + ++it; + ASSERT_TRUE(it == cache_ioctx.objects_end()); + } // recreate an object and verify we can read it { -- 2.39.5