]>
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" | |
f67539c2 | 14 | #include "rgw_sal.h" |
7c673cae FG |
15 | #include "rgw_rados.h" |
16 | #include "cls/rgw/cls_rgw_types.h" | |
17 | ||
18 | #include <atomic> | |
19 | ||
11fdf7f2 TL |
20 | class RGWGCIOManager; |
21 | ||
22 | class RGWGC : public DoutPrefixProvider { | |
7c673cae FG |
23 | CephContext *cct; |
24 | RGWRados *store; | |
25 | int max_objs; | |
20effc67 | 26 | std::string *obj_names; |
7c673cae FG |
27 | std::atomic<bool> down_flag = { false }; |
28 | ||
f67539c2 TL |
29 | static constexpr uint64_t seed = 8675309; |
30 | ||
20effc67 | 31 | int tag_index(const std::string& tag); |
7c673cae FG |
32 | |
33 | class GCWorker : public Thread { | |
11fdf7f2 | 34 | const DoutPrefixProvider *dpp; |
7c673cae FG |
35 | CephContext *cct; |
36 | RGWGC *gc; | |
9f95a23c TL |
37 | ceph::mutex lock = ceph::make_mutex("GCWorker"); |
38 | ceph::condition_variable cond; | |
7c673cae FG |
39 | |
40 | public: | |
9f95a23c | 41 | GCWorker(const DoutPrefixProvider *_dpp, CephContext *_cct, RGWGC *_gc) : dpp(_dpp), cct(_cct), gc(_gc) {} |
7c673cae FG |
42 | void *entry() override; |
43 | void stop(); | |
44 | }; | |
45 | ||
46 | GCWorker *worker; | |
47 | public: | |
48 | RGWGC() : cct(NULL), store(NULL), max_objs(0), obj_names(NULL), worker(NULL) {} | |
49 | ~RGWGC() { | |
50 | stop_processor(); | |
51 | finalize(); | |
52 | } | |
20effc67 TL |
53 | std::vector<bool> transitioned_objects_cache; |
54 | int send_chain(cls_rgw_obj_chain& chain, const std::string& tag); | |
9f95a23c TL |
55 | |
56 | // asynchronously defer garbage collection on an object that's still being read | |
20effc67 | 57 | int async_defer_chain(const std::string& tag, const cls_rgw_obj_chain& info); |
9f95a23c TL |
58 | |
59 | // callback for when async_defer_chain() fails with ECANCELED | |
60 | void on_defer_canceled(const cls_rgw_gc_obj_info& info); | |
7c673cae | 61 | |
20effc67 | 62 | int remove(int index, const std::vector<std::string>& tags, librados::AioCompletion **pc); |
9f95a23c | 63 | int remove(int index, int num_entries); |
7c673cae FG |
64 | |
65 | void initialize(CephContext *_cct, RGWRados *_store); | |
66 | void finalize(); | |
67 | ||
20effc67 | 68 | int list(int *index, std::string& marker, uint32_t max, bool expired_only, std::list<cls_rgw_gc_obj_info>& result, bool *truncated, bool& processing_queue); |
7c673cae | 69 | void list_init(int *index) { *index = 0; } |
11fdf7f2 TL |
70 | int process(int index, int process_max_secs, bool expired_only, |
71 | RGWGCIOManager& io_manager); | |
72 | int process(bool expired_only); | |
7c673cae FG |
73 | |
74 | bool going_down(); | |
75 | void start_processor(); | |
76 | void stop_processor(); | |
11fdf7f2 TL |
77 | |
78 | CephContext *get_cct() const override { return store->ctx(); } | |
79 | unsigned get_subsys() const; | |
80 | ||
81 | std::ostream& gen_prefix(std::ostream& out) const; | |
82 | ||
7c673cae FG |
83 | }; |
84 | ||
85 | ||
86 | #endif |