]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw: guard against racing writes
authorYehuda Sadeh <yehuda@redhat.com>
Tue, 16 Dec 2014 05:30:36 +0000 (21:30 -0800)
committerYehuda Sadeh <yehuda@redhat.com>
Fri, 16 Jan 2015 22:36:23 +0000 (14:36 -0800)
Signed-off-by: Yehuda Sadeh <yehuda@redhat.com>
src/rgw/rgw_rados.cc

index c875ef13b8f75ab8489ad9356defde8a5f9c153b..5aaf5c107425b35ec451fd35cae240b8aa0fb431 100644 (file)
@@ -5277,7 +5277,13 @@ int RGWRados::olh_init_modification_impl(void *ctx, rgw_obj& obj, string *obj_ta
 
   ObjectWriteOperation op;
 
-  if (!astate->exists) {
+  bool curr_olh = is_olh(s->attrset);
+
+  if (astate->exists) {
+    op.cmpxattr(RGW_ATTR_ID_TAG, CEPH_OSD_CMPXATTR_OP_EQ, astate->obj_tag);
+  }
+
+  if (!astate->exists || !curr_olh) {
     /* generate a new object tag */
     op.create(true);
     int ret = gen_rand_alphanumeric_lower(cct, obj_tag, 32);