Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

messages/MOSDOp: a fixes of encode_payload #16836

Merged
merged 1 commit into from Aug 22, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
15 changes: 10 additions & 5 deletions src/messages/MOSDOp.h
Expand Up @@ -59,7 +59,7 @@ class MOSDOp : public MOSDFastDispatchOp {
vector<snapid_t> snaps;

uint64_t features;

bool bdata_encode;
osd_reqid_t reqid; // reqid explicitly set by sender

public:
Expand Down Expand Up @@ -169,7 +169,8 @@ class MOSDOp : public MOSDFastDispatchOp {
MOSDOp()
: MOSDFastDispatchOp(CEPH_MSG_OSD_OP, HEAD_VERSION, COMPAT_VERSION),
partial_decode_needed(true),
final_decode_needed(true) { }
final_decode_needed(true),
bdata_encode(false) { }
MOSDOp(int inc, long tid, const hobject_t& ho, spg_t& _pgid,
epoch_t _osdmap_epoch,
int _flags, uint64_t feat)
Expand All @@ -180,7 +181,8 @@ class MOSDOp : public MOSDFastDispatchOp {
pgid(_pgid),
partial_decode_needed(false),
final_decode_needed(false),
features(feat) {
features(feat),
bdata_encode(false) {
set_tid(tid);

// also put the client_inc in reqid.inc, so that get_reqid() can
Expand Down Expand Up @@ -244,8 +246,10 @@ class MOSDOp : public MOSDFastDispatchOp {

// marshalling
void encode_payload(uint64_t features) override {

OSDOp::merge_osd_op_vector_in_data(ops, data);
if( false == bdata_encode ) {
OSDOp::merge_osd_op_vector_in_data(ops, data);
bdata_encode = true;
}

if ((features & CEPH_FEATURE_OBJECTLOCATOR) == 0) {
// here is the old structure we are encoding to: //
Expand Down Expand Up @@ -560,6 +564,7 @@ struct ceph_osd_request_head {

void clear_buffers() override {
OSDOp::clear_data(ops);
bdata_encode = false;
}

const char *get_type_name() const override { return "osd_op"; }
Expand Down
14 changes: 10 additions & 4 deletions src/messages/MOSDOpReply.h
Expand Up @@ -38,6 +38,7 @@ class MOSDOpReply : public Message {
object_t oid;
pg_t pgid;
vector<OSDOp> ops;
bool bdata_encode;
int64_t flags = 0;
errorcode32_t result;
eversion_t bad_replay_version;
Expand Down Expand Up @@ -104,6 +105,7 @@ class MOSDOpReply : public Message {
}
void claim_ops(vector<OSDOp>& o) {
o.swap(ops);
bdata_encode = false;
}

/**
Expand All @@ -125,13 +127,15 @@ class MOSDOpReply : public Message {

public:
MOSDOpReply()
: Message(CEPH_MSG_OSD_OPREPLY, HEAD_VERSION, COMPAT_VERSION) {
: Message(CEPH_MSG_OSD_OPREPLY, HEAD_VERSION, COMPAT_VERSION),
bdata_encode(false) {
do_redirect = false;
}
MOSDOpReply(const MOSDOp *req, int r, epoch_t e, int acktype,
bool ignore_out_data)
: Message(CEPH_MSG_OSD_OPREPLY, HEAD_VERSION, COMPAT_VERSION),
oid(req->hobj.oid), pgid(req->pgid.pgid), ops(req->ops) {
oid(req->hobj.oid), pgid(req->pgid.pgid), ops(req->ops),
bdata_encode(false) {

set_tid(req->get_tid());
result = r;
Expand All @@ -154,8 +158,10 @@ class MOSDOpReply : public Message {

public:
void encode_payload(uint64_t features) override {

OSDOp::merge_osd_op_vector_out_data(ops, data);
if(false == bdata_encode) {
OSDOp::merge_osd_op_vector_out_data(ops, data);
bdata_encode = true;
}

if ((features & CEPH_FEATURE_PGID64) == 0) {
header.version = 1;
Expand Down
12 changes: 9 additions & 3 deletions src/messages/MOSDSubOp.h
Expand Up @@ -72,6 +72,7 @@ class MOSDSubOp : public MOSDFastDispatchOp {
map<hobject_t, interval_set<uint64_t>> clone_subsets;

bool first = false, complete = false;
bool bdata_encode;

interval_set<uint64_t> data_included;
ObjectRecoveryInfo recovery_info;
Expand Down Expand Up @@ -198,7 +199,10 @@ class MOSDSubOp : public MOSDFastDispatchOp {
for (unsigned i = 0; i < ops.size(); i++) {
ops[i].op.payload_len = ops[i].indata.length();
::encode(ops[i].op, payload);
data.append(ops[i].indata);
if(false == bdata_encode) {
data.append(ops[i].indata);
bdata_encode = true;
}
}
::encode(mtime, payload);
//encode a false here for backward compatiable
Expand Down Expand Up @@ -245,7 +249,8 @@ class MOSDSubOp : public MOSDFastDispatchOp {
}

MOSDSubOp()
: MOSDFastDispatchOp(MSG_OSD_SUBOP, HEAD_VERSION, COMPAT_VERSION) { }
: MOSDFastDispatchOp(MSG_OSD_SUBOP, HEAD_VERSION, COMPAT_VERSION),
bdata_encode(false) { }
MOSDSubOp(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)
Expand All @@ -258,7 +263,8 @@ class MOSDSubOp : public MOSDFastDispatchOp {
acks_wanted(aw),
old_exists(false), old_size(0),
version(v),
first(false), complete(false) {
first(false), complete(false),
bdata_encode(false) {
memset(&peer_stat, 0, sizeof(peer_stat));
set_tid(rtid);
}
Expand Down