]> git.proxmox.com Git - ceph.git/blob - ceph/src/messages/MOSDRepOpReply.h
update sources to v12.1.2
[ceph.git] / ceph / src / messages / MOSDRepOpReply.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
16 #ifndef CEPH_MOSDREPOPREPLY_H
17 #define CEPH_MOSDREPOPREPLY_H
18
19 #include "MOSDFastDispatchOp.h"
20
21 #include "os/ObjectStore.h"
22
23 /*
24 * OSD Client Subop reply
25 *
26 * oid - object id
27 * op - OSD_OP_DELETE, etc.
28 *
29 */
30
31 class MOSDRepOpReply : public MOSDFastDispatchOp {
32 static const int HEAD_VERSION = 2;
33 static const int COMPAT_VERSION = 1;
34 public:
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
49 bufferlist::iterator p;
50 // Decoding flags. Decoding is only needed for messages catched by pipe reader.
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 {
64 p = payload.begin();
65 ::decode(map_epoch, p);
66 if (header.version >= 2) {
67 ::decode(min_epoch, p);
68 decode_trace(p);
69 } else {
70 min_epoch = map_epoch;
71 }
72 ::decode(reqid, p);
73 ::decode(pgid, p);
74 }
75
76 void finish_decode() {
77 if (!final_decode_needed)
78 return; // Message is already final decoded
79 ::decode(ack_type, p);
80 ::decode(result, p);
81 ::decode(last_complete_ondisk, p);
82
83 ::decode(from, p);
84 final_decode_needed = false;
85 }
86 void encode_payload(uint64_t features) override {
87 ::encode(map_epoch, payload);
88 if (HAVE_FEATURE(features, SERVER_LUMINOUS)) {
89 header.version = HEAD_VERSION;
90 ::encode(min_epoch, payload);
91 encode_trace(payload, features);
92 } else {
93 header.version = 1;
94 }
95 ::encode(reqid, payload);
96 ::encode(pgid, payload);
97 ::encode(ack_type, payload);
98 ::encode(result, payload);
99 ::encode(last_complete_ondisk, payload);
100 ::encode(from, payload);
101 }
102
103 spg_t get_pg() { return pgid; }
104
105 int get_ack_type() { return ack_type; }
106 bool is_ondisk() { return ack_type & CEPH_OSD_FLAG_ONDISK; }
107 bool is_onnvram() { return ack_type & CEPH_OSD_FLAG_ONNVRAM; }
108
109 int get_result() { return result; }
110
111 void set_last_complete_ondisk(eversion_t v) { last_complete_ondisk = v; }
112 eversion_t get_last_complete_ondisk() const { return last_complete_ondisk; }
113
114 public:
115 MOSDRepOpReply(
116 const MOSDRepOp *req, pg_shard_t from, int result_, epoch_t e, epoch_t mine,
117 int at) :
118 MOSDFastDispatchOp(MSG_OSD_REPOPREPLY, HEAD_VERSION, COMPAT_VERSION),
119 map_epoch(e),
120 min_epoch(mine),
121 reqid(req->reqid),
122 from(from),
123 pgid(req->pgid.pgid, req->from.shard),
124 ack_type(at),
125 result(result_),
126 final_decode_needed(false) {
127 set_tid(req->get_tid());
128 }
129 MOSDRepOpReply()
130 : MOSDFastDispatchOp(MSG_OSD_REPOPREPLY, HEAD_VERSION, COMPAT_VERSION),
131 map_epoch(0),
132 min_epoch(0),
133 ack_type(0), result(0),
134 final_decode_needed(true) {}
135 private:
136 ~MOSDRepOpReply() override {}
137
138 public:
139 const char *get_type_name() const override { return "osd_repop_reply"; }
140
141 void print(ostream& out) const override {
142 out << "osd_repop_reply(" << reqid
143 << " " << pgid << " e" << map_epoch << "/" << min_epoch;
144 if (!final_decode_needed) {
145 if (ack_type & CEPH_OSD_FLAG_ONDISK)
146 out << " ondisk";
147 if (ack_type & CEPH_OSD_FLAG_ONNVRAM)
148 out << " onnvram";
149 if (ack_type & CEPH_OSD_FLAG_ACK)
150 out << " ack";
151 out << ", result = " << result;
152 }
153 out << ")";
154 }
155
156 };
157
158
159 #endif