]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
osd/ReplicatedPG: allow whiteout deletion with IGNORE_CACHE flag
authorSage Weil <sage@redhat.com>
Fri, 14 Nov 2014 06:32:20 +0000 (22:32 -0800)
committerNathan Cutler <ncutler@suse.com>
Tue, 29 Sep 2015 13:10:05 +0000 (15:10 +0200)
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 <sage@redhat.com>
(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
src/osd/ReplicatedPG.h
src/test/librados/tier.cc

index 4229cefcf6b98e93dbcd8cd88d23018fdc807310..d7a3f1ec20866e8a618ecb5f90ea3ff84b819830 100644 (file)
@@ -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<OSDOp>& ops)
        // Cannot delete an object with watchers
        result = -EBUSY;
       } else {
-       result = _delete_oid(ctx, false);
+       result = _delete_oid(ctx, ctx->ignore_cache);
       }
       break;
 
index c8e1c4b3ca6490568299cf36afc46230b224ccca..c6de400548675eda6e679d7339520d70faeafd54 100644 (file)
@@ -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_info_t> 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),
index 145cdaed04ae736249bf46c21f2f65a3b1b26e93..32dff184ad75c592644b818919664ad7273ce13e 100644 (file)
@@ -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
   {