]> 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)
committerSage Weil <sage@redhat.com>
Fri, 14 Nov 2014 06:33:25 +0000 (22:33 -0800)
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>
src/osd/ReplicatedPG.cc
src/osd/ReplicatedPG.h
src/test/librados/tier.cc

index 3e4a1de073411e21b9a9c089dc091f8b4d545529..46c678d3201522f5da0a12d5de6549b702d9bd39 100644 (file)
@@ -1706,6 +1706,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
@@ -4241,7 +4245,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 c4490f3a724fc84869b323c426e3b0fc000870f0..61054af2458c95394f3ad384c8b0785f429c691f 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 bd35bbd8cb823bb26d30d732342b3d204243c876..7e557ebda72f6bc61e3f563264e317b0334a0afe 100644 (file)
@@ -636,7 +636,24 @@ TEST_F(LibRadosTwoPoolsPP, Whiteout) {
     ASSERT_TRUE(it == cache_ioctx.nobjects_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();
+
+    NObjectIterator it = cache_ioctx.nobjects_begin();
+    ASSERT_TRUE(it != cache_ioctx.nobjects_end());
+    ASSERT_TRUE(it->get_oid() == string("foo"));
+    ++it;
+    ASSERT_TRUE(it == cache_ioctx.nobjects_end());
+  }
 
   // recreate an object and verify we can read it
   {
@@ -2763,7 +2780,24 @@ TEST_F(LibRadosTwoPoolsECPP, Whiteout) {
     ASSERT_TRUE(it == cache_ioctx.nobjects_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();
+
+    NObjectIterator it = cache_ioctx.nobjects_begin();
+    ASSERT_TRUE(it != cache_ioctx.nobjects_end());
+    ASSERT_TRUE(it->get_oid() == string("foo"));
+    ++it;
+    ASSERT_TRUE(it == cache_ioctx.nobjects_end());
+  }
 
   // recreate an object and verify we can read it
   {