]> git-server-git.apps.pok.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)
committerYehuda Sadeh <yehuda@redhat.com>
Mon, 13 Apr 2015 23:15:56 +0000 (16:15 -0700)
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>
src/rgw/rgw_rados.cc

index 3f65f8295ec7f686c16559e51eb2decb97f2a7ce..865829c31ec33c8ec13271b4325e22df26a62483 100644 (file)
@@ -4902,13 +4902,22 @@ 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);
 
   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);
@@ -4936,6 +4945,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);