From: Yuval Lifshitz Date: Mon, 27 Feb 2023 13:18:51 +0000 (+0200) Subject: rgw/notifications: use topic references instead of pointers X-Git-Tag: v18.1.0~258^2 X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=3f7a295533025823150190a95d298ba175207276;p=ceph-ci.git rgw/notifications: use topic references instead of pointers when passing topics to be populated by the functions Signed-off-by: Yuval Lifshitz --- diff --git a/src/rgw/driver/rados/rgw_notify.cc b/src/rgw/driver/rados/rgw_notify.cc index c20768a85ef..0821e69a939 100644 --- a/src/rgw/driver/rados/rgw_notify.cc +++ b/src/rgw/driver/rados/rgw_notify.cc @@ -780,7 +780,7 @@ static inline bool notification_match(reservation_t& res, const RGWPubSub ps(res.store, res.user_tenant); const RGWPubSub::Bucket ps_bucket(ps, res.bucket); rgw_pubsub_bucket_topics bucket_topics; - auto rc = ps_bucket.get_topics(res.dpp, &bucket_topics, res.yield); + auto rc = ps_bucket.get_topics(res.dpp, bucket_topics, res.yield); if (rc < 0) { // failed to fetch bucket topics return rc; diff --git a/src/rgw/rgw_admin.cc b/src/rgw/rgw_admin.cc index f29e066e5b5..d79ade2e650 100644 --- a/src/rgw/rgw_admin.cc +++ b/src/rgw/rgw_admin.cc @@ -10328,7 +10328,7 @@ next: } const RGWPubSub::Bucket b(ps, bucket.get()); - ret = b.get_topics(dpp(), &result, null_yield); + ret = b.get_topics(dpp(), result, null_yield); if (ret < 0 && ret != -ENOENT) { cerr << "ERROR: could not get topics: " << cpp_strerror(-ret) << std::endl; return -ret; @@ -10336,7 +10336,7 @@ next: encode_json("result", result, formatter.get()); } else { rgw_pubsub_topics result; - int ret = ps.get_topics(dpp(), &result, null_yield); + int ret = ps.get_topics(dpp(), result, null_yield); if (ret < 0 && ret != -ENOENT) { cerr << "ERROR: could not get topics: " << cpp_strerror(-ret) << std::endl; return -ret; @@ -10355,7 +10355,7 @@ next: RGWPubSub ps(driver, tenant); rgw_pubsub_topic topic; - ret = ps.get_topic(dpp(), topic_name, &topic, null_yield); + ret = ps.get_topic(dpp(), topic_name, topic, null_yield); if (ret < 0) { cerr << "ERROR: could not get topic: " << cpp_strerror(-ret) << std::endl; return -ret; diff --git a/src/rgw/rgw_pubsub.cc b/src/rgw/rgw_pubsub.cc index 538b15e5a33..6ebd87e3fe4 100644 --- a/src/rgw/rgw_pubsub.cc +++ b/src/rgw/rgw_pubsub.cc @@ -407,10 +407,10 @@ RGWPubSub::RGWPubSub(rgw::sal::Driver* _driver, const std::string& _tenant) : driver(_driver), tenant(_tenant) {} -int RGWPubSub::read_topics(const DoutPrefixProvider *dpp, rgw_pubsub_topics *result, +int RGWPubSub::read_topics(const DoutPrefixProvider *dpp, rgw_pubsub_topics& result, RGWObjVersionTracker *objv_tracker, optional_yield y) const { - const int ret = driver->read_topics(tenant, *result, objv_tracker, y, dpp); + const int ret = driver->read_topics(tenant, result, objv_tracker, y, dpp); if (ret < 0) { ldpp_dout(dpp, 10) << "WARNING: failed to read topics info: ret=" << ret << dendl; return ret; @@ -429,10 +429,10 @@ int RGWPubSub::write_topics(const DoutPrefixProvider *dpp, const rgw_pubsub_topi return 0; } -int RGWPubSub::Bucket::read_topics(const DoutPrefixProvider *dpp, rgw_pubsub_bucket_topics *result, +int RGWPubSub::Bucket::read_topics(const DoutPrefixProvider *dpp, rgw_pubsub_bucket_topics& result, RGWObjVersionTracker *objv_tracker, optional_yield y) const { - const int ret = bucket->read_topics(*result, objv_tracker, y, dpp); + const int ret = bucket->read_topics(result, objv_tracker, y, dpp); if (ret < 0 && ret != -ENOENT) { ldpp_dout(dpp, 1) << "ERROR: failed to read bucket topics info: ret=" << ret << dendl; return ret; @@ -453,10 +453,10 @@ int RGWPubSub::Bucket::write_topics(const DoutPrefixProvider *dpp, const rgw_pub return 0; } -int RGWPubSub::get_topic(const DoutPrefixProvider *dpp, const std::string& name, rgw_pubsub_topic *result, optional_yield y) const +int RGWPubSub::get_topic(const DoutPrefixProvider *dpp, const std::string& name, rgw_pubsub_topic& result, optional_yield y) const { rgw_pubsub_topics topics; - const int ret = read_topics(dpp, &topics, nullptr, y); + const int ret = read_topics(dpp, topics, nullptr, y); if (ret < 0) { ldpp_dout(dpp, 1) << "ERROR: failed to read topics info: ret=" << ret << dendl; return ret; @@ -468,7 +468,7 @@ int RGWPubSub::get_topic(const DoutPrefixProvider *dpp, const std::string& name, return -ENOENT; } - *result = iter->second; + result = iter->second; return 0; } @@ -481,7 +481,7 @@ int RGWPubSub::Bucket::create_notification(const DoutPrefixProvider *dpp, const const rgw::notify::EventTypeList& events, OptionalFilter s3_filter, const std::string& notif_name, optional_yield y) const { rgw_pubsub_topic topic_info; - int ret = ps.get_topic(dpp, topic_name, &topic_info, y); + int ret = ps.get_topic(dpp, topic_name, topic_info, y); if (ret < 0) { ldpp_dout(dpp, 1) << "ERROR: failed to read topic '" << topic_name << "' info: ret=" << ret << dendl; return ret; @@ -491,7 +491,7 @@ int RGWPubSub::Bucket::create_notification(const DoutPrefixProvider *dpp, const RGWObjVersionTracker objv_tracker; rgw_pubsub_bucket_topics bucket_topics; - ret = read_topics(dpp, &bucket_topics, &objv_tracker, y); + ret = read_topics(dpp, bucket_topics, &objv_tracker, y); if (ret < 0) { ldpp_dout(dpp, 1) << "ERROR: failed to read topics from bucket '" << bucket->get_name() << "': ret=" << ret << dendl; @@ -524,7 +524,7 @@ int RGWPubSub::Bucket::remove_notification(const DoutPrefixProvider *dpp, const RGWObjVersionTracker objv_tracker; rgw_pubsub_bucket_topics bucket_topics; - auto ret = read_topics(dpp, &bucket_topics, &objv_tracker, y); + auto ret = read_topics(dpp, bucket_topics, &objv_tracker, y); if (ret < 0) { ldpp_dout(dpp, 1) << "ERROR: failed to read bucket topics info: ret=" << ret << dendl; return ret; @@ -559,7 +559,7 @@ int RGWPubSub::Bucket::remove_notifications(const DoutPrefixProvider *dpp, optio { // get all topics on a bucket rgw_pubsub_bucket_topics bucket_topics; - auto ret = get_topics(dpp, &bucket_topics, y); + auto ret = get_topics(dpp, bucket_topics, y); if (ret < 0 && ret != -ENOENT) { ldpp_dout(dpp, 1) << "ERROR: failed to get list of topics from bucket '" << bucket->get_name() << "', ret=" << ret << dendl; return ret ; @@ -593,7 +593,7 @@ int RGWPubSub::create_topic(const DoutPrefixProvider *dpp, const std::string& na RGWObjVersionTracker objv_tracker; rgw_pubsub_topics topics; - int ret = read_topics(dpp, &topics, &objv_tracker, y); + int ret = read_topics(dpp, topics, &objv_tracker, y); if (ret < 0 && ret != -ENOENT) { // its not an error if not topics exist, we create one ldpp_dout(dpp, 1) << "ERROR: failed to read topics info: ret=" << ret << dendl; @@ -621,7 +621,7 @@ int RGWPubSub::remove_topic(const DoutPrefixProvider *dpp, const std::string& na RGWObjVersionTracker objv_tracker; rgw_pubsub_topics topics; - int ret = read_topics(dpp, &topics, &objv_tracker, y); + int ret = read_topics(dpp, topics, &objv_tracker, y); if (ret < 0 && ret != -ENOENT) { ldpp_dout(dpp, 1) << "ERROR: failed to read topics info: ret=" << ret << dendl; return ret; diff --git a/src/rgw/rgw_pubsub.h b/src/rgw/rgw_pubsub.h index 18828281ce6..974581ce3d9 100644 --- a/src/rgw/rgw_pubsub.h +++ b/src/rgw/rgw_pubsub.h @@ -540,7 +540,7 @@ class RGWPubSub rgw::sal::Driver* const driver; const std::string tenant; - int read_topics(const DoutPrefixProvider *dpp, rgw_pubsub_topics *result, + int read_topics(const DoutPrefixProvider *dpp, rgw_pubsub_topics& result, RGWObjVersionTracker* objv_tracker, optional_yield y) const; int write_topics(const DoutPrefixProvider *dpp, const rgw_pubsub_topics& topics, RGWObjVersionTracker* objv_tracker, optional_yield y) const; @@ -556,7 +556,7 @@ public: // read the list of topics associated with a bucket and populate into result // use version tacker to enforce atomicity between read/write // return 0 on success or if no topic was associated with the bucket, error code otherwise - int read_topics(const DoutPrefixProvider *dpp, rgw_pubsub_bucket_topics *result, + int read_topics(const DoutPrefixProvider *dpp, rgw_pubsub_bucket_topics& result, RGWObjVersionTracker* objv_tracker, optional_yield y) const; // set the list of topics associated with a bucket // use version tacker to enforce atomicity between read/write @@ -570,7 +570,7 @@ public: // get the list of topics associated with a bucket and populate into result // return 0 on success or if no topic was associated with the bucket, error code otherwise - int get_topics(const DoutPrefixProvider *dpp, rgw_pubsub_bucket_topics *result, optional_yield y) const { + int get_topics(const DoutPrefixProvider *dpp, rgw_pubsub_bucket_topics& result, optional_yield y) const { return read_topics(dpp, result, nullptr, y); } // adds a topic + filter (event list, and possibly name metadata or tags filters) to a bucket @@ -595,13 +595,13 @@ public: // get the list of topics // return 0 on success or if no topic was associated with the bucket, error code otherwise - int get_topics(const DoutPrefixProvider *dpp, rgw_pubsub_topics *result, optional_yield y) const { + int get_topics(const DoutPrefixProvider *dpp, rgw_pubsub_topics& result, optional_yield y) const { return read_topics(dpp, result, nullptr, y); } // get a topic with by its name and populate it into "result" // return -ENOENT if the topic does not exists // return 0 on success, error code otherwise - int get_topic(const DoutPrefixProvider *dpp, const std::string& name, rgw_pubsub_topic *result, optional_yield y) const; + int get_topic(const DoutPrefixProvider *dpp, const std::string& name, rgw_pubsub_topic& result, optional_yield y) const; // create a topic with a name only // if the topic already exists it is a no-op (considered success) // return 0 on success, error code otherwise diff --git a/src/rgw/rgw_rest_pubsub.cc b/src/rgw/rgw_rest_pubsub.cc index db361bce3bd..b68c3b59966 100644 --- a/src/rgw/rgw_rest_pubsub.cc +++ b/src/rgw/rgw_rest_pubsub.cc @@ -220,7 +220,7 @@ public: void RGWPSListTopicsOp::execute(optional_yield y) { const RGWPubSub ps(driver, s->owner.get_id().tenant); - op_ret = ps.get_topics(this, &result, y); + op_ret = ps.get_topics(this, result, y); // if there are no topics it is not considered an error op_ret = op_ret == -ENOENT ? 0 : op_ret; if (op_ret < 0) { @@ -298,7 +298,7 @@ void RGWPSGetTopicOp::execute(optional_yield y) { return; } const RGWPubSub ps(driver, s->owner.get_id().tenant); - op_ret = ps.get_topic(this, topic_name, &result, y); + op_ret = ps.get_topic(this, topic_name, result, y); if (op_ret < 0) { ldpp_dout(this, 1) << "failed to get topic '" << topic_name << "', ret=" << op_ret << dendl; return; @@ -374,7 +374,7 @@ void RGWPSGetTopicAttributesOp::execute(optional_yield y) { return; } const RGWPubSub ps(driver, s->owner.get_id().tenant); - op_ret = ps.get_topic(this, topic_name, &result, y); + op_ret = ps.get_topic(this, topic_name, result, y); if (op_ret < 0) { ldpp_dout(this, 1) << "failed to get topic '" << topic_name << "', ret=" << op_ret << dendl; return; @@ -651,7 +651,7 @@ void RGWPSCreateNotifOp::execute(optional_yield y) { if(configurations.list.empty()) { // get all topics on a bucket rgw_pubsub_bucket_topics bucket_topics; - op_ret = b.get_topics(this, &bucket_topics, y); + op_ret = b.get_topics(this, bucket_topics, y); if (op_ret < 0) { ldpp_dout(this, 1) << "failed to get list of topics from bucket '" << bucket_name << "', ret=" << op_ret << dendl; return; @@ -691,7 +691,7 @@ void RGWPSCreateNotifOp::execute(optional_yield y) { // get topic information. destination information is stored in the topic rgw_pubsub_topic topic_info; - op_ret = ps.get_topic(this, topic_name, &topic_info, y); + op_ret = ps.get_topic(this, topic_name, topic_info, y); if (op_ret < 0) { ldpp_dout(this, 1) << "failed to get topic '" << topic_name << "', ret=" << op_ret << dendl; return; @@ -794,7 +794,7 @@ void RGWPSDeleteNotifOp::execute(optional_yield y) { // get all topics on a bucket rgw_pubsub_bucket_topics bucket_topics; - op_ret = b.get_topics(this, &bucket_topics, y); + op_ret = b.get_topics(this, bucket_topics, y); if (op_ret < 0) { ldpp_dout(this, 1) << "failed to get list of topics from bucket '" << bucket_name << "', ret=" << op_ret << dendl; return; @@ -891,7 +891,7 @@ void RGWPSListNotifsOp::execute(optional_yield y) { // get all topics on a bucket rgw_pubsub_bucket_topics bucket_topics; - op_ret = b.get_topics(this, &bucket_topics, y); + op_ret = b.get_topics(this, bucket_topics, y); if (op_ret < 0) { ldpp_dout(this, 1) << "failed to get list of topics from bucket '" << bucket_name << "', ret=" << op_ret << dendl; return;