]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw: generate new tag for object when setting object attrs
authorYehuda Sadeh <yehuda@redhat.com>
Fri, 27 Mar 2015 23:32:48 +0000 (16:32 -0700)
committerKen Dreyer <kdreyer@redhat.com>
Mon, 4 May 2015 18:54:10 +0000 (12:54 -0600)
Fixes: #11256
Backport: firefly, hammer

Beforehand we were reusing the object's tag, which is problematic as
this tag is used for bucket index updates, and we might be clobbering a
racing update (like object removal).

Signed-off-by: Yehuda Sadeh <yehuda@redhat.com>
(cherry picked from commit edc0627a1dbeb66ea2f5f177f6ceca64559ff3d8)

src/rgw/rgw_rados.cc

index b6ca4bd101188440869236e818911fdde6635f8e..b39c076873a89e5651f4f01ba7c4638bc34610e1 100644 (file)
@@ -4882,14 +4882,23 @@ int RGWRados::set_attrs(void *ctx, rgw_obj& obj,
   if (!op.size())
     return 0;
 
+  bufferlist bl;
   RGWRados::Bucket bop(this, bucket);
   RGWRados::Bucket::UpdateIndex index_op(&bop, obj, state);
 
   string tag;
   if (state) {
+    string tag;
+    append_rand_alpha(cct, tag, tag, 32);
+    state->write_tag = tag;
     r = index_op.prepare(CLS_RGW_OP_ADD);
+
     if (r < 0)
       return r;
+
+    bl.append(tag.c_str(), tag.size() + 1);
+
+    op.setxattr(RGW_ATTR_ID_TAG,  bl);
   }
 
   r = ref.ioctx.operate(ref.oid, &op);
@@ -4917,6 +4926,7 @@ int RGWRados::set_attrs(void *ctx, rgw_obj& obj,
     return r;
 
   if (state) {
+    state->obj_tag.swap(bl);
     if (rmattrs) {
       for (iter = rmattrs->begin(); iter != rmattrs->end(); ++iter) {
         state->attrset.erase(iter->first);