Merge pull request #16836 from heyingstar/bug-ms_dump_on_send-doubledata

messages/MOSDOp: a fixes of encode_payload

Reviewed-by: Gregory Farnum <gfarnum@redhat.com>
This commit is contained in:
Yuri Weinstein 2017-08-22 13:39:12 -07:00 committed by GitHub
commit e004685520
3 changed files with 29 additions and 12 deletions

View File

@ -59,7 +59,7 @@ private:
vector<snapid_t> snaps;
uint64_t features;
bool bdata_encode;
osd_reqid_t reqid; // reqid explicitly set by sender
public:
@ -169,7 +169,8 @@ public:
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)
@ -180,7 +181,8 @@ public:
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
@ -244,8 +246,10 @@ public:
// 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: //
@ -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"; }

View File

@ -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;
@ -104,6 +105,7 @@ public:
}
void claim_ops(vector<OSDOp>& o) {
o.swap(ops);
bdata_encode = false;
}
/**
@ -125,13 +127,15 @@ public:
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;
@ -154,8 +158,10 @@ private:
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;

View File

@ -72,6 +72,7 @@ public:
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;
@ -198,7 +199,10 @@ public:
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
@ -245,7 +249,8 @@ public:
}
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)
@ -258,7 +263,8 @@ public:
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);
}