From ea9a2cc9bdc06a0afb9add70533803dbc1a60b17 Mon Sep 17 00:00:00 2001 From: "Adam C. Emerson" Date: Tue, 18 May 2021 17:56:27 -0400 Subject: [PATCH] rgw: Add RGWAsyncPutBucketInstanceInfoCR Signed-off-by: Adam C. Emerson --- src/rgw/rgw_cr_rados.cc | 13 ++++++++ src/rgw/rgw_cr_rados.h | 71 ++++++++++++++++++++++++++++++++++++++++- 2 files changed, 83 insertions(+), 1 deletion(-) diff --git a/src/rgw/rgw_cr_rados.cc b/src/rgw/rgw_cr_rados.cc index 3ddca701009b1..7fb5396304512 100644 --- a/src/rgw/rgw_cr_rados.cc +++ b/src/rgw/rgw_cr_rados.cc @@ -604,6 +604,19 @@ int RGWAsyncGetBucketInstanceInfo::_send_request(const DoutPrefixProvider *dpp) return 0; } +int RGWAsyncPutBucketInstanceInfo::_send_request(const DoutPrefixProvider *dpp) +{ + auto r = store->getRados()->put_bucket_instance_info(bucket_info, exclusive, + mtime, attrs, dpp); + if (r < 0) { + ldpp_dout(dpp, 0) << "ERROR: failed to put bucket instance info for " + << bucket_info.bucket << dendl; + return r; + } + + return 0; +} + RGWRadosBILogTrimCR::RGWRadosBILogTrimCR( const DoutPrefixProvider *dpp, rgw::sal::RadosStore* store, diff --git a/src/rgw/rgw_cr_rados.h b/src/rgw/rgw_cr_rados.h index f83080d53e7bb..62dc104c7e590 100644 --- a/src/rgw/rgw_cr_rados.h +++ b/src/rgw/rgw_cr_rados.h @@ -878,6 +878,29 @@ public: std::map attrs; }; +class RGWAsyncPutBucketInstanceInfo : public RGWAsyncRadosRequest { + rgw::sal::RadosStore* store; + RGWBucketInfo& bucket_info; + bool exclusive; + real_time mtime; + std::map* attrs; + const DoutPrefixProvider *dpp; + +protected: + int _send_request(const DoutPrefixProvider *dpp) override; +public: + RGWAsyncPutBucketInstanceInfo(RGWCoroutine* caller, + RGWAioCompletionNotifier* cn, + rgw::sal::RadosStore* store, + RGWBucketInfo& bucket_info, + bool exclusive, + real_time mtime, + std::map* attrs, + const DoutPrefixProvider* dpp) + : RGWAsyncRadosRequest(caller, cn), store(store), bucket_info(bucket_info), + exclusive(exclusive), mtime(mtime), attrs(attrs), dpp(dpp) {} +}; + class RGWGetBucketInstanceInfoCR : public RGWSimpleCoroutine { RGWAsyncRadosProcessor *async_rados; rgw::sal::RadosStore* store; @@ -887,7 +910,7 @@ class RGWGetBucketInstanceInfoCR : public RGWSimpleCoroutine { const DoutPrefixProvider *dpp; RGWAsyncGetBucketInstanceInfo *req{nullptr}; - + public: // rgw_bucket constructor RGWGetBucketInstanceInfoCR(RGWAsyncRadosProcessor *_async_rados, rgw::sal::RadosStore* _store, @@ -921,6 +944,52 @@ public: } }; +class RGWPutBucketInstanceInfoCR : public RGWSimpleCoroutine { + RGWAsyncRadosProcessor *async_rados; + rgw::sal::RadosStore* store; + RGWBucketInfo& bucket_info; + bool exclusive; + real_time mtime; + std::map* attrs; + const DoutPrefixProvider *dpp; + + RGWAsyncPutBucketInstanceInfo* req = nullptr; + +public: + // rgw_bucket constructor + RGWPutBucketInstanceInfoCR(RGWAsyncRadosProcessor *async_rados, + rgw::sal::RadosStore* store, + RGWBucketInfo& bucket_info, + bool exclusive, + real_time mtime, + std::map* attrs, + const DoutPrefixProvider *dpp) + : RGWSimpleCoroutine(store->ctx()), async_rados(async_rados), store(store), + bucket_info(bucket_info), exclusive(exclusive), + mtime(mtime), attrs(attrs), dpp(dpp) {} + ~RGWPutBucketInstanceInfoCR() override { + request_cleanup(); + } + void request_cleanup() override { + if (req) { + req->finish(); + req = nullptr; + } + } + + int send_request(const DoutPrefixProvider *dpp) override { + req = new RGWAsyncPutBucketInstanceInfo(this, + stack->create_completion_notifier(), + store, bucket_info, exclusive, + mtime, attrs, dpp); + async_rados->queue(req); + return 0; + } + int request_complete() override { + return req->get_ret_status(); + } +}; + class RGWRadosBILogTrimCR : public RGWSimpleCoroutine { RGWRados::BucketShard bs; std::string start_marker; -- 2.39.5