]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
osd/ReplicatedPG: check obs.exists for CEPH_OSD_OP_CMPXATTR/SRC_CMPXATTR. 5961/head
authorJianpeng Ma <jianpeng.ma@intel.com>
Fri, 18 Dec 2015 15:48:04 +0000 (23:48 +0800)
committerJianpeng Ma <jianpeng.ma@intel.com>
Fri, 18 Dec 2015 15:48:04 +0000 (23:48 +0800)
We may use those ops(CMPXATTR, WRITE, SET_XATTR) to do a write. Using
CMPXATTR to indiate whether to write. But if object don't exist, because
the ops is writeable(because WRITE, SET_XATTR), so it can do CMPXATTR.
But at this situation, the func getattr_maybe_cache return -ENOENT.
For optimization, we first check obs.exists.

Signed-off-by: Jianpeng Ma <jianpeng.ma@intel.com>
src/osd/ReplicatedPG.cc

index 52340caa51a2461bb00c824112b453875c29b39f..c631c847cbbd596b4dde0ed06248003cd4dc71dc 100644 (file)
@@ -4498,21 +4498,23 @@ int ReplicatedPG::do_osd_ops(OpContext *ctx, vector<OSDOp>& ops)
        name[op.xattr.name_len + 1] = 0;
        
        bufferlist xattr;
-       if (op.op == CEPH_OSD_OP_CMPXATTR)
-         result = getattr_maybe_cache(
-           ctx->obc,
-           name,
-           &xattr);
-       else
-         result = getattr_maybe_cache(
-           src_obc,
-           name,
-           &xattr);
-       if (result < 0 && result != -ENODATA)
-         break;
-       
-       ctx->delta_stats.num_rd++;
-       ctx->delta_stats.num_rd_kb += SHIFT_ROUND_UP(xattr.length(), 10);
+       if (obs.exists) {
+         if (op.op == CEPH_OSD_OP_CMPXATTR)
+           result = getattr_maybe_cache(
+               ctx->obc,
+               name,
+               &xattr);
+         else
+           result = getattr_maybe_cache(
+               src_obc,
+               name,
+               &xattr);
+         if (result < 0 && result != -ENODATA)
+           break;
+
+         ctx->delta_stats.num_rd++;
+         ctx->delta_stats.num_rd_kb += SHIFT_ROUND_UP(xattr.length(), 10);
+       }
 
        switch (op.xattr.cmp_mode) {
        case CEPH_OSD_CMPXATTR_MODE_STRING: