]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw: rados->set_attrs() updates bucket index
authorYehuda Sadeh <yehuda@redhat.com>
Tue, 23 Sep 2014 19:43:55 +0000 (12:43 -0700)
committerYehuda Sadeh <yehuda@redhat.com>
Wed, 14 Jan 2015 23:51:44 +0000 (15:51 -0800)
Fixes: #5595
Backport: dumpling, firefly
We need to update the bucket index when updating object attrs, otherwise
we're missing meta changes that need to be registered. It also
solves issue of bucket index not knowing about object acl changes,
although this one still requires some more work.

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

src/rgw/rgw_rados.cc

index 139a3d498e120ce1e2ce3d8ec7b3f3cd6698d8f4..52f8a701f2dd135e8a8ba4ef773acacfe3b132fc 100644 (file)
@@ -4161,7 +4161,33 @@ int RGWRados::set_attrs(void *ctx, rgw_obj& obj,
   if (!op.size())
     return 0;
 
+  string tag;
+  if (state) {
+    r = prepare_update_index(state, bucket, CLS_RGW_OP_ADD, obj, tag);
+    if (r < 0)
+      return r;
+  }
+
   r = ref.ioctx.operate(ref.oid, &op);
+  if (state) {
+    if (r >= 0) {
+      bufferlist acl_bl = attrs[RGW_ATTR_ACL];
+      bufferlist etag_bl = attrs[RGW_ATTR_ETAG];
+      bufferlist content_type_bl = attrs[RGW_ATTR_CONTENT_TYPE];
+      string etag(etag_bl.c_str(), etag_bl.length());
+      string content_type(content_type_bl.c_str(), content_type_bl.length());
+      uint64_t epoch = ref.ioctx.get_last_version();
+      int64_t poolid = ref.ioctx.get_id();
+      utime_t mtime = ceph_clock_now(cct);
+      r = complete_update_index(bucket, obj.object, tag, poolid, epoch, state->size,
+                                mtime, etag, content_type, &acl_bl, RGW_OBJ_CATEGORY_MAIN, NULL);
+    } else {
+      int ret = complete_update_index_cancel(bucket, obj.object, tag);
+      if (ret < 0) {
+        ldout(cct, 0) << "ERROR: comlete_update_index_cancel() returned r=" << r << dendl;
+      }
+    }
+  }
   if (r < 0)
     return r;