]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
osd/ReplicatedPG: using missing_oid to decide which object to promote
authorSage Weil <sage@inktank.com>
Tue, 24 Dec 2013 01:26:39 +0000 (17:26 -0800)
committerSage Weil <sage@inktank.com>
Tue, 14 Jan 2014 00:19:39 +0000 (16:19 -0800)
find_object_context() now tells us which object it could use if it
doesn't find it on disk.  Promote that one.

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

index 9c4c19794c0e809a5b509eed603d6c658410efbd..7ba3efb6e3d8120e346bdecfff222b14cd33ddfc 100644 (file)
@@ -1156,7 +1156,7 @@ void ReplicatedPG::do_op(OpRequestRef op)
   }
 
   if ((m->get_flags() & CEPH_OSD_FLAG_IGNORE_CACHE) == 0 &&
-      maybe_handle_cache(op, obc, r))
+      maybe_handle_cache(op, obc, r, missing_oid))
     return;
 
   if (r) {
@@ -1344,13 +1344,17 @@ void ReplicatedPG::do_op(OpRequestRef op)
 }
 
 bool ReplicatedPG::maybe_handle_cache(OpRequestRef op, ObjectContextRef obc,
-                                      int r)
+                                      int r, const hobject_t& missing_oid)
 {
   if (obc)
     dout(25) << __func__ << " " << obc->obs.oi << " "
-            << (obc->obs.exists ? "exists" : "DNE") << dendl;
+            << (obc->obs.exists ? "exists" : "DNE")
+            << " missing_oid " << missing_oid
+            << dendl;
   else
-    dout(25) << __func__ << " (no obc)" << dendl;
+    dout(25) << __func__ << " (no obc)"
+            << " missing_oid " << missing_oid
+            << dendl;
 
   if (obc.get() && obc->is_blocked()) {
     // we're already doing something with this object
@@ -1369,7 +1373,7 @@ bool ReplicatedPG::maybe_handle_cache(OpRequestRef op, ObjectContextRef obc,
     if (can_skip_promote(op, obc)) {
       return false;
     }
-    promote_object(op, obc);
+    promote_object(op, obc, missing_oid);
     return true;
 
   case pg_pool_t::CACHEMODE_FORWARD:
@@ -1382,7 +1386,7 @@ bool ReplicatedPG::maybe_handle_cache(OpRequestRef op, ObjectContextRef obc,
   case pg_pool_t::CACHEMODE_READONLY: // TODO: clean this case up
     if (!obc.get() && r == -ENOENT) {
       // we don't have the object and op's a read
-      promote_object(op, obc);
+      promote_object(op, obc, missing_oid);
       return true;
     }
     if (obc.get() && obc->obs.exists) { // we have the object locally
@@ -1451,19 +1455,13 @@ public:
   }
 };
 
-void ReplicatedPG::promote_object(OpRequestRef op, ObjectContextRef obc)
+void ReplicatedPG::promote_object(OpRequestRef op, ObjectContextRef obc,
+                                 const hobject_t& missing_oid)
 {
   MOSDOp *m = static_cast<MOSDOp*>(op->get_req());
-  if (!obc.get()) { // we need to create an ObjectContext
-    int r = find_object_context(
-      hobject_t(m->get_oid(),
-             m->get_object_locator().key,
-             m->get_snapid(),
-             m->get_pg().ps(),
-             m->get_object_locator().get_pool(),
-             m->get_object_locator().nspace),
-      &obc, true, NULL);
-    assert(r == 0); // a lookup that allows creates can't fail now
+  if (!obc) { // we need to create an ObjectContext
+    assert(missing_oid != hobject_t());
+    obc = get_object_context(missing_oid, true);
   }
   dout(10) << __func__ << " " << obc->obs.oi.soid << dendl;
 
index c8aa86dc09e1f63bf887ffd3682bd8f1eecc3a29..cfd4bc78d652c78fe18c5b2002f2d1ecc63a92c4 100644 (file)
@@ -789,7 +789,8 @@ protected:
    * This helper function is called from do_op if the ObjectContext lookup fails.
    * @returns true if the caching code is handling the Op, false otherwise.
    */
-  inline bool maybe_handle_cache(OpRequestRef op, ObjectContextRef obc, int r);
+  inline bool maybe_handle_cache(OpRequestRef op, ObjectContextRef obc, int r,
+                                const hobject_t& missing_oid);
   /**
    * This helper function tells the client to redirect their request elsewhere.
    */
@@ -797,7 +798,8 @@ protected:
   /**
    * This function starts up a copy from
    */
-  void promote_object(OpRequestRef op, ObjectContextRef obc);
+  void promote_object(OpRequestRef op, ObjectContextRef obc,
+                     const hobject_t& missing_object);
 
   /**
    * Check if the op is such that we can skip promote (e.g., DELETE)