Fix some bugs when testing opensds ansible
[stor4nfv.git] / src / ceph / src / messages / MBackfillReserve.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_MBACKFILL_H
16 #define CEPH_MBACKFILL_H
17
18 #include "msg/Message.h"
19
20 class MBackfillReserve : public Message {
21   static const int HEAD_VERSION = 3;
22   static const int COMPAT_VERSION = 3;
23 public:
24   spg_t pgid;
25   epoch_t query_epoch;
26   enum {
27     REQUEST = 0,
28     GRANT = 1,
29     REJECT = 2,
30   };
31   uint32_t type;
32   uint32_t priority;
33
34   MBackfillReserve()
35     : Message(MSG_OSD_BACKFILL_RESERVE, HEAD_VERSION, COMPAT_VERSION),
36       query_epoch(0), type(-1), priority(-1) {}
37   MBackfillReserve(int type,
38                    spg_t pgid,
39                    epoch_t query_epoch, unsigned prio = -1)
40     : Message(MSG_OSD_BACKFILL_RESERVE, HEAD_VERSION, COMPAT_VERSION),
41       pgid(pgid), query_epoch(query_epoch),
42       type(type), priority(prio) {}
43
44   const char *get_type_name() const override {
45     return "MBackfillReserve";
46   }
47
48   void print(ostream& out) const override {
49     out << "MBackfillReserve ";
50     switch (type) {
51     case REQUEST:
52       out << "REQUEST ";
53       break;
54     case GRANT:
55       out << "GRANT "; 
56       break;
57     case REJECT:
58       out << "REJECT ";
59       break;
60     }
61     out << " pgid: " << pgid << ", query_epoch: " << query_epoch;
62     if (type == REQUEST) out << ", prio: " << priority;
63     return;
64   }
65
66   void decode_payload() override {
67     bufferlist::iterator p = payload.begin();
68     ::decode(pgid.pgid, p);
69     ::decode(query_epoch, p);
70     ::decode(type, p);
71     ::decode(priority, p);
72     ::decode(pgid.shard, p);
73   }
74
75   void encode_payload(uint64_t features) override {
76     ::encode(pgid.pgid, payload);
77     ::encode(query_epoch, payload);
78     ::encode(type, payload);
79     ::encode(priority, payload);
80     ::encode(pgid.shard, payload);
81   }
82 };
83
84 #endif