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