]> git.proxmox.com Git - ceph.git/blob - ceph/src/messages/MOSDPGRecoveryDelete.h
import 15.2.0 Octopus source
[ceph.git] / ceph / src / messages / MOSDPGRecoveryDelete.h
1 // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
2 // vim: ts=8 sw=2 smarttab
3
4 #ifndef CEPH_MOSDPGRECOVERYDELETE_H
5 #define CEPH_MOSDPGRECOVERYDELETE_H
6
7 #include "MOSDFastDispatchOp.h"
8
9 /*
10 * instruct non-primary to remove some objects during recovery
11 */
12
13 class MOSDPGRecoveryDelete : public MOSDFastDispatchOp {
14 public:
15 static constexpr int HEAD_VERSION = 2;
16 static constexpr int COMPAT_VERSION = 1;
17
18 pg_shard_t from;
19 spg_t pgid; ///< target spg_t
20 epoch_t map_epoch, min_epoch;
21 list<pair<hobject_t, eversion_t> > objects; ///< objects to remove
22
23 private:
24 uint64_t cost = 0;
25
26 public:
27 int get_cost() const override {
28 return cost;
29 }
30
31 epoch_t get_map_epoch() const override {
32 return map_epoch;
33 }
34 epoch_t get_min_epoch() const override {
35 return min_epoch;
36 }
37 spg_t get_spg() const override {
38 return pgid;
39 }
40
41 void set_cost(uint64_t c) {
42 cost = c;
43 }
44
45 MOSDPGRecoveryDelete()
46 : MOSDFastDispatchOp{MSG_OSD_PG_RECOVERY_DELETE, HEAD_VERSION,
47 COMPAT_VERSION}
48 {}
49
50 MOSDPGRecoveryDelete(pg_shard_t from, spg_t pgid, epoch_t map_epoch,
51 epoch_t min_epoch)
52 : MOSDFastDispatchOp{MSG_OSD_PG_RECOVERY_DELETE, HEAD_VERSION,
53 COMPAT_VERSION},
54 from(from),
55 pgid(pgid),
56 map_epoch(map_epoch),
57 min_epoch(min_epoch)
58 {}
59
60 private:
61 ~MOSDPGRecoveryDelete() {}
62
63 public:
64 std::string_view get_type_name() const { return "recovery_delete"; }
65 void print(ostream& out) const {
66 out << "MOSDPGRecoveryDelete(" << pgid << " e" << map_epoch << ","
67 << min_epoch << " " << objects << ")";
68 }
69
70 void encode_payload(uint64_t features) {
71 using ceph::encode;
72 encode(from, payload);
73 encode(pgid, payload);
74 encode(map_epoch, payload);
75 encode(min_epoch, payload);
76 encode(cost, payload);
77 encode(objects, payload);
78 }
79 void decode_payload() {
80 auto p = payload.cbegin();
81 decode(from, p);
82 decode(pgid, p);
83 decode(map_epoch, p);
84 decode(min_epoch, p);
85 decode(cost, p);
86 decode(objects, p);
87 }
88 private:
89 template<class T, typename... Args>
90 friend boost::intrusive_ptr<T> ceph::make_message(Args&&... args);
91 };
92
93 #endif