diff options
author | Casey Bodley <cbodley@users.noreply.github.com> | 2023-11-29 17:24:26 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-11-29 17:24:26 +0100 |
commit | 090e92a18db50f388140575e451c1b92c1d3721b (patch) | |
tree | de10e62c1eb6e664171dca94a2ea59c2ae9a13e6 /src/rgw/services | |
parent | Merge pull request #54582 from phlogistonjohn/jjm-cephadm-more-template-error (diff) | |
parent | rgw/quota: remove base class AsyncRefreshHandler (diff) | |
download | ceph-090e92a18db50f388140575e451c1b92c1d3721b.tar.xz ceph-090e92a18db50f388140575e451c1b92c1d3721b.zip |
Merge pull request #54619 from cbodley/wip-rgw-sal-get-stats-async
rgw/sal: clean up read_stats_async() callbacks
Reviewed-by: Daniel Gryniewicz <dang@redhat.com>
Diffstat (limited to 'src/rgw/services')
-rw-r--r-- | src/rgw/services/svc_user.h | 5 | ||||
-rw-r--r-- | src/rgw/services/svc_user_rados.cc | 28 | ||||
-rw-r--r-- | src/rgw/services/svc_user_rados.h | 3 |
3 files changed, 16 insertions, 20 deletions
diff --git a/src/rgw/services/svc_user.h b/src/rgw/services/svc_user.h index 1cb459d31cb..f53ec49f259 100644 --- a/src/rgw/services/svc_user.h +++ b/src/rgw/services/svc_user.h @@ -20,9 +20,9 @@ #include "svc_meta_be.h" #include "rgw_service.h" +#include "rgw_sal_fwd.h" class RGWUserBuckets; -class RGWGetUserStats_CB; class RGWSI_User : public RGWServiceInstance { @@ -122,6 +122,7 @@ public: optional_yield y) = 0; /* last time a stats update was done */ virtual int read_stats_async(const DoutPrefixProvider *dpp, - const rgw_user& user, RGWGetUserStats_CB *cb) = 0; + const rgw_user& user, + boost::intrusive_ptr<rgw::sal::ReadStatsCB> cb) = 0; }; diff --git a/src/rgw/services/svc_user_rados.cc b/src/rgw/services/svc_user_rados.cc index c99af935415..b9dd8cd1553 100644 --- a/src/rgw/services/svc_user_rados.cc +++ b/src/rgw/services/svc_user_rados.cc @@ -927,36 +927,32 @@ int RGWSI_User_RADOS::read_stats(const DoutPrefixProvider *dpp, } class RGWGetUserStatsContext : public RGWGetUserHeader_CB { - RGWGetUserStats_CB *cb; + boost::intrusive_ptr<rgw::sal::ReadStatsCB> cb; public: - explicit RGWGetUserStatsContext(RGWGetUserStats_CB * const cb) - : cb(cb) {} + explicit RGWGetUserStatsContext(boost::intrusive_ptr<rgw::sal::ReadStatsCB> cb) + : cb(std::move(cb)) {} void handle_response(int r, cls_user_header& header) override { const cls_user_stats& hs = header.stats; - if (r >= 0) { - RGWStorageStats stats; + RGWStorageStats stats; - stats.size = hs.total_bytes; - stats.size_rounded = hs.total_bytes_rounded; - stats.num_objects = hs.total_entries; + stats.size = hs.total_bytes; + stats.size_rounded = hs.total_bytes_rounded; + stats.num_objects = hs.total_entries; - cb->set_response(stats); - } - - cb->handle_response(r); - - cb->put(); + cb->handle_response(r, stats); + cb.reset(); } }; int RGWSI_User_RADOS::read_stats_async(const DoutPrefixProvider *dpp, - const rgw_user& user, RGWGetUserStats_CB *_cb) + const rgw_user& user, + boost::intrusive_ptr<rgw::sal::ReadStatsCB> _cb) { string user_str = user.to_str(); - RGWGetUserStatsContext *cb = new RGWGetUserStatsContext(_cb); + RGWGetUserStatsContext *cb = new RGWGetUserStatsContext(std::move(_cb)); int r = cls_user_get_header_async(dpp, user_str, cb); if (r < 0) { delete cb; diff --git a/src/rgw/services/svc_user_rados.h b/src/rgw/services/svc_user_rados.h index 4712d1fdafd..01d8a8eb1cc 100644 --- a/src/rgw/services/svc_user_rados.h +++ b/src/rgw/services/svc_user_rados.h @@ -34,7 +34,6 @@ class RGWSI_MetaBackend_Handler; struct rgw_cache_entry_info; class RGWGetUserHeader_CB; -class RGWGetUserStats_CB; template <class T> class RGWChainedCacheImpl; @@ -207,6 +206,6 @@ public: optional_yield y) override; /* last time a stats update was done */ int read_stats_async(const DoutPrefixProvider *dpp, const rgw_user& user, - RGWGetUserStats_CB *cb) override; + boost::intrusive_ptr<rgw::sal::ReadStatsCB> cb) override; }; |