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