From ab2b45aa184ed3e2b48a98853b6eea87bfc2b31b Mon Sep 17 00:00:00 2001 From: Casey Bodley Date: Tue, 26 Jul 2022 17:25:32 -0400 Subject: rgw/rados: pass obj_lock_enabled into RGWRados::create_bucket there's a retry loop here that may end up overwriting RGWBucketInfo, so pass obj_lock_enabled and use it to update info.flags on each iteration Signed-off-by: Casey Bodley --- src/rgw/driver/rados/rgw_rados.cc | 4 ++++ src/rgw/driver/rados/rgw_rados.h | 1 + src/rgw/driver/rados/rgw_sal_rados.cc | 13 ++++--------- 3 files changed, 9 insertions(+), 9 deletions(-) (limited to 'src/rgw/driver/rados') diff --git a/src/rgw/driver/rados/rgw_rados.cc b/src/rgw/driver/rados/rgw_rados.cc index 2df4f77b673..e2754eead72 100644 --- a/src/rgw/driver/rados/rgw_rados.cc +++ b/src/rgw/driver/rados/rgw_rados.cc @@ -2276,6 +2276,7 @@ int RGWRados::create_bucket(const RGWUserInfo& owner, rgw_bucket& bucket, const string& zonegroup_id, const rgw_placement_rule& placement_rule, const string& swift_ver_location, + bool obj_lock_enabled, const RGWQuotaInfo * pquota_info, map& attrs, RGWBucketInfo& info, @@ -2322,6 +2323,9 @@ int RGWRados::create_bucket(const RGWUserInfo& owner, rgw_bucket& bucket, info.placement_rule = selected_placement_rule; info.swift_ver_location = swift_ver_location; info.swift_versioning = (!swift_ver_location.empty()); + if (obj_lock_enabled) { + info.flags |= BUCKET_VERSIONED | BUCKET_OBJ_LOCK_ENABLED; + } init_default_bucket_layout(cct, info.layout, svc.zone->get_zone(), rule_info.index_type); diff --git a/src/rgw/driver/rados/rgw_rados.h b/src/rgw/driver/rados/rgw_rados.h index d312e7355e2..1727bd84758 100644 --- a/src/rgw/driver/rados/rgw_rados.h +++ b/src/rgw/driver/rados/rgw_rados.h @@ -632,6 +632,7 @@ public: const std::string& zonegroup_id, const rgw_placement_rule& placement_rule, const std::string& swift_ver_location, + bool obj_lock_enabled, const RGWQuotaInfo * pquota_info, std::map& attrs, RGWBucketInfo& bucket_info, diff --git a/src/rgw/driver/rados/rgw_sal_rados.cc b/src/rgw/driver/rados/rgw_sal_rados.cc index b7a7732388b..bc6efa46196 100644 --- a/src/rgw/driver/rados/rgw_sal_rados.cc +++ b/src/rgw/driver/rados/rgw_sal_rados.cc @@ -140,7 +140,7 @@ int RadosUser::create_bucket(const DoutPrefixProvider* dpp, int ret; bufferlist in_data; RGWBucketInfo master_info; - rgw_bucket* pmaster_bucket; + rgw_bucket* pmaster_bucket = nullptr; real_time creation_time; std::unique_ptr bucket; obj_version objv,* pobjv = NULL; @@ -174,13 +174,7 @@ int RadosUser::create_bucket(const DoutPrefixProvider* dpp, pmaster_bucket= &master_info.bucket; creation_time = master_info.creation_time; pobjv = &objv; - if (master_info.obj_lock_enabled()) { - info.flags = BUCKET_VERSIONED | BUCKET_OBJ_LOCK_ENABLED; - } - } else { - pmaster_bucket = NULL; - if (obj_lock_enabled) - info.flags = BUCKET_VERSIONED | BUCKET_OBJ_LOCK_ENABLED; + obj_lock_enabled = master_info.obj_lock_enabled(); } std::string zid = zonegroup_id; @@ -201,7 +195,8 @@ int RadosUser::create_bucket(const DoutPrefixProvider* dpp, } else { ret = store->getRados()->create_bucket(this->get_info(), bucket->get_key(), - zid, placement_rule, swift_ver_location, pquota_info, + zid, placement_rule, swift_ver_location, + obj_lock_enabled, pquota_info, attrs, info, pobjv, &ep_objv, creation_time, pmaster_bucket, y, dpp, exclusive); if (ret == -EEXIST) { -- cgit v1.2.3