Skip to content

Commit

Permalink
MOSDRepOpReply: Simple Messenger optimization
Browse files Browse the repository at this point in the history
the origin idea is from #5211.

Signed-off-by: Xinze Chi <xinze@xsky.com>
  • Loading branch information
XinzeChi committed Nov 9, 2015
1 parent c6ee5fa commit 22d2732
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 11 deletions.
34 changes: 23 additions & 11 deletions src/messages/MOSDRepOpReply.h
Expand Up @@ -46,18 +46,26 @@ class MOSDRepOpReply : public Message {
// piggybacked osd state
eversion_t last_complete_ondisk;

bufferlist::iterator p;
// Decoding flags. Decoding is only needed for messages catched by pipe reader.
bool final_decode_needed;

virtual void decode_payload() {
bufferlist::iterator p = payload.begin();
p = payload.begin();
::decode(map_epoch, p);
::decode(reqid, p);
::decode(pgid, p);
}

void finish_decode() {
if (!final_decode_needed)
return; // Message is already final decoded
::decode(ack_type, p);
::decode(result, p);
::decode(last_complete_ondisk, p);

::decode(from, p);
final_decode_needed = false;
}
virtual void encode_payload(uint64_t features) {
::encode(map_epoch, payload);
Expand Down Expand Up @@ -91,12 +99,14 @@ class MOSDRepOpReply : public Message {
from(from),
pgid(req->pgid.pgid, req->from.shard),
ack_type(at),
result(result_) {
result(result_),
final_decode_needed(false) {
set_tid(req->get_tid());
}
MOSDRepOpReply()
: Message(MSG_OSD_REPOPREPLY), map_epoch(0),
ack_type(0), result(0) {}
ack_type(0), result(0),
final_decode_needed(true) {}
private:
~MOSDRepOpReply() {}

Expand All @@ -105,14 +115,16 @@ class MOSDRepOpReply : public Message {

void print(ostream& out) const {
out << "osd_repop_reply(" << reqid
<< " " << pgid;
if (ack_type & CEPH_OSD_FLAG_ONDISK)
out << " ondisk";
if (ack_type & CEPH_OSD_FLAG_ONNVRAM)
out << " onnvram";
if (ack_type & CEPH_OSD_FLAG_ACK)
out << " ack";
out << ", result = " << result;
<< " " << pgid;
if (!final_decode_needed) {
if (ack_type & CEPH_OSD_FLAG_ONDISK)
out << " ondisk";
if (ack_type & CEPH_OSD_FLAG_ONNVRAM)
out << " onnvram";
if (ack_type & CEPH_OSD_FLAG_ACK)
out << " ack";
out << ", result = " << result;
}
out << ")";
}

Expand Down
3 changes: 3 additions & 0 deletions src/messages/MOSDSubOpReply.h
Expand Up @@ -85,6 +85,9 @@ class MOSDSubOpReply : public Message {
pgid.shard = shard_id_t::NO_SHARD;
}
}

void finish_decode() { }

virtual void encode_payload(uint64_t features) {
::encode(map_epoch, payload);
::encode(reqid, payload);
Expand Down
1 change: 1 addition & 0 deletions src/osd/ReplicatedBackend.cc
Expand Up @@ -666,6 +666,7 @@ template<typename T, int MSGTYPE>
void ReplicatedBackend::sub_op_modify_reply(OpRequestRef op)
{
T *r = static_cast<T *>(op->get_req());
r->finish_decode();
assert(r->get_header().type == MSGTYPE);
assert(MSGTYPE == MSG_OSD_SUBOPREPLY || MSGTYPE == MSG_OSD_REPOPREPLY);

Expand Down

0 comments on commit 22d2732

Please sign in to comment.