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 ::encode(min_epoch
, payload
);
90 encode_trace(payload
, features
);
94 ::encode(reqid
, payload
);
95 ::encode(pgid
, payload
);
96 ::encode(ack_type
, payload
);
97 ::encode(result
, payload
);
98 ::encode(last_complete_ondisk
, payload
);
99 ::encode(from
, payload
);
102 spg_t
get_pg() { return pgid
; }
104 int get_ack_type() { return ack_type
; }
105 bool is_ondisk() { return ack_type
& CEPH_OSD_FLAG_ONDISK
; }
106 bool is_onnvram() { return ack_type
& CEPH_OSD_FLAG_ONNVRAM
; }
108 int get_result() { return result
; }
110 void set_last_complete_ondisk(eversion_t v
) { last_complete_ondisk
= v
; }
111 eversion_t
get_last_complete_ondisk() const { return last_complete_ondisk
; }
115 const MOSDRepOp
*req
, pg_shard_t from
, int result_
, epoch_t e
, epoch_t mine
,
117 MOSDFastDispatchOp(MSG_OSD_REPOPREPLY
, HEAD_VERSION
, COMPAT_VERSION
),
122 pgid(req
->pgid
.pgid
, req
->from
.shard
),
125 final_decode_needed(false) {
126 set_tid(req
->get_tid());
129 : MOSDFastDispatchOp(MSG_OSD_REPOPREPLY
, HEAD_VERSION
, COMPAT_VERSION
),
132 ack_type(0), result(0),
133 final_decode_needed(true) {}
135 ~MOSDRepOpReply() override
{}
138 const char *get_type_name() const override
{ return "osd_repop_reply"; }
140 void print(ostream
& out
) const override
{
141 out
<< "osd_repop_reply(" << reqid
142 << " " << pgid
<< " e" << map_epoch
<< "/" << min_epoch
;
143 if (!final_decode_needed
) {
144 if (ack_type
& CEPH_OSD_FLAG_ONDISK
)
146 if (ack_type
& CEPH_OSD_FLAG_ONNVRAM
)
148 if (ack_type
& CEPH_OSD_FLAG_ACK
)
150 out
<< ", result = " << result
;