]>
Commit | Line | Data |
---|---|---|
7c673cae | 1 | // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- |
9f95a23c | 2 | // vim: ts=8 sw=2 smarttab ft=cpp |
7c673cae FG |
3 | |
4 | #ifndef CEPH_RGW_GC_H | |
5 | #define CEPH_RGW_GC_H | |
6 | ||
7 | ||
8 | #include "include/types.h" | |
9 | #include "include/rados/librados.hpp" | |
9f95a23c | 10 | #include "common/ceph_mutex.h" |
7c673cae FG |
11 | #include "common/Cond.h" |
12 | #include "common/Thread.h" | |
13 | #include "rgw_common.h" | |
14 | #include "rgw_rados.h" | |
15 | #include "cls/rgw/cls_rgw_types.h" | |
16 | ||
17 | #include <atomic> | |
18 | ||
11fdf7f2 TL |
19 | class RGWGCIOManager; |
20 | ||
21 | class RGWGC : public DoutPrefixProvider { | |
7c673cae FG |
22 | CephContext *cct; |
23 | RGWRados *store; | |
24 | int max_objs; | |
25 | string *obj_names; | |
26 | std::atomic<bool> down_flag = { false }; | |
27 | ||
28 | int tag_index(const string& tag); | |
29 | ||
30 | class GCWorker : public Thread { | |
11fdf7f2 | 31 | const DoutPrefixProvider *dpp; |
7c673cae FG |
32 | CephContext *cct; |
33 | RGWGC *gc; | |
9f95a23c TL |
34 | ceph::mutex lock = ceph::make_mutex("GCWorker"); |
35 | ceph::condition_variable cond; | |
7c673cae FG |
36 | |
37 | public: | |
9f95a23c | 38 | GCWorker(const DoutPrefixProvider *_dpp, CephContext *_cct, RGWGC *_gc) : dpp(_dpp), cct(_cct), gc(_gc) {} |
7c673cae FG |
39 | void *entry() override; |
40 | void stop(); | |
41 | }; | |
42 | ||
43 | GCWorker *worker; | |
44 | public: | |
45 | RGWGC() : cct(NULL), store(NULL), max_objs(0), obj_names(NULL), worker(NULL) {} | |
46 | ~RGWGC() { | |
47 | stop_processor(); | |
48 | finalize(); | |
49 | } | |
9f95a23c TL |
50 | vector<bool> transitioned_objects_cache; |
51 | int send_chain(cls_rgw_obj_chain& chain, const string& tag); | |
52 | ||
53 | // asynchronously defer garbage collection on an object that's still being read | |
54 | int async_defer_chain(const string& tag, const cls_rgw_obj_chain& info); | |
55 | ||
56 | // callback for when async_defer_chain() fails with ECANCELED | |
57 | void on_defer_canceled(const cls_rgw_gc_obj_info& info); | |
7c673cae | 58 | |
11fdf7f2 | 59 | int remove(int index, const std::vector<string>& tags, librados::AioCompletion **pc); |
9f95a23c | 60 | int remove(int index, int num_entries); |
7c673cae FG |
61 | |
62 | void initialize(CephContext *_cct, RGWRados *_store); | |
63 | void finalize(); | |
64 | ||
9f95a23c | 65 | int list(int *index, string& marker, uint32_t max, bool expired_only, std::list<cls_rgw_gc_obj_info>& result, bool *truncated, bool& processing_queue); |
7c673cae | 66 | void list_init(int *index) { *index = 0; } |
11fdf7f2 TL |
67 | int process(int index, int process_max_secs, bool expired_only, |
68 | RGWGCIOManager& io_manager); | |
69 | int process(bool expired_only); | |
7c673cae FG |
70 | |
71 | bool going_down(); | |
72 | void start_processor(); | |
73 | void stop_processor(); | |
11fdf7f2 TL |
74 | |
75 | CephContext *get_cct() const override { return store->ctx(); } | |
76 | unsigned get_subsys() const; | |
77 | ||
78 | std::ostream& gen_prefix(std::ostream& out) const; | |
79 | ||
7c673cae FG |
80 | }; |
81 | ||
82 | ||
83 | #endif |