]> git.proxmox.com Git - ceph.git/blob - ceph/src/messages/MOSDPGBackfill.h
update sources to v12.1.3
[ceph.git] / ceph / src / messages / MOSDPGBackfill.h
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
20 class MOSDPGBackfill : public MOSDFastDispatchOp {
21 static const int HEAD_VERSION = 3;
22 static const int COMPAT_VERSION = 3;
23 public:
24 enum {
25 OP_BACKFILL_PROGRESS = 2,
26 OP_BACKFILL_FINISH = 3,
27 OP_BACKFILL_FINISH_ACK = 4,
28 };
29 const char *get_op_name(int o) const {
30 switch (o) {
31 case OP_BACKFILL_PROGRESS: return "progress";
32 case OP_BACKFILL_FINISH: return "finish";
33 case OP_BACKFILL_FINISH_ACK: return "finish_ack";
34 default: return "???";
35 }
36 }
37
38 __u32 op = 0;
39 epoch_t map_epoch = 0, query_epoch = 0;
40 spg_t pgid;
41 hobject_t last_backfill;
42 pg_stat_t stats;
43
44 epoch_t get_map_epoch() const override {
45 return map_epoch;
46 }
47 epoch_t get_min_epoch() const override {
48 return query_epoch;
49 }
50 spg_t get_spg() const override {
51 return pgid;
52 }
53
54 void decode_payload() override {
55 bufferlist::iterator p = payload.begin();
56 ::decode(op, p);
57 ::decode(map_epoch, p);
58 ::decode(query_epoch, p);
59 ::decode(pgid.pgid, p);
60 ::decode(last_backfill, p);
61
62 // For compatibility with version 1
63 ::decode(stats.stats, p);
64
65 ::decode(stats, p);
66
67 // Handle hobject_t format change
68 if (!last_backfill.is_max() &&
69 last_backfill.pool == -1)
70 last_backfill.pool = pgid.pool();
71 ::decode(pgid.shard, p);
72 }
73
74 void encode_payload(uint64_t features) override {
75 ::encode(op, payload);
76 ::encode(map_epoch, payload);
77 ::encode(query_epoch, payload);
78 ::encode(pgid.pgid, payload);
79 ::encode(last_backfill, payload);
80
81 // For compatibility with version 1
82 ::encode(stats.stats, payload);
83
84 ::encode(stats, payload);
85
86 ::encode(pgid.shard, payload);
87 }
88
89 MOSDPGBackfill()
90 : MOSDFastDispatchOp(MSG_OSD_PG_BACKFILL, HEAD_VERSION, COMPAT_VERSION) {}
91 MOSDPGBackfill(__u32 o, epoch_t e, epoch_t qe, spg_t p)
92 : MOSDFastDispatchOp(MSG_OSD_PG_BACKFILL, HEAD_VERSION, COMPAT_VERSION),
93 op(o),
94 map_epoch(e), query_epoch(e),
95 pgid(p) {}
96 private:
97 ~MOSDPGBackfill() override {}
98
99 public:
100 const char *get_type_name() const override { return "pg_backfill"; }
101 void print(ostream& out) const override {
102 out << "pg_backfill(" << get_op_name(op)
103 << " " << pgid
104 << " e " << map_epoch << "/" << query_epoch
105 << " lb " << last_backfill
106 << ")";
107 }
108 };
109
110 #endif