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