]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
osd/ReplicatedPG: skip promote for DELETE
authorSage Weil <sage@inktank.com>
Wed, 23 Oct 2013 02:56:55 +0000 (19:56 -0700)
committerSage Weil <sage@inktank.com>
Sat, 14 Dec 2013 00:35:54 +0000 (16:35 -0800)
If an op starts with DELETE there is no need to promote the old content
from the base tier.  Note that this only works if the FAILOK flag is
set.  Otherwise, we need to know whether the object existed or not to
return either 0 or -ENOENT.

Signed-off-by: Sage Weil <sage@inktank.com>
src/osd/ReplicatedPG.cc
src/osd/ReplicatedPG.h

index 6e338c2bf73951882d4fc7571bc3b6da206c6fad..64d9c1dcef1362179bac14a755c16b6a75d08428 100644 (file)
@@ -1231,6 +1231,8 @@ bool ReplicatedPG::maybe_handle_cache(OpRequestRef op, ObjectContextRef obc,
   case pg_pool_t::CACHEMODE_WRITEBACK:
     if (obc.get() && obc->obs.exists) { // we have the object already
       return false;
+    } else if (can_skip_promote(op, obc)) {
+      return false;
     } else { // try and promote!
       promote_object(op, obc);
       return true;
@@ -1259,6 +1261,20 @@ bool ReplicatedPG::maybe_handle_cache(OpRequestRef op, ObjectContextRef obc,
   return false;
 }
 
+bool ReplicatedPG::can_skip_promote(OpRequestRef op, ObjectContextRef obc)
+{
+  MOSDOp *m = static_cast<MOSDOp*>(op->get_req());
+  if (m->ops.empty())
+    return false;
+  // if we get a delete with FAILOK we can skip promote.  without
+  // FAILOK we still need to promote (or do something smarter) to
+  // determine whether to return ENOENT or 0.
+  if (m->ops[0].op.op == CEPH_OSD_OP_DELETE &&
+      (m->ops[0].op.flags & CEPH_OSD_OP_FLAG_FAILOK))
+    return true;
+  return false;
+}
+
 void ReplicatedPG::do_cache_redirect(OpRequestRef op, ObjectContextRef obc)
 {
   MOSDOp *m = static_cast<MOSDOp*>(op->get_req());
index ef1a385ce469ab21be5ddc9bfa532d71ba9e1b13..06797d0c6cae721ff71f7f0f6568f6aa551e6fb6 100644 (file)
@@ -818,6 +818,11 @@ protected:
    */
   void promote_object(OpRequestRef op, ObjectContextRef obc);
 
+  /**
+   * Check if the op is such that we can skip promote (e.g., DELETE)
+   */
+  bool can_skip_promote(OpRequestRef op, ObjectContextRef obc);
+
   int prepare_transaction(OpContext *ctx);
   
   // pg on-disk content