Skip to content

Commit

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

Signed-off-by: Xinze Chi <xinze@xsky.com>
  • Loading branch information
XinzeChi committed Nov 9, 2015
1 parent f9fdf47 commit c6ee5fa
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 9 deletions.
33 changes: 24 additions & 9 deletions src/messages/MOSDRepOp.h
Expand Up @@ -34,9 +34,14 @@ class MOSDRepOp : public Message {
// metadata from original request
osd_reqid_t reqid;

spg_t pgid;

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

// subop
pg_shard_t from;
spg_t pgid;
hobject_t poid;

__u8 acks_wanted;
Expand Down Expand Up @@ -64,10 +69,16 @@ class MOSDRepOp : public Message {
}

virtual void decode_payload() {
bufferlist::iterator p = payload.begin();
p = payload.begin();
// splitted to partial and final
::decode(map_epoch, p);
::decode(reqid, p);
::decode(pgid, p);
}

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

::decode(acks_wanted, p);
Expand All @@ -83,6 +94,7 @@ class MOSDRepOp : public Message {
::decode(from, p);
::decode(updated_hit_set_history, p);
::decode(pg_trim_rollback_to, p);
final_decode_needed = false;
}

virtual void encode_payload(uint64_t features) {
Expand All @@ -105,15 +117,17 @@ class MOSDRepOp : public Message {

MOSDRepOp()
: Message(MSG_OSD_REPOP, HEAD_VERSION, COMPAT_VERSION),
map_epoch(0), acks_wanted (0) {}
map_epoch(0),
final_decode_needed(true), acks_wanted (0) {}
MOSDRepOp(osd_reqid_t r, pg_shard_t from,
spg_t p, const hobject_t& po, int aw,
epoch_t mape, ceph_tid_t rtid, eversion_t v)
: Message(MSG_OSD_REPOP, HEAD_VERSION, COMPAT_VERSION),
map_epoch(mape),
reqid(r),
from(from),
pgid(p),
final_decode_needed(false),
from(from),
poid(po),
acks_wanted(aw),
version(v) {
Expand All @@ -126,11 +140,12 @@ class MOSDRepOp : public Message {
const char *get_type_name() const { return "osd_repop"; }
void print(ostream& out) const {
out << "osd_repop(" << reqid
<< " " << pgid
<< " " << poid;
out << " v " << version;
if (updated_hit_set_history)
out << ", has_updated_hit_set_history";
<< " " << pgid;
if (!final_decode_needed) {
out << " " << poid << " v " << version;
if (updated_hit_set_history)
out << ", has_updated_hit_set_history";
}
out << ")";
}
};
Expand Down
2 changes: 2 additions & 0 deletions src/messages/MOSDSubOp.h
Expand Up @@ -172,6 +172,8 @@ class MOSDSubOp : public Message {
}
}

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 @@ -1117,6 +1117,7 @@ template<typename T, int MSGTYPE>
void ReplicatedBackend::sub_op_modify_impl(OpRequestRef op)
{
T *m = static_cast<T *>(op->get_req());
m->finish_decode();
int msg_type = m->get_type();
assert(MSGTYPE == msg_type);
assert(msg_type == MSG_OSD_SUBOP || msg_type == MSG_OSD_REPOP);
Expand Down

0 comments on commit c6ee5fa

Please sign in to comment.