Fix some bugs when testing opensds ansible
[stor4nfv.git] / src / ceph / src / messages / MPoolOpReply.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_MPOOLOPREPLY_H
16 #define CEPH_MPOOLOPREPLY_H
17
18 #include "common/errno.h"
19
20 class MPoolOpReply : public PaxosServiceMessage {
21 public:
22   uuid_d fsid;
23   __u32 replyCode = 0;
24   epoch_t epoch = 0;
25   bufferlist response_data;
26
27   MPoolOpReply() : PaxosServiceMessage(CEPH_MSG_POOLOP_REPLY, 0)
28   {}
29   MPoolOpReply( uuid_d& f, ceph_tid_t t, int rc, int e, version_t v) :
30     PaxosServiceMessage(CEPH_MSG_POOLOP_REPLY, v),
31     fsid(f),
32     replyCode(rc),
33     epoch(e) {
34     set_tid(t);
35   }
36   MPoolOpReply( uuid_d& f, ceph_tid_t t, int rc, int e, version_t v,
37                 bufferlist *blp) :
38     PaxosServiceMessage(CEPH_MSG_POOLOP_REPLY, v),
39     fsid(f),
40     replyCode(rc),
41     epoch(e) {
42     set_tid(t);
43     if (blp)
44       response_data.claim(*blp);
45   }
46
47   const char *get_type_name() const override { return "poolopreply"; }
48
49   void print(ostream& out) const override {
50     out << "pool_op_reply(tid " << get_tid()
51         << " " << cpp_strerror(-replyCode)
52         << " v" << version << ")";
53   }
54
55   void encode_payload(uint64_t features) override {
56     paxos_encode();
57     ::encode(fsid, payload);
58     ::encode(replyCode, payload);
59     ::encode(epoch, payload);
60     if (response_data.length()) {
61       ::encode(true, payload);
62       ::encode(response_data, payload);
63     } else
64       ::encode(false, payload);
65   }
66   void decode_payload() override {
67     bufferlist::iterator p = payload.begin();
68     paxos_decode(p);
69     ::decode(fsid, p);
70     ::decode(replyCode, p);
71     ::decode(epoch, p);
72     bool has_response_data;
73     ::decode(has_response_data, p);
74     if (has_response_data) {
75       ::decode(response_data, p);
76     }
77   }
78 };
79
80 #endif