]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
rgwlc/sync: avoid calling merge-and-store-attrs from remove_bucket_config() 47411/head
authorMatt Benjamin <mbenjamin@redhat.com>
Tue, 2 Aug 2022 11:52:27 +0000 (07:52 -0400)
committerMatt Benjamin <mbenjamin@redhat.com>
Tue, 2 Aug 2022 11:52:27 +0000 (07:52 -0400)
Calling merge-and-store attrs turns out to be unsafe from the context of
the metadata sync handler--although I am doubtful that really *should* be
the case.

Fixes: https://tracker.ceph.com/issues/56997
Signed-off-by: Matt Benjamin <mbenjamin@redhat.com>
src/rgw/rgw_bucket.cc
src/rgw/rgw_lc.cc
src/rgw/rgw_lc.h

index cf34fd512514f845d8a55393dcb24471df2d5667..ae4ec9b50edfca26e1ad0a331b8335168acb326c 100644 (file)
@@ -2400,7 +2400,7 @@ int RGWMetadataHandlerPut_BucketInstance::put_post(const DoutPrefixProvider *dpp
 
     } else {
       ldpp_dout(dpp, 20) << "remove lc config for " << bci.info.bucket.name << dendl;
-      ret = lc->remove_bucket_config(bucket.get(), bci.attrs);
+      ret = lc->remove_bucket_config(bucket.get(), bci.attrs, false /* cannot merge attrs */);
       if (ret < 0) {
              ldpp_dout(dpp, 0) << __func__ << " failed to remove lc config for "
                        << bci.info.bucket.name
index 08f705d5e8b9af55f9cd1e86f61b4d3f6e2b9785..cb002b09b2b539692e56089a61fc5893241c101d 100644 (file)
@@ -2480,20 +2480,23 @@ int RGWLC::set_bucket_config(rgw::sal::Bucket* bucket,
 }
 
 int RGWLC::remove_bucket_config(rgw::sal::Bucket* bucket,
-                                const rgw::sal::Attrs& bucket_attrs)
+                                const rgw::sal::Attrs& bucket_attrs,
+                               bool merge_attrs)
 {
   rgw::sal::Attrs attrs = bucket_attrs;
-  attrs.erase(RGW_ATTR_LC);
-  int ret = bucket->merge_and_store_attrs(this, attrs, null_yield);
-
   rgw_bucket& b = bucket->get_key();
+  int ret{0};
 
-  if (ret < 0) {
-    ldpp_dout(this, 0) << "RGWLC::RGWDeleteLC() failed to set attrs on bucket="
-        << b.name << " returned err=" << ret << dendl;
-    return ret;
-  }
+  if (merge_attrs) {
+    attrs.erase(RGW_ATTR_LC);
+    ret = bucket->merge_and_store_attrs(this, attrs, null_yield);
 
+    if (ret < 0) {
+      ldpp_dout(this, 0) << "RGWLC::RGWDeleteLC() failed to set attrs on bucket="
+                        << b.name << " returned err=" << ret << dendl;
+      return ret;
+    }
+  }
 
   ret = guard_lc_modify(this, store, sal_lc.get(), b, cookie,
                        [&](rgw::sal::Lifecycle* sal_lc, const string& oid,
index 8b3ab7c71d1ab5a439cab47f288e21bd2bf153d7..14bcb3b266654218ecd3c29fdd41023bf4b22262 100644 (file)
@@ -601,7 +601,8 @@ public:
                         const rgw::sal::Attrs& bucket_attrs,
                         RGWLifecycleConfiguration *config);
   int remove_bucket_config(rgw::sal::Bucket* bucket,
-                           const rgw::sal::Attrs& bucket_attrs);
+                           const rgw::sal::Attrs& bucket_attrs,
+                          bool merge_attrs = true);
 
   CephContext *get_cct() const override { return cct; }
   rgw::sal::Lifecycle* get_lc() const { return sal_lc.get(); }