1 // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
2 // vim: ts=8 sw=2 smarttab
4 * Ceph - scalable distributed file system
6 * Copyright (C) 2004-2006 Sage Weil <sage@newdream.net>
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.
16 #ifndef CEPH_MOSDREPOPREPLY_H
17 #define CEPH_MOSDREPOPREPLY_H
19 #include "MOSDFastDispatchOp.h"
21 #include "os/ObjectStore.h"
24 * OSD Client Subop reply
27 * op - OSD_OP_DELETE, etc.
31 class MOSDRepOpReply : public MOSDFastDispatchOp {
32 static const int HEAD_VERSION = 2;
33 static const int COMPAT_VERSION = 1;
35 epoch_t map_epoch, min_epoch;
46 // piggybacked osd state
47 eversion_t last_complete_ondisk;
49 bufferlist::iterator p;
50 // Decoding flags. Decoding is only needed for messages catched by pipe reader.
51 bool final_decode_needed;
53 epoch_t get_map_epoch() const override {
56 epoch_t get_min_epoch() const override {
59 spg_t get_spg() const override {
63 void decode_payload() override {
65 ::decode(map_epoch, p);
66 if (header.version >= 2) {
67 ::decode(min_epoch, p);
70 min_epoch = map_epoch;
76 void finish_decode() {
77 if (!final_decode_needed)
78 return; // Message is already final decoded
79 ::decode(ack_type, p);
81 ::decode(last_complete_ondisk, p);
84 final_decode_needed = false;
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);
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);
103 spg_t get_pg() { return pgid; }
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; }
109 int get_result() { return result; }
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; }
116 const MOSDRepOp *req, pg_shard_t from, int result_, epoch_t e, epoch_t mine,
118 MOSDFastDispatchOp(MSG_OSD_REPOPREPLY, HEAD_VERSION, COMPAT_VERSION),
123 pgid(req->pgid.pgid, req->from.shard),
126 final_decode_needed(false) {
127 set_tid(req->get_tid());
130 : MOSDFastDispatchOp(MSG_OSD_REPOPREPLY, HEAD_VERSION, COMPAT_VERSION),
133 ack_type(0), result(0),
134 final_decode_needed(true) {}
136 ~MOSDRepOpReply() override {}
139 const char *get_type_name() const override { return "osd_repop_reply"; }
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)
147 if (ack_type & CEPH_OSD_FLAG_ONNVRAM)
149 if (ack_type & CEPH_OSD_FLAG_ACK)
151 out << ", result = " << result;