]> git.proxmox.com Git - ceph.git/blob - ceph/src/messages/MOSDScrubReserve.h
update sources to ceph Nautilus 14.2.1
[ceph.git] / ceph / src / messages / MOSDScrubReserve.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_MOSDSCRUBRESERVE_H
16 #define CEPH_MOSDSCRUBRESERVE_H
17
18 #include "MOSDFastDispatchOp.h"
19
20 class MOSDScrubReserve : public MessageInstance<MOSDScrubReserve, MOSDFastDispatchOp> {
21 public:
22 friend factory;
23 private:
24 static constexpr int HEAD_VERSION = 1;
25 static constexpr int COMPAT_VERSION = 1;
26 public:
27 spg_t pgid;
28 epoch_t map_epoch;
29 enum {
30 REQUEST = 0,
31 GRANT = 1,
32 RELEASE = 2,
33 REJECT = 3,
34 };
35 int32_t type;
36 pg_shard_t from;
37
38 epoch_t get_map_epoch() const override {
39 return map_epoch;
40 }
41 spg_t get_spg() const override {
42 return pgid;
43 }
44
45 MOSDScrubReserve()
46 : MessageInstance(MSG_OSD_SCRUB_RESERVE, HEAD_VERSION, COMPAT_VERSION),
47 map_epoch(0), type(-1) {}
48 MOSDScrubReserve(spg_t pgid,
49 epoch_t map_epoch,
50 int type,
51 pg_shard_t from)
52 : MessageInstance(MSG_OSD_SCRUB_RESERVE, HEAD_VERSION, COMPAT_VERSION),
53 pgid(pgid), map_epoch(map_epoch),
54 type(type), from(from) {}
55
56 std::string_view get_type_name() const {
57 return "MOSDScrubReserve";
58 }
59
60 void print(ostream& out) const {
61 out << "MOSDScrubReserve(" << pgid << " ";
62 switch (type) {
63 case REQUEST:
64 out << "REQUEST ";
65 break;
66 case GRANT:
67 out << "GRANT ";
68 break;
69 case REJECT:
70 out << "REJECT ";
71 break;
72 case RELEASE:
73 out << "RELEASE ";
74 break;
75 }
76 out << "e" << map_epoch << ")";
77 return;
78 }
79
80 void decode_payload() {
81 auto p = payload.cbegin();
82 decode(pgid, p);
83 decode(map_epoch, p);
84 decode(type, p);
85 decode(from, p);
86 }
87
88 void encode_payload(uint64_t features) {
89 using ceph::encode;
90 encode(pgid, payload);
91 encode(map_epoch, payload);
92 encode(type, payload);
93 encode(from, payload);
94 }
95 };
96
97 #endif