From: Casey Bodley Date: Mon, 18 Sep 2023 15:15:02 +0000 (-0400) Subject: rgw/sal: get_placement_target_names() returns void X-Git-Tag: v19.0.0~444^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=3ad17ed3b222701bb6f4e3150989584645789d7c;p=ceph.git rgw/sal: get_placement_target_names() returns void the function returned an integer error code, but two callers were incorrectly testing the return value as a boolean the function just returns placement ids that are in-memory, so none of the drivers have a failure case; change the return value to void Fixes: https://tracker.ceph.com/issues/62771 Signed-off-by: Casey Bodley --- diff --git a/src/rgw/driver/daos/rgw_sal_daos.cc b/src/rgw/driver/daos/rgw_sal_daos.cc index a8663805d828..862eb86315cf 100644 --- a/src/rgw/driver/daos/rgw_sal_daos.cc +++ b/src/rgw/driver/daos/rgw_sal_daos.cc @@ -826,13 +826,11 @@ bool DaosZoneGroup::placement_target_exists(std::string& target) const { return !!group.placement_targets.count(target); } -int DaosZoneGroup::get_placement_target_names( +void DaosZoneGroup::get_placement_target_names( std::set& names) const { for (const auto& target : group.placement_targets) { names.emplace(target.second.name); } - - return 0; } int DaosZoneGroup::get_placement_tier(const rgw_placement_rule& rule, diff --git a/src/rgw/driver/daos/rgw_sal_daos.h b/src/rgw/driver/daos/rgw_sal_daos.h index ac7352191f23..3a8f34ce91c9 100644 --- a/src/rgw/driver/daos/rgw_sal_daos.h +++ b/src/rgw/driver/daos/rgw_sal_daos.h @@ -414,7 +414,7 @@ class DaosZoneGroup : public StoreZoneGroup { virtual const std::string& get_api_name() const override { return group.api_name; }; - virtual int get_placement_target_names( + virtual void get_placement_target_names( std::set& names) const override; virtual const std::string& get_default_placement_name() const override { return group.default_placement.name; diff --git a/src/rgw/driver/motr/rgw_sal_motr.cc b/src/rgw/driver/motr/rgw_sal_motr.cc index a1bca8b5696d..b951d0080e4d 100644 --- a/src/rgw/driver/motr/rgw_sal_motr.cc +++ b/src/rgw/driver/motr/rgw_sal_motr.cc @@ -1086,13 +1086,11 @@ bool MotrZoneGroup::placement_target_exists(std::string& target) const return !!group.placement_targets.count(target); } -int MotrZoneGroup::get_placement_target_names(std::set& names) const +void MotrZoneGroup::get_placement_target_names(std::set& names) const { for (const auto& target : group.placement_targets) { names.emplace(target.second.name); } - - return 0; } int MotrZoneGroup::get_placement_tier(const rgw_placement_rule& rule, diff --git a/src/rgw/driver/motr/rgw_sal_motr.h b/src/rgw/driver/motr/rgw_sal_motr.h index 153ac8abd005..a14f8e30f8ba 100644 --- a/src/rgw/driver/motr/rgw_sal_motr.h +++ b/src/rgw/driver/motr/rgw_sal_motr.h @@ -446,7 +446,7 @@ public: return group.is_master_zonegroup(); }; virtual const std::string& get_api_name() const override { return group.api_name; }; - virtual int get_placement_target_names(std::set& names) const override; + virtual void get_placement_target_names(std::set& names) const override; virtual const std::string& get_default_placement_name() const override { return group.default_placement.name; }; virtual int get_hostnames(std::list& names) const override { diff --git a/src/rgw/driver/rados/rgw_sal_rados.cc b/src/rgw/driver/rados/rgw_sal_rados.cc index 01f642a38702..ebac3bb8cf9b 100644 --- a/src/rgw/driver/rados/rgw_sal_rados.cc +++ b/src/rgw/driver/rados/rgw_sal_rados.cc @@ -3192,13 +3192,11 @@ bool RadosZoneGroup::placement_target_exists(std::string& target) const return !!group.placement_targets.count(target); } -int RadosZoneGroup::get_placement_target_names(std::set& names) const +void RadosZoneGroup::get_placement_target_names(std::set& names) const { for (const auto& target : group.placement_targets) { names.emplace(target.second.name); } - - return 0; } int RadosZoneGroup::get_placement_tier(const rgw_placement_rule& rule, diff --git a/src/rgw/driver/rados/rgw_sal_rados.h b/src/rgw/driver/rados/rgw_sal_rados.h index cdb4ad95e21d..c84a18ee45f3 100644 --- a/src/rgw/driver/rados/rgw_sal_rados.h +++ b/src/rgw/driver/rados/rgw_sal_rados.h @@ -62,7 +62,7 @@ public: return group.is_master_zonegroup(); }; virtual const std::string& get_api_name() const override { return group.api_name; }; - virtual int get_placement_target_names(std::set& names) const override; + virtual void get_placement_target_names(std::set& names) const override; virtual const std::string& get_default_placement_name() const override { return group.default_placement.name; }; virtual int get_hostnames(std::list& names) const override { diff --git a/src/rgw/rgw_op.cc b/src/rgw/rgw_op.cc index 5afc4a72a0ae..5de07969deb2 100644 --- a/src/rgw/rgw_op.cc +++ b/src/rgw/rgw_op.cc @@ -2527,10 +2527,9 @@ void RGWListBuckets::execute(optional_yield y) * isn't actually used in a given account. In such situation its usage * stats would be simply full of zeros. */ std::set targets; - if (driver->get_zone()->get_zonegroup().get_placement_target_names(targets)) { - for (const auto& policy : targets) { - policies_stats.emplace(policy, decltype(policies_stats)::mapped_type()); - } + driver->get_zone()->get_zonegroup().get_placement_target_names(targets); + for (const auto& policy : targets) { + policies_stats.emplace(policy, decltype(policies_stats)::mapped_type()); } std::map>& m = buckets.get_buckets(); diff --git a/src/rgw/rgw_rest_swift.cc b/src/rgw/rgw_rest_swift.cc index 353520b52d80..ba2099f38ad2 100644 --- a/src/rgw/rgw_rest_swift.cc +++ b/src/rgw/rgw_rest_swift.cc @@ -1908,14 +1908,13 @@ void RGWInfo_ObjStore_SWIFT::list_swift_data(Formatter& formatter, const rgw::sal::ZoneGroup& zonegroup = driver->get_zone()->get_zonegroup(); std::set targets; - if (zonegroup.get_placement_target_names(targets)) { - for (const auto& placement_targets : targets) { - formatter.open_object_section("policy"); - if (placement_targets.compare(zonegroup.get_default_placement_name()) == 0) - formatter.dump_bool("default", true); - formatter.dump_string("name", placement_targets.c_str()); - formatter.close_section(); - } + zonegroup.get_placement_target_names(targets); + for (const auto& placement_targets : targets) { + formatter.open_object_section("policy"); + if (placement_targets.compare(zonegroup.get_default_placement_name()) == 0) + formatter.dump_bool("default", true); + formatter.dump_string("name", placement_targets.c_str()); + formatter.close_section(); } formatter.close_section(); diff --git a/src/rgw/rgw_sal.h b/src/rgw/rgw_sal.h index 3c33a6d51e17..253d36cb3b28 100644 --- a/src/rgw/rgw_sal.h +++ b/src/rgw/rgw_sal.h @@ -1477,7 +1477,7 @@ public: /** Get the API name of this zonegroup */ virtual const std::string& get_api_name() const = 0; /** Get the list of placement target names for this zone */ - virtual int get_placement_target_names(std::set& names) const = 0; + virtual void get_placement_target_names(std::set& names) const = 0; /** Get the name of the default placement target for this zone */ virtual const std::string& get_default_placement_name() const = 0; /** Get the list of hostnames from this zone */ diff --git a/src/rgw/rgw_sal_dbstore.cc b/src/rgw/rgw_sal_dbstore.cc index 80a619f122c1..143830fda51a 100644 --- a/src/rgw/rgw_sal_dbstore.cc +++ b/src/rgw/rgw_sal_dbstore.cc @@ -525,12 +525,10 @@ namespace rgw::sal { return !!group->placement_targets.count(target); } - int DBZoneGroup::get_placement_target_names(std::set& names) const { + void DBZoneGroup::get_placement_target_names(std::set& names) const { for (const auto& target : group->placement_targets) { names.emplace(target.second.name); } - - return 0; } ZoneGroup& DBZone::get_zonegroup() diff --git a/src/rgw/rgw_sal_dbstore.h b/src/rgw/rgw_sal_dbstore.h index 2c84f7098721..a6e140380e5c 100644 --- a/src/rgw/rgw_sal_dbstore.h +++ b/src/rgw/rgw_sal_dbstore.h @@ -270,7 +270,7 @@ protected: return group->is_master_zonegroup(); }; virtual const std::string& get_api_name() const override { return group->api_name; }; - virtual int get_placement_target_names(std::set& names) const override; + virtual void get_placement_target_names(std::set& names) const override; virtual const std::string& get_default_placement_name() const override { return group->default_placement.name; }; virtual int get_hostnames(std::list& names) const override { diff --git a/src/rgw/rgw_sal_filter.h b/src/rgw/rgw_sal_filter.h index f9ceff7f1a38..9776cd5c228d 100644 --- a/src/rgw/rgw_sal_filter.h +++ b/src/rgw/rgw_sal_filter.h @@ -58,8 +58,8 @@ public: { return next->is_master_zonegroup(); } virtual const std::string& get_api_name() const override { return next->get_api_name(); } - virtual int get_placement_target_names(std::set& names) const override - { return next->get_placement_target_names(names); } + virtual void get_placement_target_names(std::set& names) const override + { next->get_placement_target_names(names); } virtual const std::string& get_default_placement_name() const override { return next->get_default_placement_name(); } virtual int get_hostnames(std::list& names) const override