From: Yehuda Sadeh Date: Fri, 27 Mar 2015 23:32:48 +0000 (-0700) Subject: rgw: generate new tag for object when setting object attrs X-Git-Tag: v0.94.1.2~13 X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=10013a90b03ff317f7cae7944b2561a504c4718d;p=ceph.git rgw: generate new tag for object when setting object attrs 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 (cherry picked from commit edc0627a1dbeb66ea2f5f177f6ceca64559ff3d8) --- diff --git a/src/rgw/rgw_rados.cc b/src/rgw/rgw_rados.cc index b6ca4bd101188..b39c076873a89 100644 --- a/src/rgw/rgw_rados.cc +++ b/src/rgw/rgw_rados.cc @@ -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);