]> git.proxmox.com Git - ceph.git/blame - ceph/src/messages/MOSDRepOpReply.h
Import ceph 15.2.8
[ceph.git] / ceph / src / messages / MOSDRepOpReply.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
16#ifndef CEPH_MOSDREPOPREPLY_H
17#define CEPH_MOSDREPOPREPLY_H
18
19#include "MOSDFastDispatchOp.h"
9f95a23c 20#include "MOSDRepOp.h"
7c673cae 21
7c673cae
FG
22/*
23 * OSD Client Subop reply
24 *
25 * oid - object id
26 * op - OSD_OP_DELETE, etc.
27 *
28 */
29
9f95a23c 30class MOSDRepOpReply : public MOSDFastDispatchOp {
11fdf7f2
TL
31private:
32 static constexpr int HEAD_VERSION = 2;
33 static constexpr int COMPAT_VERSION = 1;
7c673cae
FG
34public:
35 epoch_t map_epoch, min_epoch;
36
37 // subop metadata
38 osd_reqid_t reqid;
39 pg_shard_t from;
40 spg_t pgid;
41
42 // result
43 __u8 ack_type;
44 int32_t result;
45
46 // piggybacked osd state
47 eversion_t last_complete_ondisk;
48
9f95a23c 49 ceph::buffer::list::const_iterator p;
11fdf7f2 50 // Decoding flags. Decoding is only needed for messages caught by pipe reader.
7c673cae
FG
51 bool final_decode_needed;
52
53 epoch_t get_map_epoch() const override {
54 return map_epoch;
55 }
56 epoch_t get_min_epoch() const override {
57 return min_epoch;
58 }
59 spg_t get_spg() const override {
60 return pgid;
61 }
62
63 void decode_payload() override {
9f95a23c 64 using ceph::decode;
11fdf7f2
TL
65 p = payload.cbegin();
66 decode(map_epoch, p);
7c673cae 67 if (header.version >= 2) {
11fdf7f2 68 decode(min_epoch, p);
7c673cae
FG
69 decode_trace(p);
70 } else {
71 min_epoch = map_epoch;
72 }
11fdf7f2
TL
73 decode(reqid, p);
74 decode(pgid, p);
7c673cae
FG
75 }
76
77 void finish_decode() {
9f95a23c 78 using ceph::decode;
7c673cae
FG
79 if (!final_decode_needed)
80 return; // Message is already final decoded
11fdf7f2
TL
81 decode(ack_type, p);
82 decode(result, p);
83 decode(last_complete_ondisk, p);
7c673cae 84
11fdf7f2 85 decode(from, p);
7c673cae
FG
86 final_decode_needed = false;
87 }
88 void encode_payload(uint64_t features) override {
11fdf7f2
TL
89 using ceph::encode;
90 encode(map_epoch, payload);
7c673cae 91 if (HAVE_FEATURE(features, SERVER_LUMINOUS)) {
c07f9fc5 92 header.version = HEAD_VERSION;
11fdf7f2 93 encode(min_epoch, payload);
7c673cae
FG
94 encode_trace(payload, features);
95 } else {
96 header.version = 1;
97 }
11fdf7f2
TL
98 encode(reqid, payload);
99 encode(pgid, payload);
100 encode(ack_type, payload);
101 encode(result, payload);
102 encode(last_complete_ondisk, payload);
103 encode(from, payload);
7c673cae
FG
104 }
105
106 spg_t get_pg() { return pgid; }
107
108 int get_ack_type() { return ack_type; }
109 bool is_ondisk() { return ack_type & CEPH_OSD_FLAG_ONDISK; }
110 bool is_onnvram() { return ack_type & CEPH_OSD_FLAG_ONNVRAM; }
111
112 int get_result() { return result; }
113
114 void set_last_complete_ondisk(eversion_t v) { last_complete_ondisk = v; }
115 eversion_t get_last_complete_ondisk() const { return last_complete_ondisk; }
116
117public:
118 MOSDRepOpReply(
119 const MOSDRepOp *req, pg_shard_t from, int result_, epoch_t e, epoch_t mine,
120 int at) :
9f95a23c 121 MOSDFastDispatchOp{MSG_OSD_REPOPREPLY, HEAD_VERSION, COMPAT_VERSION},
7c673cae
FG
122 map_epoch(e),
123 min_epoch(mine),
124 reqid(req->reqid),
125 from(from),
126 pgid(req->pgid.pgid, req->from.shard),
127 ack_type(at),
128 result(result_),
129 final_decode_needed(false) {
130 set_tid(req->get_tid());
131 }
132 MOSDRepOpReply()
9f95a23c 133 : MOSDFastDispatchOp{MSG_OSD_REPOPREPLY, HEAD_VERSION, COMPAT_VERSION},
7c673cae
FG
134 map_epoch(0),
135 min_epoch(0),
136 ack_type(0), result(0),
137 final_decode_needed(true) {}
138private:
139 ~MOSDRepOpReply() override {}
140
141public:
11fdf7f2 142 std::string_view get_type_name() const override { return "osd_repop_reply"; }
7c673cae 143
9f95a23c 144 void print(std::ostream& out) const override {
7c673cae
FG
145 out << "osd_repop_reply(" << reqid
146 << " " << pgid << " e" << map_epoch << "/" << min_epoch;
147 if (!final_decode_needed) {
148 if (ack_type & CEPH_OSD_FLAG_ONDISK)
149 out << " ondisk";
150 if (ack_type & CEPH_OSD_FLAG_ONNVRAM)
151 out << " onnvram";
152 if (ack_type & CEPH_OSD_FLAG_ACK)
153 out << " ack";
154 out << ", result = " << result;
155 }
156 out << ")";
157 }
158
9f95a23c
TL
159private:
160 template<class T, typename... Args>
161 friend boost::intrusive_ptr<T> ceph::make_message(Args&&... args);
7c673cae
FG
162};
163
7c673cae 164#endif