From: Casey Bodley Date: Tue, 26 Jul 2022 20:05:51 +0000 (-0400) Subject: rgw: read existing placement and swift_ver_location outside of sal X-Git-Tag: v19.0.0~122^2~15 X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=6decabf0a2f0d5c78dc22024103a19daa3d2f72b;p=ceph-ci.git rgw: read existing placement and swift_ver_location outside of sal Signed-off-by: Casey Bodley --- diff --git a/src/rgw/driver/d4n/rgw_sal_d4n.cc b/src/rgw/driver/d4n/rgw_sal_d4n.cc index 3195d87eac4..93cd8f2d415 100644 --- a/src/rgw/driver/d4n/rgw_sal_d4n.cc +++ b/src/rgw/driver/d4n/rgw_sal_d4n.cc @@ -62,8 +62,8 @@ std::unique_ptr D4NFilterBucket::get_object(const rgw_obj_key& k) int D4NFilterUser::create_bucket(const DoutPrefixProvider* dpp, const rgw_bucket& b, const std::string& zonegroup_id, - rgw_placement_rule& placement_rule, - std::string& swift_ver_location, + const rgw_placement_rule& placement_rule, + const std::string& swift_ver_location, const RGWQuotaInfo * pquota_info, const RGWAccessControlPolicy& policy, Attrs& attrs, diff --git a/src/rgw/driver/d4n/rgw_sal_d4n.h b/src/rgw/driver/d4n/rgw_sal_d4n.h index 5a2cd88896d..459e885fc24 100644 --- a/src/rgw/driver/d4n/rgw_sal_d4n.h +++ b/src/rgw/driver/d4n/rgw_sal_d4n.h @@ -75,8 +75,8 @@ class D4NFilterUser : public FilterUser { virtual int create_bucket(const DoutPrefixProvider* dpp, const rgw_bucket& b, const std::string& zonegroup_id, - rgw_placement_rule& placement_rule, - std::string& swift_ver_location, + const rgw_placement_rule& placement_rule, + const std::string& swift_ver_location, const RGWQuotaInfo* pquota_info, const RGWAccessControlPolicy& policy, Attrs& attrs, diff --git a/src/rgw/driver/motr/rgw_sal_motr.cc b/src/rgw/driver/motr/rgw_sal_motr.cc index e9377f94536..156fb6d6031 100644 --- a/src/rgw/driver/motr/rgw_sal_motr.cc +++ b/src/rgw/driver/motr/rgw_sal_motr.cc @@ -210,8 +210,8 @@ int MotrUser::list_buckets(const DoutPrefixProvider *dpp, const string& marker, int MotrUser::create_bucket(const DoutPrefixProvider* dpp, const rgw_bucket& b, const std::string& zonegroup_id, - rgw_placement_rule& placement_rule, - std::string& swift_ver_location, + const rgw_placement_rule& placement_rule, + const std::string& swift_ver_location, const RGWQuotaInfo* pquota_info, const RGWAccessControlPolicy& policy, Attrs& attrs, @@ -234,24 +234,7 @@ int MotrUser::create_bucket(const DoutPrefixProvider* dpp, if (ret != -ENOENT) { *existed = true; - // if (swift_ver_location.empty()) { - // swift_ver_location = bucket->get_info().swift_ver_location; - // } - // placement_rule.inherit_from(bucket->get_info().placement_rule); - - // TODO: ACL policy - // // don't allow changes to the acl policy - //RGWAccessControlPolicy old_policy(ctx()); - //int rc = rgw_op_get_bucket_policy_from_attr( - // dpp, this, u, bucket->get_attrs(), &old_policy, y); - //if (rc >= 0 && old_policy != policy) { - // bucket_out->swap(bucket); - // return -EEXIST; - //} } else { - - placement_rule.name = "default"; - placement_rule.storage_class = "STANDARD"; bucket = std::make_unique(store, b, this); bucket->set_attrs(attrs); *existed = false; diff --git a/src/rgw/driver/motr/rgw_sal_motr.h b/src/rgw/driver/motr/rgw_sal_motr.h index 6e6b9908061..23854b466de 100644 --- a/src/rgw/driver/motr/rgw_sal_motr.h +++ b/src/rgw/driver/motr/rgw_sal_motr.h @@ -222,8 +222,8 @@ class MotrUser : public StoreUser { virtual int create_bucket(const DoutPrefixProvider* dpp, const rgw_bucket& b, const std::string& zonegroup_id, - rgw_placement_rule& placement_rule, - std::string& swift_ver_location, + const rgw_placement_rule& placement_rule, + const std::string& swift_ver_location, const RGWQuotaInfo* pquota_info, const RGWAccessControlPolicy& policy, Attrs& attrs, diff --git a/src/rgw/driver/posix/rgw_sal_posix.cc b/src/rgw/driver/posix/rgw_sal_posix.cc index b999839bf4e..0831ebd97c5 100644 --- a/src/rgw/driver/posix/rgw_sal_posix.cc +++ b/src/rgw/driver/posix/rgw_sal_posix.cc @@ -594,8 +594,8 @@ int POSIXUser::list_buckets(const DoutPrefixProvider* dpp, const std::string& ma int POSIXUser::create_bucket(const DoutPrefixProvider* dpp, const rgw_bucket& b, const std::string& zonegroup_id, - rgw_placement_rule& placement_rule, - std::string& swift_ver_location, + const rgw_placement_rule& placement_rule, + const std::string& swift_ver_location, const RGWQuotaInfo * pquota_info, const RGWAccessControlPolicy& policy, Attrs& attrs, diff --git a/src/rgw/driver/posix/rgw_sal_posix.h b/src/rgw/driver/posix/rgw_sal_posix.h index 3695763c45f..f78bbadbfe9 100644 --- a/src/rgw/driver/posix/rgw_sal_posix.h +++ b/src/rgw/driver/posix/rgw_sal_posix.h @@ -128,8 +128,8 @@ public: virtual int create_bucket(const DoutPrefixProvider* dpp, const rgw_bucket& b, const std::string& zonegroup_id, - rgw_placement_rule& placement_rule, - std::string& swift_ver_location, + const rgw_placement_rule& placement_rule, + const std::string& swift_ver_location, const RGWQuotaInfo* pquota_info, const RGWAccessControlPolicy& policy, Attrs& attrs, diff --git a/src/rgw/driver/rados/rgw_sal_rados.cc b/src/rgw/driver/rados/rgw_sal_rados.cc index 4cc3ab5972b..b7a7732388b 100644 --- a/src/rgw/driver/rados/rgw_sal_rados.cc +++ b/src/rgw/driver/rados/rgw_sal_rados.cc @@ -123,8 +123,8 @@ int RadosUser::list_buckets(const DoutPrefixProvider* dpp, const std::string& ma int RadosUser::create_bucket(const DoutPrefixProvider* dpp, const rgw_bucket& b, const std::string& zonegroup_id, - rgw_placement_rule& placement_rule, - std::string& swift_ver_location, + const rgw_placement_rule& placement_rule, + const std::string& swift_ver_location, const RGWQuotaInfo * pquota_info, const RGWAccessControlPolicy& policy, Attrs& attrs, @@ -152,10 +152,6 @@ int RadosUser::create_bucket(const DoutPrefixProvider* dpp, if (ret != -ENOENT) { *existed = true; - if (swift_ver_location.empty()) { - swift_ver_location = bucket->get_info().swift_ver_location; - } - placement_rule.inherit_from(bucket->get_info().placement_rule); } else { bucket = std::unique_ptr(new RadosBucket(store, b, this)); *existed = false; diff --git a/src/rgw/driver/rados/rgw_sal_rados.h b/src/rgw/driver/rados/rgw_sal_rados.h index ebf6531f147..f542a68d047 100644 --- a/src/rgw/driver/rados/rgw_sal_rados.h +++ b/src/rgw/driver/rados/rgw_sal_rados.h @@ -277,8 +277,8 @@ class RadosUser : public StoreUser { virtual int create_bucket(const DoutPrefixProvider* dpp, const rgw_bucket& b, const std::string& zonegroup_id, - rgw_placement_rule& placement_rule, - std::string& swift_ver_location, + const rgw_placement_rule& placement_rule, + const std::string& swift_ver_location, const RGWQuotaInfo * pquota_info, const RGWAccessControlPolicy& policy, Attrs& attrs, diff --git a/src/rgw/rgw_op.cc b/src/rgw/rgw_op.cc index 0307658aa0a..6f42f03a118 100644 --- a/src/rgw/rgw_op.cc +++ b/src/rgw/rgw_op.cc @@ -3384,6 +3384,11 @@ void RGWCreateBucket::execute(optional_yield y) /* Initialize info from req_state */ info = tmp_bucket->get_info(); + if (!swift_ver_location) { + swift_ver_location = info.swift_ver_location; + } + placement_rule.inherit_from(info.placement_rule); + // don't allow changes to the acl policy RGWAccessControlPolicy old_policy(get_cct()); int r = rgw_op_get_bucket_policy_from_attr(this, s->cct, driver, info.owner, diff --git a/src/rgw/rgw_sal.h b/src/rgw/rgw_sal.h index 73122e06b4b..d8072ca6f6f 100644 --- a/src/rgw/rgw_sal.h +++ b/src/rgw/rgw_sal.h @@ -491,8 +491,8 @@ class User { virtual int create_bucket(const DoutPrefixProvider* dpp, const rgw_bucket& b, const std::string& zonegroup_id, - rgw_placement_rule& placement_rule, - std::string& swift_ver_location, + const rgw_placement_rule& placement_rule, + const std::string& swift_ver_location, const RGWQuotaInfo* pquota_info, const RGWAccessControlPolicy& policy, Attrs& attrs, diff --git a/src/rgw/rgw_sal_dbstore.cc b/src/rgw/rgw_sal_dbstore.cc index 97da47eb6d3..5e429ba5c4c 100644 --- a/src/rgw/rgw_sal_dbstore.cc +++ b/src/rgw/rgw_sal_dbstore.cc @@ -61,8 +61,8 @@ namespace rgw::sal { int DBUser::create_bucket(const DoutPrefixProvider *dpp, const rgw_bucket& b, const string& zonegroup_id, - rgw_placement_rule& placement_rule, - string& swift_ver_location, + const rgw_placement_rule& placement_rule, + const string& swift_ver_location, const RGWQuotaInfo * pquota_info, const RGWAccessControlPolicy& policy, Attrs& attrs, @@ -79,7 +79,6 @@ namespace rgw::sal { bufferlist in_data; RGWBucketInfo master_info; rgw_bucket *pmaster_bucket = nullptr; - uint32_t *pmaster_num_shards = nullptr; real_time creation_time; std::unique_ptr bucket; obj_version objv, *pobjv = NULL; @@ -90,28 +89,11 @@ namespace rgw::sal { return ret; if (ret != -ENOENT) { - RGWAccessControlPolicy old_policy(store->ctx()); *existed = true; - if (swift_ver_location.empty()) { - swift_ver_location = bucket->get_info().swift_ver_location; - } - placement_rule.inherit_from(bucket->get_info().placement_rule); - - // don't allow changes to the acl policy - /* int r = rgw_op_get_bucket_policy_from_attr(dpp, this, this, bucket->get_attrs(), - &old_policy, y); - if (r >= 0 && old_policy != policy) { - bucket_out->swap(bucket); - return -EEXIST; - }*/ } else { bucket = std::make_unique(store, b, this); *existed = false; bucket->set_attrs(attrs); - // XXX: For now single default zone and STANDARD storage class - // supported. - placement_rule.name = "default"; - placement_rule.storage_class = "STANDARD"; } /* @@ -123,8 +105,13 @@ namespace rgw::sal { zid = svc()->zone->get_zonegroup().get_id(); } */ + // XXX: For now single default zone and STANDARD storage class + // supported. + rgw_placement_rule selected_placement_rule; + selected_placement_rule.name = "default"; + selected_placement_rule.storage_class = "STANDARD"; + if (*existed) { - rgw_placement_rule selected_placement_rule; /* XXX: Handle this when zone is implemented ret = svc()->zone->select_bucket_placement(this.get_info(), zid, placement_rule, @@ -138,9 +125,9 @@ namespace rgw::sal { /* XXX: We may not need to send all these params. Cleanup the unused ones */ ret = store->getDB()->create_bucket(dpp, this->get_info(), bucket->get_key(), - zid, placement_rule, swift_ver_location, pquota_info, + zid, selected_placement_rule, swift_ver_location, pquota_info, attrs, info, pobjv, &ep_objv, creation_time, - pmaster_bucket, pmaster_num_shards, y, exclusive); + pmaster_bucket, nullptr, y, exclusive); if (ret == -EEXIST) { *existed = true; ret = 0; diff --git a/src/rgw/rgw_sal_dbstore.h b/src/rgw/rgw_sal_dbstore.h index 68fe4c44319..375a4524517 100644 --- a/src/rgw/rgw_sal_dbstore.h +++ b/src/rgw/rgw_sal_dbstore.h @@ -91,8 +91,8 @@ protected: virtual int create_bucket(const DoutPrefixProvider* dpp, const rgw_bucket& b, const std::string& zonegroup_id, - rgw_placement_rule& placement_rule, - std::string& swift_ver_location, + const rgw_placement_rule& placement_rule, + const std::string& swift_ver_location, const RGWQuotaInfo* pquota_info, const RGWAccessControlPolicy& policy, Attrs& attrs, diff --git a/src/rgw/rgw_sal_filter.cc b/src/rgw/rgw_sal_filter.cc index fb9e7aa1a28..3f3c5102cb4 100644 --- a/src/rgw/rgw_sal_filter.cc +++ b/src/rgw/rgw_sal_filter.cc @@ -543,8 +543,8 @@ int FilterUser::list_buckets(const DoutPrefixProvider* dpp, const std::string& m int FilterUser::create_bucket(const DoutPrefixProvider* dpp, const rgw_bucket& b, const std::string& zonegroup_id, - rgw_placement_rule& placement_rule, - std::string& swift_ver_location, + const rgw_placement_rule& placement_rule, + const std::string& swift_ver_location, const RGWQuotaInfo * pquota_info, const RGWAccessControlPolicy& policy, Attrs& attrs, diff --git a/src/rgw/rgw_sal_filter.h b/src/rgw/rgw_sal_filter.h index 81452f22cd7..5d81bea0e42 100644 --- a/src/rgw/rgw_sal_filter.h +++ b/src/rgw/rgw_sal_filter.h @@ -332,8 +332,8 @@ public: virtual int create_bucket(const DoutPrefixProvider* dpp, const rgw_bucket& b, const std::string& zonegroup_id, - rgw_placement_rule& placement_rule, - std::string& swift_ver_location, + const rgw_placement_rule& placement_rule, + const std::string& swift_ver_location, const RGWQuotaInfo* pquota_info, const RGWAccessControlPolicy& policy, Attrs& attrs, diff --git a/src/test/rgw/test_rgw_lua.cc b/src/test/rgw/test_rgw_lua.cc index e8656ac8e39..05f0d291961 100644 --- a/src/test/rgw/test_rgw_lua.cc +++ b/src/test/rgw/test_rgw_lua.cc @@ -78,7 +78,7 @@ public: return 0; } - virtual int create_bucket(const DoutPrefixProvider* dpp, const rgw_bucket& b, const std::string& zonegroup_id, rgw_placement_rule& placement_rule, std::string& swift_ver_location, const RGWQuotaInfo* pquota_info, const RGWAccessControlPolicy& policy, sal::Attrs& attrs, RGWBucketInfo& info, obj_version& ep_objv, bool exclusive, bool obj_lock_enabled, bool* existed, req_info& req_info, std::unique_ptr* bucket, optional_yield y) override { + virtual int create_bucket(const DoutPrefixProvider* dpp, const rgw_bucket& b, const std::string& zonegroup_id, const rgw_placement_rule& placement_rule, const std::string& swift_ver_location, const RGWQuotaInfo* pquota_info, const RGWAccessControlPolicy& policy, sal::Attrs& attrs, RGWBucketInfo& info, obj_version& ep_objv, bool exclusive, bool obj_lock_enabled, bool* existed, req_info& req_info, std::unique_ptr* bucket, optional_yield y) override { return 0; }