]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
osd: refactor the skip promotion logic
authorZhiqiang Wang <zhiqiang.wang@intel.com>
Thu, 12 Mar 2015 05:54:51 +0000 (13:54 +0800)
committerZhiqiang Wang <zhiqiang.wang@intel.com>
Fri, 17 Apr 2015 01:11:47 +0000 (09:11 +0800)
Moving the skip promotion detection logic into init_op_flags, avoid
doing extra checking.

Signed-off-by: Zhiqiang Wang <zhiqiang.wang@intel.com>
src/osd/OSD.cc
src/osd/ReplicatedPG.cc
src/osd/ReplicatedPG.h

index 933d35daaf22220716396e6316dd05b0dc1aa451..c5cc613b635c0776b0acf917254d8efd176f0672 100644 (file)
@@ -8667,6 +8667,16 @@ int OSD::init_op_flags(OpRequestRef& op)
         break;
       }
 
+    case CEPH_OSD_OP_DELETE:
+      // 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 (iter == m->ops.begin() &&
+         iter->op.flags == CEPH_OSD_OP_FLAG_FAILOK) {
+       op->set_skip_promote();
+      }
+      break;
+
     default:
       break;
     }
index ab435301c15ecea926c7edaff6858c956f5bb5a9..ac977a136e4a37072bef62f05d935ff92ca5f40c 100644 (file)
@@ -1800,7 +1800,7 @@ bool ReplicatedPG::maybe_handle_cache(OpRequestRef op,
     osd->logger->inc(l_osd_op_cache_hit);
     return false;
   }
-
+  
   MOSDOp *m = static_cast<MOSDOp*>(op->get_req());
   const object_locator_t& oloc = m->get_object_locator();
 
@@ -1809,6 +1809,10 @@ bool ReplicatedPG::maybe_handle_cache(OpRequestRef op,
     return true;
   }
 
+  if (op->need_skip_promote()) {
+    return false;
+  }
+
   // older versions do not proxy the feature bits.
   bool can_proxy_read = get_osdmap()->get_up_osd_features() &
     CEPH_FEATURE_OSD_PROXY_FEATURES;
@@ -1832,9 +1836,7 @@ bool ReplicatedPG::maybe_handle_cache(OpRequestRef op,
       waiting_for_cache_not_full.push_back(op);
       return true;
     }
-    if (can_skip_promote(op)) {
-      return false;
-    }
+
     if (op->may_write() || write_ordered || !hit_set) {
       promote_object(obc, missing_oid, oloc, op);
       return true;
@@ -1920,9 +1922,6 @@ bool ReplicatedPG::maybe_handle_cache(OpRequestRef op,
        waiting_for_cache_not_full.push_back(op);
        return true;
       }
-      if (can_skip_promote(op)) {
-       return false;
-      }
       promote_object(obc, missing_oid, oloc, op);
       return true;
     }
@@ -1940,9 +1939,6 @@ bool ReplicatedPG::maybe_handle_cache(OpRequestRef op,
        waiting_for_cache_not_full.push_back(op);
        return true;
       }
-      if (can_skip_promote(op)) {
-       return false;
-      }
       promote_object(obc, missing_oid, oloc, op);
       return true;
     }
@@ -1957,20 +1953,6 @@ bool ReplicatedPG::maybe_handle_cache(OpRequestRef op,
   return false;
 }
 
-bool ReplicatedPG::can_skip_promote(OpRequestRef op)
-{
-  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)
 {
   MOSDOp *m = static_cast<MOSDOp*>(op->get_req());
index 5c8ad6bd34948d89c1d9746cea527fde1bfc4bac..28afab1518ac004e3e503ff209aba5bef2c11752 100644 (file)
@@ -1156,11 +1156,6 @@ protected:
                      const object_locator_t& oloc,    ///< locator for obc|oid
                      OpRequestRef op);                ///< [optional] client op
 
-  /**
-   * Check if the op is such that we can skip promote (e.g., DELETE)
-   */
-  bool can_skip_promote(OpRequestRef op);
-
   int prepare_transaction(OpContext *ctx);
   list<pair<OpRequestRef, OpContext*> > in_progress_async_reads;
   void complete_read_ctx(int result, OpContext *ctx);