From e6918187568dbd01842d8d1d2c808ce16a894239 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 21 Apr 2024 13:54:28 +0200 Subject: Adding upstream version 18.2.2. Signed-off-by: Daniel Baumann --- src/rgw/driver/rados/rgw_object_expirer_core.h | 146 +++++++++++++++++++++++++ 1 file changed, 146 insertions(+) create mode 100644 src/rgw/driver/rados/rgw_object_expirer_core.h (limited to 'src/rgw/driver/rados/rgw_object_expirer_core.h') diff --git a/src/rgw/driver/rados/rgw_object_expirer_core.h b/src/rgw/driver/rados/rgw_object_expirer_core.h new file mode 100644 index 000000000..be63815c1 --- /dev/null +++ b/src/rgw/driver/rados/rgw_object_expirer_core.h @@ -0,0 +1,146 @@ +// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- +// vim: ts=8 sw=2 smarttab ft=cpp + +#pragma once + +#include +#include +#include +#include +#include + +#include "auth/Crypto.h" + +#include "common/armor.h" +#include "common/ceph_json.h" +#include "common/config.h" +#include "common/ceph_argparse.h" +#include "common/Formatter.h" +#include "common/errno.h" + +#include "common/ceph_mutex.h" +#include "common/Cond.h" +#include "common/Thread.h" + +#include "global/global_init.h" + +#include "include/common_fwd.h" +#include "include/utime.h" +#include "include/str_list.h" + +#include "rgw_sal_rados.h" + +class RGWSI_RADOS; +class RGWSI_Zone; +class RGWBucketInfo; +class cls_timeindex_entry; + +class RGWObjExpStore { + CephContext *cct; + RGWSI_RADOS *rados_svc; + rgw::sal::RadosStore* driver; +public: + RGWObjExpStore(CephContext *_cct, RGWSI_RADOS *_rados_svc, rgw::sal::RadosStore* _driver) : cct(_cct), + rados_svc(_rados_svc), + driver(_driver) {} + + int objexp_hint_add(const DoutPrefixProvider *dpp, + const ceph::real_time& delete_at, + const std::string& tenant_name, + const std::string& bucket_name, + const std::string& bucket_id, + const rgw_obj_index_key& obj_key); + + int objexp_hint_list(const DoutPrefixProvider *dpp, + const std::string& oid, + const ceph::real_time& start_time, + const ceph::real_time& end_time, + const int max_entries, + const std::string& marker, + std::list& entries, /* out */ + std::string *out_marker, /* out */ + bool *truncated); /* out */ + + int objexp_hint_trim(const DoutPrefixProvider *dpp, + const std::string& oid, + const ceph::real_time& start_time, + const ceph::real_time& end_time, + const std::string& from_marker, + const std::string& to_marker); +}; + +class RGWObjectExpirer { +protected: + rgw::sal::Driver* driver; + RGWObjExpStore exp_store; + + class OEWorker : public Thread, public DoutPrefixProvider { + CephContext *cct; + RGWObjectExpirer *oe; + ceph::mutex lock = ceph::make_mutex("OEWorker"); + ceph::condition_variable cond; + + public: + OEWorker(CephContext * const cct, + RGWObjectExpirer * const oe) + : cct(cct), + oe(oe) { + } + + void *entry() override; + void stop(); + + CephContext *get_cct() const override; + unsigned get_subsys() const override; + std::ostream& gen_prefix(std::ostream& out) const override; + }; + + OEWorker *worker{nullptr}; + std::atomic down_flag = { false }; + +public: + explicit RGWObjectExpirer(rgw::sal::Driver* _driver) + : driver(_driver), + exp_store(_driver->ctx(), static_cast(driver)->svc()->rados, static_cast(driver)), + worker(NULL) { + } + ~RGWObjectExpirer() { + stop_processor(); + } + + int hint_add(const DoutPrefixProvider *dpp, + const ceph::real_time& delete_at, + const std::string& tenant_name, + const std::string& bucket_name, + const std::string& bucket_id, + const rgw_obj_index_key& obj_key) { + return exp_store.objexp_hint_add(dpp, delete_at, tenant_name, bucket_name, + bucket_id, obj_key); + } + + int garbage_single_object(const DoutPrefixProvider *dpp, objexp_hint_entry& hint); + + void garbage_chunk(const DoutPrefixProvider *dpp, + std::list& entries, /* in */ + bool& need_trim); /* out */ + + void trim_chunk(const DoutPrefixProvider *dpp, + const std::string& shard, + const utime_t& from, + const utime_t& to, + const std::string& from_marker, + const std::string& to_marker); + + bool process_single_shard(const DoutPrefixProvider *dpp, + const std::string& shard, + const utime_t& last_run, + const utime_t& round_start); + + bool inspect_all_shards(const DoutPrefixProvider *dpp, + const utime_t& last_run, + const utime_t& round_start); + + bool going_down(); + void start_processor(); + void stop_processor(); +}; -- cgit v1.2.3