diff options
author | Casey Bodley <cbodley@redhat.com> | 2023-11-22 17:20:26 +0100 |
---|---|---|
committer | Casey Bodley <cbodley@redhat.com> | 2023-11-23 20:47:08 +0100 |
commit | 3bf735b4ab78f64e434feec7f11b84a2d9aa1a01 (patch) | |
tree | 7fc883b296ace4c31c7da01e4444b901bdef09d8 /src/rgw/services/svc_user_rados.cc | |
parent | rgw/sal: RGWGetUserStats_CB cleanup (diff) | |
download | ceph-3bf735b4ab78f64e434feec7f11b84a2d9aa1a01.tar.xz ceph-3bf735b4ab78f64e434feec7f11b84a2d9aa1a01.zip |
rgw/sal: unify ReadStatsCB for async user/bucket stats
`rgw::sal::Bucket::read_stats_async()` had returned stats as
`map<RGWObjCategory, RGWStorageStats>`, but the only caller in
rgw_quota.cc just summed up the categories into a single instance
of `RGWStorageStats`. moving this summation up into rgw_rados'
`RGWGetBucketStatsContext` allows us to unify these sal callbacks
around `RGWStorageStats` alone
the `RGWGetUserStats_CB`/`RGWGetBucketStats_CB` callbacks had inherited
from `RefCountedObject` and required manual reference counting. switch
to `boost::intrusive_ptr` for scope-based shared ownership
Signed-off-by: Casey Bodley <cbodley@redhat.com>
Diffstat (limited to 'src/rgw/services/svc_user_rados.cc')
-rw-r--r-- | src/rgw/services/svc_user_rados.cc | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/src/rgw/services/svc_user_rados.cc b/src/rgw/services/svc_user_rados.cc index 1b23dad53fb..b9dd8cd1553 100644 --- a/src/rgw/services/svc_user_rados.cc +++ b/src/rgw/services/svc_user_rados.cc @@ -927,11 +927,11 @@ 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; @@ -942,17 +942,17 @@ public: stats.num_objects = hs.total_entries; cb->handle_response(r, stats); - - cb->put(); + 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; |