Fix some bugs when testing opensds ansible
[stor4nfv.git] / src / 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 MOSDFastDispatchOp {
21   static const int HEAD_VERSION = 1;
22   static const int COMPAT_VERSION = 1;
23 public:
24   spg_t pgid;
25   epoch_t map_epoch;
26   enum {
27     REQUEST = 0,
28     GRANT = 1,
29     RELEASE = 2,
30     REJECT = 3,
31   };
32   int32_t type;
33   pg_shard_t from;
34
35   epoch_t get_map_epoch() const override {
36     return map_epoch;
37   }
38   spg_t get_spg() const override {
39     return pgid;
40   }
41
42   MOSDScrubReserve()
43     : MOSDFastDispatchOp(MSG_OSD_SCRUB_RESERVE, HEAD_VERSION, COMPAT_VERSION),
44       map_epoch(0), type(-1) {}
45   MOSDScrubReserve(spg_t pgid,
46                    epoch_t map_epoch,
47                    int type,
48                    pg_shard_t from)
49     : MOSDFastDispatchOp(MSG_OSD_SCRUB_RESERVE, HEAD_VERSION, COMPAT_VERSION),
50       pgid(pgid), map_epoch(map_epoch),
51       type(type), from(from) {}
52
53   const char *get_type_name() const {
54     return "MOSDScrubReserve";
55   }
56
57   void print(ostream& out) const {
58     out << "MOSDScrubReserve(" << pgid << " ";
59     switch (type) {
60     case REQUEST:
61       out << "REQUEST ";
62       break;
63     case GRANT:
64       out << "GRANT ";
65       break;
66     case REJECT:
67       out << "REJECT ";
68       break;
69     case RELEASE:
70       out << "RELEASE ";
71       break;
72     }
73     out << "e" << map_epoch << ")";
74     return;
75   }
76
77   void decode_payload() {
78     bufferlist::iterator p = payload.begin();
79     ::decode(pgid, p);
80     ::decode(map_epoch, p);
81     ::decode(type, p);
82     ::decode(from, p);
83   }
84
85   void encode_payload(uint64_t features) {
86     ::encode(pgid, payload);
87     ::encode(map_epoch, payload);
88     ::encode(type, payload);
89     ::encode(from, payload);
90   }
91 };
92
93 #endif