From 7f16aceb96d331ce66ffdab053b36e0c19e732c6 Mon Sep 17 00:00:00 2001 From: Casey Bodley Date: Tue, 6 Oct 2020 17:59:34 -0400 Subject: [PATCH] rgw: add rgw_read_bucket_full_sync_status() Signed-off-by: Casey Bodley --- src/rgw/rgw_data_sync.cc | 31 +++++++++++++++++++++++++++++++ src/rgw/rgw_data_sync.h | 7 +++++++ 2 files changed, 38 insertions(+) diff --git a/src/rgw/rgw_data_sync.cc b/src/rgw/rgw_data_sync.cc index fd19179021d77..ed0d0d049722a 100644 --- a/src/rgw/rgw_data_sync.cc +++ b/src/rgw/rgw_data_sync.cc @@ -5352,6 +5352,37 @@ class RGWCollectBucketSyncStatusCR : public RGWShardCollectCR { } }; +int rgw_read_bucket_full_sync_status(const DoutPrefixProvider *dpp, + rgw::sal::RadosStore *store, + const rgw_sync_bucket_pipe& pipe, + rgw_bucket_sync_status *status, + optional_yield y) +{ + auto get_oid = RGWBucketPipeSyncStatusManager::full_status_oid; + const rgw_raw_obj obj{store->svc()->zone->get_zone_params().log_pool, + get_oid(*pipe.source.zone, *pipe.source.bucket, *pipe.dest.bucket)}; + + auto svc = store->svc()->sysobj; + auto obj_ctx = svc->init_obj_ctx(); + auto sysobj = svc->get_obj(obj_ctx, obj); + bufferlist bl; + int ret = sysobj.rop().read(dpp, &bl, y); + if (ret < 0) + return ret; + + try { + auto iter = bl.cbegin(); + using ceph::decode; + rgw_bucket_sync_status result; + decode(result, iter); + *status = result; + return 0; + } catch (const buffer::error& err) { + lderr(svc->ctx()) << "error decoding " << obj << ": " << err.what() << dendl; + return -EIO; + } +} + int rgw_read_bucket_inc_sync_status(const DoutPrefixProvider *dpp, rgw::sal::RadosStore *store, const rgw_sync_bucket_pipe& pipe, diff --git a/src/rgw/rgw_data_sync.h b/src/rgw/rgw_data_sync.h index 27885783533f2..0a74430ec2597 100644 --- a/src/rgw/rgw_data_sync.h +++ b/src/rgw/rgw_data_sync.h @@ -742,6 +742,13 @@ public: int run(const DoutPrefixProvider *dpp); }; +/// read the full sync status with respect to a source bucket +int rgw_read_bucket_full_sync_status(const DoutPrefixProvider *dpp, + rgw::sal::RadosStore *store, + const rgw_sync_bucket_pipe& pipe, + rgw_bucket_sync_status *status, + optional_yield y); + /// read the incremental sync status of all bucket shards from the given source zone int rgw_read_bucket_inc_sync_status(const DoutPrefixProvider *dpp, rgw::sal::RadosStore *store, -- 2.39.5