]>
git.proxmox.com Git - ceph.git/blob - ceph/src/rgw/rgw_object_expirer_core.h
1 // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
2 // vim: ts=8 sw=2 smarttab ft=cpp
13 #include "auth/Crypto.h"
15 #include "common/armor.h"
16 #include "common/ceph_json.h"
17 #include "common/config.h"
18 #include "common/ceph_argparse.h"
19 #include "common/Formatter.h"
20 #include "common/errno.h"
22 #include "common/ceph_mutex.h"
23 #include "common/Cond.h"
24 #include "common/Thread.h"
26 #include "global/global_init.h"
28 #include "include/common_fwd.h"
29 #include "include/utime.h"
30 #include "include/str_list.h"
33 #include "rgw_sal_rados.h"
38 class cls_timeindex_entry
;
40 class RGWObjExpStore
{
42 RGWSI_RADOS
*rados_svc
;
45 RGWObjExpStore(CephContext
*_cct
, RGWSI_RADOS
*_rados_svc
, RGWSI_Zone
*_zone_svc
) : cct(_cct
),
46 rados_svc(_rados_svc
),
47 zone_svc(_zone_svc
) {}
49 int objexp_hint_add(const DoutPrefixProvider
*dpp
,
50 const ceph::real_time
& delete_at
,
51 const string
& tenant_name
,
52 const string
& bucket_name
,
53 const string
& bucket_id
,
54 const rgw_obj_index_key
& obj_key
);
56 int objexp_hint_list(const DoutPrefixProvider
*dpp
,
58 const ceph::real_time
& start_time
,
59 const ceph::real_time
& end_time
,
60 const int max_entries
,
62 list
<cls_timeindex_entry
>& entries
, /* out */
63 string
*out_marker
, /* out */
64 bool *truncated
); /* out */
66 int objexp_hint_trim(const DoutPrefixProvider
*dpp
,
68 const ceph::real_time
& start_time
,
69 const ceph::real_time
& end_time
,
70 const string
& from_marker
,
71 const string
& to_marker
);
74 class RGWObjectExpirer
{
76 rgw::sal::RGWRadosStore
*store
;
77 RGWObjExpStore exp_store
;
79 int init_bucket_info(const std::string
& tenant_name
,
80 const std::string
& bucket_name
,
81 const std::string
& bucket_id
,
82 RGWBucketInfo
& bucket_info
);
84 class OEWorker
: public Thread
, public DoutPrefixProvider
{
87 ceph::mutex lock
= ceph::make_mutex("OEWorker");
88 ceph::condition_variable cond
;
91 OEWorker(CephContext
* const cct
,
92 RGWObjectExpirer
* const oe
)
97 void *entry() override
;
100 CephContext
*get_cct() const override
;
101 unsigned get_subsys() const;
102 std::ostream
& gen_prefix(std::ostream
& out
) const;
105 OEWorker
*worker
{nullptr};
106 std::atomic
<bool> down_flag
= { false };
109 explicit RGWObjectExpirer(rgw::sal::RGWRadosStore
*_store
)
111 exp_store(_store
->getRados()->ctx(), _store
->svc()->rados
, _store
->svc()->zone
),
114 ~RGWObjectExpirer() {
118 int hint_add(const DoutPrefixProvider
*dpp
,
119 const ceph::real_time
& delete_at
,
120 const string
& tenant_name
,
121 const string
& bucket_name
,
122 const string
& bucket_id
,
123 const rgw_obj_index_key
& obj_key
) {
124 return exp_store
.objexp_hint_add(dpp
, delete_at
, tenant_name
, bucket_name
,
128 int garbage_single_object(const DoutPrefixProvider
*dpp
, objexp_hint_entry
& hint
);
130 void garbage_chunk(const DoutPrefixProvider
*dpp
,
131 std::list
<cls_timeindex_entry
>& entries
, /* in */
132 bool& need_trim
); /* out */
134 void trim_chunk(const DoutPrefixProvider
*dpp
,
135 const std::string
& shard
,
138 const string
& from_marker
,
139 const string
& to_marker
);
141 bool process_single_shard(const DoutPrefixProvider
*dpp
,
142 const std::string
& shard
,
143 const utime_t
& last_run
,
144 const utime_t
& round_start
);
146 bool inspect_all_shards(const DoutPrefixProvider
*dpp
,
147 const utime_t
& last_run
,
148 const utime_t
& round_start
);
151 void start_processor();
152 void stop_processor();
154 #endif /* CEPH_OBJEXP_H */