]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw: Don't erase bucket attributes on trim
authorAdam C. Emerson <aemerson@redhat.com>
Wed, 2 Feb 2022 20:53:41 +0000 (15:53 -0500)
committerCasey Bodley <cbodley@redhat.com>
Fri, 27 May 2022 19:47:33 +0000 (15:47 -0400)
Writing bucket instance info is surprising, as if you pass a null
pointer for the attributes, it just erases all the attributes.

To avoid disturbing users and other 'system objects', make a special
case that we can pass in explicitly.

Signed-off-by: Adam C. Emerson <aemerson@redhat.com>
src/rgw/rgw_tools.cc
src/rgw/rgw_tools.h
src/rgw/rgw_trim_bilog.cc

index a6ada43fd38704f56f5f6cd5c73daa8f2ec17fbb..84390c3eae3093891216016a78cd0f20c3e880ef 100644 (file)
@@ -101,6 +101,11 @@ int rgw_init_ioctx(const DoutPrefixProvider *dpp,
   return 0;
 }
 
+map<string, bufferlist>* no_change_attrs() {
+  static map<string, bufferlist> no_change;
+  return &no_change;
+}
+
 int rgw_put_system_obj(const DoutPrefixProvider *dpp, 
                        RGWSysObjectCtx& obj_ctx, const rgw_pool& pool, const string& oid, bufferlist& data, bool exclusive,
                        RGWObjVersionTracker *objv_tracker, real_time set_mtime, optional_yield y, map<string, bufferlist> *pattrs)
@@ -113,12 +118,22 @@ int rgw_put_system_obj(const DoutPrefixProvider *dpp,
   rgw_raw_obj obj(pool, oid);
 
   auto sysobj = obj_ctx.get_obj(obj);
-  int ret = sysobj.wop()
-                  .set_objv_tracker(objv_tracker)
-                  .set_exclusive(exclusive)
-                  .set_mtime(set_mtime)
-                  .set_attrs(*pattrs)
-                  .write(dpp, data, y);
+  int ret;
+
+  if (pattrs != no_change_attrs()) {
+    ret = sysobj.wop()
+      .set_objv_tracker(objv_tracker)
+      .set_exclusive(exclusive)
+      .set_mtime(set_mtime)
+      .set_attrs(*pattrs)
+      .write(dpp, data, y);
+  } else {
+    ret = sysobj.wop()
+      .set_objv_tracker(objv_tracker)
+      .set_exclusive(exclusive)
+      .set_mtime(set_mtime)
+      .write_data(dpp, data, y);
+  }
 
   return ret;
 }
index 28ff91835ee5b25a508c6501538a2ca3a6b9c4b7..3cfa11a493e4711738d3ac40e2f5945f63f6e07f 100644 (file)
@@ -257,4 +257,11 @@ using RGWDataAccessRef = std::shared_ptr<RGWDataAccess>;
 /// calls and error handling.
 void rgw_complete_aio_completion(librados::AioCompletion* c, int r);
 
+/// This returns a static, non-NULL pointer, recognized only by
+/// rgw_put_system_obj(). When supplied instead of the attributes, the
+/// attributes will be unmodified.
+///
+// (Currently providing nullptr will wipe all attributes.)
+
+std::map<std::string, ceph::buffer::list>* no_change_attrs();
 #endif
index 9a65c358bc1c67057f939742bfd28783602c1374..038d2a5a79e11b3455cacb216b872bd8b4d1156e 100644 (file)
@@ -729,7 +729,7 @@ int BucketTrimInstanceCR::operate(const DoutPrefixProvider *dpp)
        yield call(new RGWPutBucketInstanceInfoCR(
                     store->svc()->rados->get_async_processor(),
                     store, clean_info->first, false, {},
-                    nullptr, dpp));
+                    no_change_attrs(), dpp));
 
        // Raced, try again.
        if (retcode == -ECANCELED) {