]> git.proxmox.com Git - ceph.git/blob - ceph/src/messages/MPoolOpReply.h
bump version to 18.2.2-pve1
[ceph.git] / 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 ceph::buffer::list 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 ceph::buffer::list *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 = std::move(*blp);
45 }
46
47 std::string_view get_type_name() const override { return "poolopreply"; }
48
49 void print(std::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 using ceph::encode;
57 paxos_encode();
58 encode(fsid, payload);
59 encode(replyCode, payload);
60 encode(epoch, payload);
61 if (response_data.length()) {
62 encode(true, payload);
63 encode(response_data, payload);
64 } else
65 encode(false, payload);
66 }
67 void decode_payload() override {
68 using ceph::decode;
69 auto p = payload.cbegin();
70 paxos_decode(p);
71 decode(fsid, p);
72 decode(replyCode, p);
73 decode(epoch, p);
74 bool has_response_data;
75 decode(has_response_data, p);
76 if (has_response_data) {
77 decode(response_data, p);
78 }
79 }
80 private:
81 template<class T, typename... Args>
82 friend boost::intrusive_ptr<T> ceph::make_message(Args&&... args);
83 };
84
85 #endif