]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
rbd: move the detection of destination image ealier in rename op 4113/head
authorZhiqiang Wang <zhiqiang.wang@intel.com>
Fri, 20 Mar 2015 08:26:29 +0000 (16:26 +0800)
committerZhiqiang Wang <zhiqiang.wang@intel.com>
Mon, 23 Mar 2015 03:26:36 +0000 (11:26 +0800)
Return earlier to avoid extra work of reading image data and omap if the
detection fails or the destination image already exists.

Signed-off-by: Zhiqiang Wang <zhiqiang.wang@intel.com>
src/librbd/internal.cc

index 714c3b3ef381095147171d098c77c16e8ec4979b..2f1d8ca80943b3e7993a6fa5dd669535f86974d6 100644 (file)
@@ -1212,6 +1212,17 @@ reprotect_and_return_err:
       return r;
     }
 
+    r = detect_format(io_ctx, dstname, NULL, NULL);
+    if (r < 0 && r != -ENOENT) {
+      lderr(cct) << "error checking for existing image called "
+                << dstname << ":" << cpp_strerror(r) << dendl;
+      return r;
+    }
+    if (r == 0) {
+      lderr(cct) << "rbd image " << dstname << " already exists" << dendl;
+      return -EEXIST;
+    }
+
     string src_oid =
       old_format ? old_header_name(srcname) : id_obj_name(srcname);
     string dst_oid =
@@ -1250,17 +1261,6 @@ reprotect_and_return_err:
        last_read = outbl.rbegin()->first;
     } while (r == MAX_READ);
 
-    r = detect_format(io_ctx, dstname, NULL, NULL);
-    if (r < 0 && r != -ENOENT) {
-      lderr(cct) << "error checking for existing image called "
-                << dstname << ":" << cpp_strerror(r) << dendl;
-      return r;
-    }
-    if (r == 0) {
-      lderr(cct) << "rbd image " << dstname << " already exists" << dendl;
-      return -EEXIST;
-    }
-
     librados::ObjectWriteOperation op;
     op.create(true);
     op.write_full(databl);