]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
ReplicatedPG:: find_object_context clear extra creation (head,snapdir) 3679/head
authorNing Yao <zay11022@gmail.com>
Tue, 10 Feb 2015 12:28:42 +0000 (12:28 +0000)
committerNing Yao <zay11022@gmail.com>
Tue, 10 Feb 2015 12:28:42 +0000 (12:28 +0000)
if it is the head object, there is no need to create extra head,
snapdir. only creation for other cases we need.

Signed-off-by: Ning Yao <zay11022@gmail.com>
src/osd/ReplicatedPG.cc

index 904119e27027fd04df147e0f40db8c295218a488..0deef67a7139e5747804f3bbd15600ed19a4ba7a 100644 (file)
@@ -8007,17 +8007,35 @@ int ReplicatedPG::find_object_context(const hobject_t& oid,
                                      bool map_snapid_to_clone,
                                      hobject_t *pmissing)
 {
+  assert(oid.pool == info.pgid.pool());
+  // want the head?
+  if (oid.snap == CEPH_NOSNAP) {
+    ObjectContextRef obc = get_object_context(oid, can_create);
+    if (!obc) {
+      if (pmissing)
+  *pmissing = oid;
+      return -ENOENT;
+    }
+    dout(10) << "find_object_context " << oid
+       << " @" << oid.snap
+       << " oi=" << obc->obs.oi
+       << dendl;
+    *pobc = obc;
+
+    if (can_create && !obc->ssc)
+      obc->ssc = get_snapset_context(oid, true);
+
+    return 0;
+  }
+
   hobject_t head(oid.oid, oid.get_key(), CEPH_NOSNAP, oid.get_hash(),
                 info.pgid.pool(), oid.get_namespace());
-  hobject_t snapdir(oid.oid, oid.get_key(), CEPH_SNAPDIR, oid.get_hash(),
-                   info.pgid.pool(), oid.get_namespace());
-
   // want the snapdir?
   if (oid.snap == CEPH_SNAPDIR) {
     // return head or snapdir, whichever exists.
     ObjectContextRef obc = get_object_context(head, can_create);
     if (!obc || !obc->obs.exists)
-      obc = get_object_context(snapdir, can_create);
+      obc = get_object_context(oid, can_create);
     if (!obc || !obc->obs.exists) {
       // if we have neither, we would want to promote the head.
       if (pmissing)
@@ -8037,26 +8055,6 @@ int ReplicatedPG::find_object_context(const hobject_t& oid,
     return 0;
   }
 
-  // want the head?
-  if (oid.snap == CEPH_NOSNAP) {
-    ObjectContextRef obc = get_object_context(head, can_create);
-    if (!obc) {
-      if (pmissing)
-       *pmissing = head;
-      return -ENOENT;
-    }
-    dout(10) << "find_object_context " << oid
-            << " @" << oid.snap
-            << " oi=" << obc->obs.oi
-            << dendl;
-    *pobc = obc;
-
-    if (can_create && !obc->ssc)
-      obc->ssc = get_snapset_context(oid, true);
-
-    return 0;
-  }
-
   // we want a snap
   if (!map_snapid_to_clone && pool.info.is_removed_snap(oid.snap)) {
     dout(10) << __func__ << " snap " << oid.snap << " is removed" << dendl;