Fix some bugs when testing opensds ansible
[stor4nfv.git] / src / 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 #include "include/ceph_features.h"
9
10 /*
11  * instruct non-primary to remove some objects during recovery
12  */
13
14 struct MOSDPGRecoveryDelete : public MOSDFastDispatchOp {
15
16   static const int HEAD_VERSION = 2;
17   static const int COMPAT_VERSION = 1;
18
19   pg_shard_t from;
20   spg_t pgid;            ///< target spg_t
21   epoch_t map_epoch, min_epoch;
22   list<pair<hobject_t, eversion_t> > objects;    ///< objects to remove
23
24 private:
25   uint64_t cost;
26
27 public:
28   int get_cost() const override {
29     return cost;
30   }
31
32   epoch_t get_map_epoch() const override {
33     return map_epoch;
34   }
35   epoch_t get_min_epoch() const override {
36     return min_epoch;
37   }
38   spg_t get_spg() const override {
39     return pgid;
40   }
41
42   void set_cost(uint64_t c) {
43     cost = c;
44   }
45
46   MOSDPGRecoveryDelete()
47     : MOSDFastDispatchOp(MSG_OSD_PG_RECOVERY_DELETE, HEAD_VERSION,
48                          COMPAT_VERSION), cost(0) {}
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       cost(0) {}
59
60 private:
61   ~MOSDPGRecoveryDelete() {}
62
63 public:
64   const char *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     ::encode(from, payload);
72     ::encode(pgid, payload);
73     ::encode(map_epoch, payload);
74     if (HAVE_FEATURE(features, SERVER_LUMINOUS)) {
75       ::encode(min_epoch, payload);
76     }
77     ::encode(cost, payload);
78     ::encode(objects, payload);
79   }
80   void decode_payload() {
81     bufferlist::iterator p = payload.begin();
82     ::decode(from, p);
83     ::decode(pgid, p);
84     ::decode(map_epoch, p);
85     if (header.version == 1 &&
86         !HAVE_FEATURE(get_connection()->get_features(), SERVER_LUMINOUS)) {
87       min_epoch = map_epoch;
88     } else {
89       ::decode(min_epoch, p);
90     }
91     ::decode(cost, p);
92     ::decode(objects, p);
93   }
94 };
95
96
97
98 #endif