From ca15873cfa0f21782c7075cd48fa56995767c19f Mon Sep 17 00:00:00 2001 From: Soumya Koduri Date: Wed, 6 Nov 2024 22:35:38 +0530 Subject: [PATCH] rgw: Add objects expirer API to the SAL interface Add the API `process_expired_objects` which is used to process and delete the expired objects (swift or temporarily restored from cloud) to the Zipper interface. Signed-off-by: Soumya Koduri --- src/rgw/driver/daos/rgw_sal_daos.cc | 6 ++++++ src/rgw/driver/daos/rgw_sal_daos.h | 1 + src/rgw/driver/motr/rgw_sal_motr.cc | 6 ++++++ src/rgw/driver/motr/rgw_sal_motr.h | 1 + src/rgw/driver/posix/rgw_sal_posix.cc | 5 +++++ src/rgw/driver/posix/rgw_sal_posix.h | 2 ++ src/rgw/driver/rados/rgw_rados.cc | 2 +- src/rgw/driver/rados/rgw_rados.h | 2 +- src/rgw/driver/rados/rgw_sal_rados.cc | 6 ++++++ src/rgw/driver/rados/rgw_sal_rados.h | 1 + src/rgw/radosgw-admin/radosgw-admin.cc | 4 ++-- src/rgw/rgw_lc.cc | 4 ++-- src/rgw/rgw_sal.h | 2 ++ src/rgw/rgw_sal_dbstore.cc | 6 ++++++ src/rgw/rgw_sal_dbstore.h | 1 + src/rgw/rgw_sal_filter.cc | 5 +++++ src/rgw/rgw_sal_filter.h | 1 + 17 files changed, 49 insertions(+), 6 deletions(-) diff --git a/src/rgw/driver/daos/rgw_sal_daos.cc b/src/rgw/driver/daos/rgw_sal_daos.cc index 92dd7afe2fb..9cd8c352267 100644 --- a/src/rgw/driver/daos/rgw_sal_daos.cc +++ b/src/rgw/driver/daos/rgw_sal_daos.cc @@ -2322,6 +2322,12 @@ std::unique_ptr DaosStore::get_lifecycle(void) { return 0; } +bool DaosStore::process_expired_objects(const DoutPrefixProvider *dpp, + optional_yield y) { + DAOS_NOT_IMPLEMENTED_LOG(nullptr); + return 0; +} + std::unique_ptr DaosStore::get_notification( rgw::sal::Object* obj, rgw::sal::Object* src_obj, struct req_state* s, rgw::notify::EventType event_type, const std::string* object_name) { diff --git a/src/rgw/driver/daos/rgw_sal_daos.h b/src/rgw/driver/daos/rgw_sal_daos.h index 5515579a441..f7ab8a4e40e 100644 --- a/src/rgw/driver/daos/rgw_sal_daos.h +++ b/src/rgw/driver/daos/rgw_sal_daos.h @@ -934,6 +934,7 @@ class DaosStore : public StoreDriver { virtual std::string zone_unique_trans_id(const uint64_t unique_num) override; virtual int cluster_stat(RGWClusterStat& stats) override; virtual std::unique_ptr get_lifecycle(void) override; + virtual bool process_expired_objects(const DoutPrefixProvider *dpp, optional_yield y) override; virtual std::unique_ptr get_notification( rgw::sal::Object* obj, rgw::sal::Object* src_obj, struct req_state* s, rgw::notify::EventType event_type, optional_yield y, diff --git a/src/rgw/driver/motr/rgw_sal_motr.cc b/src/rgw/driver/motr/rgw_sal_motr.cc index 463ea8c5b11..98ddaf9dcb9 100644 --- a/src/rgw/driver/motr/rgw_sal_motr.cc +++ b/src/rgw/driver/motr/rgw_sal_motr.cc @@ -3328,6 +3328,12 @@ std::unique_ptr MotrStore::get_lifecycle(void) return 0; } +bool MotrStore::process_expired_objects(const DoutPrefixProvider *dpp, + optional_yield y) +{ + return 0; +} + std::unique_ptr MotrStore::get_notification(Object* obj, Object* src_obj, req_state* s, rgw::notify::EventType event_type, optional_yield y, const string* object_name) { diff --git a/src/rgw/driver/motr/rgw_sal_motr.h b/src/rgw/driver/motr/rgw_sal_motr.h index 0f99ae48e86..98dc77aaf05 100644 --- a/src/rgw/driver/motr/rgw_sal_motr.h +++ b/src/rgw/driver/motr/rgw_sal_motr.h @@ -1002,6 +1002,7 @@ class MotrStore : public StoreDriver { virtual int list_all_zones(const DoutPrefixProvider* dpp, std::list& zone_ids) override; virtual int cluster_stat(RGWClusterStat& stats) override; virtual std::unique_ptr get_lifecycle(void) override; + virtual bool process_expired_objects(const DoutPrefixProvider *dpp, optional_yield y) override; virtual std::unique_ptr get_notification(rgw::sal::Object* obj, rgw::sal::Object* src_obj, req_state* s, rgw::notify::EventType event_type, optional_yield y, const std::string* object_name=nullptr) override; virtual std::unique_ptr get_notification( diff --git a/src/rgw/driver/posix/rgw_sal_posix.cc b/src/rgw/driver/posix/rgw_sal_posix.cc index 9d76462baa0..129be22b632 100644 --- a/src/rgw/driver/posix/rgw_sal_posix.cc +++ b/src/rgw/driver/posix/rgw_sal_posix.cc @@ -2010,6 +2010,11 @@ void POSIXDriver::register_admin_apis(RGWRESTMgr* mgr) return next->register_admin_apis(mgr); } +bool POSIXDriver::process_expired_objects(const DoutPrefixProvider *dpp, + optional_yield y) { + return next->process_expired_objects(dpp, y); +} + std::unique_ptr POSIXDriver::get_notification(rgw::sal::Object* obj, rgw::sal::Object* src_obj, struct req_state* s, rgw::notify::EventType event_type, optional_yield y, diff --git a/src/rgw/driver/posix/rgw_sal_posix.h b/src/rgw/driver/posix/rgw_sal_posix.h index bf3478ad6ab..ac3e17ca93f 100644 --- a/src/rgw/driver/posix/rgw_sal_posix.h +++ b/src/rgw/driver/posix/rgw_sal_posix.h @@ -401,6 +401,8 @@ public: virtual void finalize(void) override; virtual void register_admin_apis(RGWRESTMgr* mgr) override; + virtual bool process_expired_objects(const DoutPrefixProvider *dpp, + optional_yield y) override; virtual std::unique_ptr get_notification(rgw::sal::Object* obj, rgw::sal::Object* src_obj, struct req_state* s, rgw::notify::EventType event_type, optional_yield y, diff --git a/src/rgw/driver/rados/rgw_rados.cc b/src/rgw/driver/rados/rgw_rados.cc index 69075c506f1..3b86a49471a 100644 --- a/src/rgw/driver/rados/rgw_rados.cc +++ b/src/rgw/driver/rados/rgw_rados.cc @@ -9708,7 +9708,7 @@ int RGWRados::process_lc(const std::unique_ptr& optional_bucke return ret; } -bool RGWRados::process_expire_objects(const DoutPrefixProvider *dpp, optional_yield y) +bool RGWRados::process_expired_objects(const DoutPrefixProvider *dpp, optional_yield y) { return obj_expirer->inspect_all_shards(dpp, utime_t(), ceph_clock_now(), y); } diff --git a/src/rgw/driver/rados/rgw_rados.h b/src/rgw/driver/rados/rgw_rados.h index fe79916392f..217159487bf 100644 --- a/src/rgw/driver/rados/rgw_rados.h +++ b/src/rgw/driver/rados/rgw_rados.h @@ -1587,7 +1587,7 @@ public: int list_gc_objs(int *index, std::string& marker, uint32_t max, bool expired_only, std::list& result, bool *truncated, bool& processing_queue); int process_gc(bool expired_only, optional_yield y); - bool process_expire_objects(const DoutPrefixProvider *dpp, optional_yield y); + bool process_expired_objects(const DoutPrefixProvider *dpp, optional_yield y); int defer_gc(const DoutPrefixProvider *dpp, RGWObjectCtx* ctx, RGWBucketInfo& bucket_info, const rgw_obj& obj, optional_yield y); int process_lc(const std::unique_ptr& optional_bucket); diff --git a/src/rgw/driver/rados/rgw_sal_rados.cc b/src/rgw/driver/rados/rgw_sal_rados.cc index 4c67d0ee71a..9b53a5eac0b 100644 --- a/src/rgw/driver/rados/rgw_sal_rados.cc +++ b/src/rgw/driver/rados/rgw_sal_rados.cc @@ -1844,6 +1844,12 @@ std::unique_ptr RadosStore::get_lifecycle(void) return std::make_unique(this); } +bool RadosStore::process_expired_objects(const DoutPrefixProvider *dpp, + optional_yield y) +{ + return getRados()->process_expired_objects(dpp, y); +} + std::unique_ptr RadosStore::get_notification( rgw::sal::Object* obj, rgw::sal::Object* src_obj, req_state* s, rgw::notify::EventType event_type, optional_yield y, const std::string* object_name) { diff --git a/src/rgw/driver/rados/rgw_sal_rados.h b/src/rgw/driver/rados/rgw_sal_rados.h index 85ea247e345..6bfbbf74d64 100644 --- a/src/rgw/driver/rados/rgw_sal_rados.h +++ b/src/rgw/driver/rados/rgw_sal_rados.h @@ -279,6 +279,7 @@ class RadosStore : public StoreDriver { virtual int list_all_zones(const DoutPrefixProvider* dpp, std::list& zone_ids) override; virtual int cluster_stat(RGWClusterStat& stats) override; virtual std::unique_ptr get_lifecycle(void) override; + virtual bool process_expired_objects(const DoutPrefixProvider *dpp, optional_yield y) override; virtual std::unique_ptr get_notification(rgw::sal::Object* obj, rgw::sal::Object* src_obj, req_state* s, rgw::notify::EventType event_type, optional_yield y, const std::string* object_name=nullptr) override; virtual std::unique_ptr get_notification( const DoutPrefixProvider* dpp, diff --git a/src/rgw/radosgw-admin/radosgw-admin.cc b/src/rgw/radosgw-admin/radosgw-admin.cc index 182e42b8e31..994fbefbf5f 100644 --- a/src/rgw/radosgw-admin/radosgw-admin.cc +++ b/src/rgw/radosgw-admin/radosgw-admin.cc @@ -8386,8 +8386,8 @@ next: } // OPT::OBJECT_REINDEX if (opt_cmd == OPT::OBJECTS_EXPIRE) { - if (!static_cast(driver)->getRados()->process_expire_objects(dpp(), null_yield)) { - cerr << "ERROR: process_expire_objects() processing returned error." << std::endl; + if (!driver->process_expired_objects(dpp(), null_yield)) { + cerr << "ERROR: process_expired_objects() processing returned error." << std::endl; return 1; } } diff --git a/src/rgw/rgw_lc.cc b/src/rgw/rgw_lc.cc index c9fb4765d59..0b3c92db924 100644 --- a/src/rgw/rgw_lc.cc +++ b/src/rgw/rgw_lc.cc @@ -2000,9 +2000,9 @@ int RGWLC::process(LCWorker* worker, } } - ret = static_cast(driver)->getRados()->process_expire_objects(this, null_yield); + ret = driver->process_expired_objects(this, null_yield); if (ret < 0) { - ldpp_dout(this, 5) << "RGWLC::process_expire_objects: failed, " + ldpp_dout(this, 5) << "RGWLC::process_expired_objects: failed, " << " worker ix: " << worker->ix << dendl; } diff --git a/src/rgw/rgw_sal.h b/src/rgw/rgw_sal.h index 4b94f74b851..843d96f632f 100644 --- a/src/rgw/rgw_sal.h +++ b/src/rgw/rgw_sal.h @@ -466,6 +466,8 @@ class Driver { virtual int cluster_stat(RGWClusterStat& stats) = 0; /** Get a @a Lifecycle object. Used to manage/run lifecycle transitions */ virtual std::unique_ptr get_lifecycle(void) = 0; + /** Reset the temporarily restored objects which are expired */ + virtual bool process_expired_objects(const DoutPrefixProvider *dpp, optional_yield y) = 0; /** Get a @a Notification object. Used to communicate with non-RGW daemons, such as * management/tracking software */ diff --git a/src/rgw/rgw_sal_dbstore.cc b/src/rgw/rgw_sal_dbstore.cc index 02fd7a49cda..e9abfc0a8c5 100644 --- a/src/rgw/rgw_sal_dbstore.cc +++ b/src/rgw/rgw_sal_dbstore.cc @@ -1854,6 +1854,12 @@ namespace rgw::sal { return std::make_unique(this); } + bool DBStore::process_expired_objects(const DoutPrefixProvider *dpp, + optional_yield y) + { + return 0; + } + int DBLifecycle::get_entry(const DoutPrefixProvider* dpp, optional_yield y, const std::string& oid, const std::string& marker, LCEntry& entry) diff --git a/src/rgw/rgw_sal_dbstore.h b/src/rgw/rgw_sal_dbstore.h index 4df10d1dce1..2530f3e9ff7 100644 --- a/src/rgw/rgw_sal_dbstore.h +++ b/src/rgw/rgw_sal_dbstore.h @@ -885,6 +885,7 @@ public: virtual int list_all_zones(const DoutPrefixProvider* dpp, std::list& zone_ids) override; virtual int cluster_stat(RGWClusterStat& stats) override; virtual std::unique_ptr get_lifecycle(void) override; + virtual bool process_expired_objects(const DoutPrefixProvider *dpp, optional_yield y) override; virtual std::unique_ptr get_notification( rgw::sal::Object* obj, rgw::sal::Object* src_obj, req_state* s, diff --git a/src/rgw/rgw_sal_filter.cc b/src/rgw/rgw_sal_filter.cc index 15da580988e..60fa37d3c84 100644 --- a/src/rgw/rgw_sal_filter.cc +++ b/src/rgw/rgw_sal_filter.cc @@ -435,6 +435,11 @@ std::unique_ptr FilterDriver::get_lifecycle(void) return std::make_unique(std::move(lc)); } +bool FilterDriver::process_expired_objects(const DoutPrefixProvider *dpp, + optional_yield y) { + return next->process_expired_objects(dpp, y); +} + std::unique_ptr FilterDriver::get_notification(rgw::sal::Object* obj, rgw::sal::Object* src_obj, req_state* s, rgw::notify::EventType event_type, optional_yield y, diff --git a/src/rgw/rgw_sal_filter.h b/src/rgw/rgw_sal_filter.h index 947ce9d4bf5..648e2238ff8 100644 --- a/src/rgw/rgw_sal_filter.h +++ b/src/rgw/rgw_sal_filter.h @@ -289,6 +289,7 @@ public: } virtual int cluster_stat(RGWClusterStat& stats) override; virtual std::unique_ptr get_lifecycle(void) override; + virtual bool process_expired_objects(const DoutPrefixProvider *dpp, optional_yield y) override; virtual std::unique_ptr get_notification(rgw::sal::Object* obj, rgw::sal::Object* src_obj, struct req_state* s, -- 2.39.5