From: Matt Benjamin Date: Tue, 2 Aug 2022 11:52:27 +0000 (-0400) Subject: rgwlc/sync: avoid calling merge-and-store-attrs from remove_bucket_config() X-Git-Tag: v18.0.0~270^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=7dd245af49ce7d5c2d51ddf8f7890c128c32cd51;p=ceph.git rgwlc/sync: avoid calling merge-and-store-attrs from remove_bucket_config() 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 --- diff --git a/src/rgw/rgw_bucket.cc b/src/rgw/rgw_bucket.cc index cf34fd512514..ae4ec9b50edf 100644 --- a/src/rgw/rgw_bucket.cc +++ b/src/rgw/rgw_bucket.cc @@ -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 diff --git a/src/rgw/rgw_lc.cc b/src/rgw/rgw_lc.cc index 08f705d5e8b9..cb002b09b2b5 100644 --- a/src/rgw/rgw_lc.cc +++ b/src/rgw/rgw_lc.cc @@ -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, diff --git a/src/rgw/rgw_lc.h b/src/rgw/rgw_lc.h index 8b3ab7c71d1a..14bcb3b26665 100644 --- a/src/rgw/rgw_lc.h +++ b/src/rgw/rgw_lc.h @@ -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(); }