]>
Commit | Line | Data |
---|---|---|
7c673cae FG |
1 | // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- |
2 | // vim: ts=8 sw=2 smarttab | |
3 | /* | |
4 | * Ceph - scalable distributed file system | |
5 | * | |
6 | * Copyright (C) 2004-2006 Sage Weil <sage@newdream.net> | |
7 | * | |
8 | * This is free software; you can redistribute it and/or | |
9 | * modify it under the terms of the GNU Lesser General Public | |
10 | * License version 2.1, as published by the Free Software | |
11 | * Foundation. See file COPYING. | |
12 | * | |
13 | */ | |
14 | ||
15 | #ifndef CEPH_MOSDPGBACKFILL_H | |
16 | #define CEPH_MOSDPGBACKFILL_H | |
17 | ||
18 | #include "MOSDFastDispatchOp.h" | |
19 | ||
9f95a23c | 20 | class MOSDPGBackfill : public MOSDFastDispatchOp { |
11fdf7f2 TL |
21 | private: |
22 | static constexpr int HEAD_VERSION = 3; | |
23 | static constexpr int COMPAT_VERSION = 3; | |
7c673cae FG |
24 | public: |
25 | enum { | |
26 | OP_BACKFILL_PROGRESS = 2, | |
27 | OP_BACKFILL_FINISH = 3, | |
28 | OP_BACKFILL_FINISH_ACK = 4, | |
29 | }; | |
30 | const char *get_op_name(int o) const { | |
31 | switch (o) { | |
32 | case OP_BACKFILL_PROGRESS: return "progress"; | |
33 | case OP_BACKFILL_FINISH: return "finish"; | |
34 | case OP_BACKFILL_FINISH_ACK: return "finish_ack"; | |
35 | default: return "???"; | |
36 | } | |
37 | } | |
38 | ||
d2e6a577 FG |
39 | __u32 op = 0; |
40 | epoch_t map_epoch = 0, query_epoch = 0; | |
7c673cae FG |
41 | spg_t pgid; |
42 | hobject_t last_backfill; | |
43 | pg_stat_t stats; | |
44 | ||
45 | epoch_t get_map_epoch() const override { | |
46 | return map_epoch; | |
47 | } | |
48 | epoch_t get_min_epoch() const override { | |
49 | return query_epoch; | |
50 | } | |
51 | spg_t get_spg() const override { | |
52 | return pgid; | |
53 | } | |
54 | ||
55 | void decode_payload() override { | |
11fdf7f2 TL |
56 | auto p = payload.cbegin(); |
57 | decode(op, p); | |
58 | decode(map_epoch, p); | |
59 | decode(query_epoch, p); | |
60 | decode(pgid.pgid, p); | |
61 | decode(last_backfill, p); | |
7c673cae FG |
62 | |
63 | // For compatibility with version 1 | |
11fdf7f2 | 64 | decode(stats.stats, p); |
7c673cae | 65 | |
11fdf7f2 | 66 | decode(stats, p); |
7c673cae FG |
67 | |
68 | // Handle hobject_t format change | |
69 | if (!last_backfill.is_max() && | |
70 | last_backfill.pool == -1) | |
71 | last_backfill.pool = pgid.pool(); | |
11fdf7f2 | 72 | decode(pgid.shard, p); |
7c673cae FG |
73 | } |
74 | ||
75 | void encode_payload(uint64_t features) override { | |
11fdf7f2 TL |
76 | using ceph::encode; |
77 | encode(op, payload); | |
78 | encode(map_epoch, payload); | |
79 | encode(query_epoch, payload); | |
80 | encode(pgid.pgid, payload); | |
81 | encode(last_backfill, payload); | |
7c673cae FG |
82 | |
83 | // For compatibility with version 1 | |
11fdf7f2 | 84 | encode(stats.stats, payload); |
7c673cae | 85 | |
11fdf7f2 | 86 | encode(stats, payload); |
7c673cae | 87 | |
11fdf7f2 | 88 | encode(pgid.shard, payload); |
7c673cae FG |
89 | } |
90 | ||
91 | MOSDPGBackfill() | |
9f95a23c | 92 | : MOSDFastDispatchOp{MSG_OSD_PG_BACKFILL, HEAD_VERSION, COMPAT_VERSION} {} |
7c673cae | 93 | MOSDPGBackfill(__u32 o, epoch_t e, epoch_t qe, spg_t p) |
9f95a23c | 94 | : MOSDFastDispatchOp{MSG_OSD_PG_BACKFILL, HEAD_VERSION, COMPAT_VERSION}, |
7c673cae FG |
95 | op(o), |
96 | map_epoch(e), query_epoch(e), | |
97 | pgid(p) {} | |
98 | private: | |
99 | ~MOSDPGBackfill() override {} | |
100 | ||
101 | public: | |
11fdf7f2 | 102 | std::string_view get_type_name() const override { return "pg_backfill"; } |
7c673cae FG |
103 | void print(ostream& out) const override { |
104 | out << "pg_backfill(" << get_op_name(op) | |
105 | << " " << pgid | |
106 | << " e " << map_epoch << "/" << query_epoch | |
107 | << " lb " << last_backfill | |
108 | << ")"; | |
109 | } | |
9f95a23c TL |
110 | |
111 | private: | |
112 | template<class T, typename... Args> | |
113 | friend boost::intrusive_ptr<T> ceph::make_message(Args&&... args); | |
7c673cae FG |
114 | }; |
115 | ||
116 | #endif |