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

osd: tag fast dispatch messages with min_epoch #13681

Merged
merged 13 commits into from May 5, 2017
15 changes: 12 additions & 3 deletions src/messages/MOSDECSubOpRead.h
Expand Up @@ -19,12 +19,12 @@
#include "osd/ECMsgTypes.h"

class MOSDECSubOpRead : public MOSDFastDispatchOp {
static const int HEAD_VERSION = 2;
static const int HEAD_VERSION = 3;
static const int COMPAT_VERSION = 1;

public:
spg_t pgid;
epoch_t map_epoch;
epoch_t map_epoch, min_epoch;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit, could initialize min_epoch to something like 0. yeah, i knew we always initialize it after decoding a message or creating a new one, but it could help us to make sure that the min_epoch is initialized properly.

ECSubRead op;

int get_cost() const override {
Expand All @@ -33,6 +33,9 @@ class MOSDECSubOpRead : public MOSDFastDispatchOp {
epoch_t get_map_epoch() const override {
return map_epoch;
}
epoch_t get_min_epoch() const override {
return min_epoch;
}
spg_t get_spg() const override {
return pgid;
}
Expand All @@ -46,19 +49,25 @@ class MOSDECSubOpRead : public MOSDFastDispatchOp {
::decode(pgid, p);
::decode(map_epoch, p);
::decode(op, p);
if (header.version >= 3) {
::decode(min_epoch, p);
} else {
min_epoch = map_epoch;
}
}

void encode_payload(uint64_t features) override {
::encode(pgid, payload);
::encode(map_epoch, payload);
::encode(op, payload, features);
::encode(min_epoch, payload);
}

const char *get_type_name() const override { return "MOSDECSubOpRead"; }

void print(ostream& out) const override {
out << "MOSDECSubOpRead(" << pgid
<< " " << map_epoch
<< " " << map_epoch << "/" << min_epoch
<< " " << op;
out << ")";
}
Expand Down
15 changes: 12 additions & 3 deletions src/messages/MOSDECSubOpReadReply.h
Expand Up @@ -19,12 +19,12 @@
#include "osd/ECMsgTypes.h"

class MOSDECSubOpReadReply : public MOSDFastDispatchOp {
static const int HEAD_VERSION = 1;
static const int HEAD_VERSION = 2;
static const int COMPAT_VERSION = 1;

public:
spg_t pgid;
epoch_t map_epoch;
epoch_t map_epoch, min_epoch;
ECSubReadReply op;

int get_cost() const override {
Expand All @@ -33,6 +33,9 @@ class MOSDECSubOpReadReply : public MOSDFastDispatchOp {
epoch_t get_map_epoch() const override {
return map_epoch;
}
epoch_t get_min_epoch() const override {
return min_epoch;
}
spg_t get_spg() const override {
return pgid;
}
Expand All @@ -46,19 +49,25 @@ class MOSDECSubOpReadReply : public MOSDFastDispatchOp {
::decode(pgid, p);
::decode(map_epoch, p);
::decode(op, p);
if (header.version >= 2) {
::decode(min_epoch, p);
} else {
min_epoch = map_epoch;
}
}

void encode_payload(uint64_t features) override {
::encode(pgid, payload);
::encode(map_epoch, payload);
::encode(op, payload);
::encode(min_epoch, payload);
}

const char *get_type_name() const override { return "MOSDECSubOpReadReply"; }

void print(ostream& out) const override {
out << "MOSDECSubOpReadReply(" << pgid
<< " " << map_epoch
<< " " << map_epoch << "/" << min_epoch
<< " " << op;
out << ")";
}
Expand Down
15 changes: 12 additions & 3 deletions src/messages/MOSDECSubOpWrite.h
Expand Up @@ -19,12 +19,12 @@
#include "osd/ECMsgTypes.h"

class MOSDECSubOpWrite : public MOSDFastDispatchOp {
static const int HEAD_VERSION = 1;
static const int HEAD_VERSION = 2;
static const int COMPAT_VERSION = 1;

public:
spg_t pgid;
epoch_t map_epoch;
epoch_t map_epoch, min_epoch;
ECSubWrite op;

int get_cost() const override {
Expand All @@ -33,6 +33,9 @@ class MOSDECSubOpWrite : public MOSDFastDispatchOp {
epoch_t get_map_epoch() const override {
return map_epoch;
}
epoch_t get_min_epoch() const override {
return min_epoch;
}
spg_t get_spg() const override {
return pgid;
}
Expand All @@ -50,19 +53,25 @@ class MOSDECSubOpWrite : public MOSDFastDispatchOp {
::decode(pgid, p);
::decode(map_epoch, p);
::decode(op, p);
if (header.version >= 2) {
::decode(min_epoch, p);
} else {
min_epoch = map_epoch;
}
}

void encode_payload(uint64_t features) override {
::encode(pgid, payload);
::encode(map_epoch, payload);
::encode(op, payload);
::encode(min_epoch, payload);
}

const char *get_type_name() const override { return "MOSDECSubOpWrite"; }

void print(ostream& out) const override {
out << "MOSDECSubOpWrite(" << pgid
<< " " << map_epoch
<< " " << map_epoch << "/" << min_epoch
<< " " << op;
out << ")";
}
Expand Down
15 changes: 12 additions & 3 deletions src/messages/MOSDECSubOpWriteReply.h
Expand Up @@ -19,12 +19,12 @@
#include "osd/ECMsgTypes.h"

class MOSDECSubOpWriteReply : public MOSDFastDispatchOp {
static const int HEAD_VERSION = 1;
static const int HEAD_VERSION = 2;
static const int COMPAT_VERSION = 1;

public:
spg_t pgid;
epoch_t map_epoch;
epoch_t map_epoch, min_epoch;
ECSubWriteReply op;

int get_cost() const override {
Expand All @@ -33,6 +33,9 @@ class MOSDECSubOpWriteReply : public MOSDFastDispatchOp {
epoch_t get_map_epoch() const override {
return map_epoch;
}
epoch_t get_min_epoch() const override {
return min_epoch;
}
spg_t get_spg() const override {
return pgid;
}
Expand All @@ -46,19 +49,25 @@ class MOSDECSubOpWriteReply : public MOSDFastDispatchOp {
::decode(pgid, p);
::decode(map_epoch, p);
::decode(op, p);
if (header.version >= 2) {
::decode(min_epoch, p);
} else {
min_epoch = map_epoch;
}
}

void encode_payload(uint64_t features) override {
::encode(pgid, payload);
::encode(map_epoch, payload);
::encode(op, payload);
::encode(min_epoch, payload);
}

const char *get_type_name() const override { return "MOSDECSubOpWriteReply"; }

void print(ostream& out) const override {
out << "MOSDECSubOpWriteReply(" << pgid
<< " " << map_epoch
<< " " << map_epoch << "/" << min_epoch
<< " " << op;
out << ")";
}
Expand Down
3 changes: 3 additions & 0 deletions src/messages/MOSDFastDispatchOp.h
Expand Up @@ -10,6 +10,9 @@
class MOSDFastDispatchOp : public Message {
public:
virtual epoch_t get_map_epoch() const = 0;
virtual epoch_t get_min_epoch() const {
return get_map_epoch();
}
virtual spg_t get_spg() const = 0;

MOSDFastDispatchOp(int t, int version, int compat_version)
Expand Down
5 changes: 5 additions & 0 deletions src/osd/ECBackend.cc
Expand Up @@ -749,6 +749,7 @@ bool ECBackend::handle_message(
MOSDECSubOpReadReply *reply = new MOSDECSubOpReadReply;
reply->pgid = get_parent()->primary_spg_t();
reply->map_epoch = get_parent()->get_epoch();
reply->min_epoch = get_parent()->get_interval_start_epoch();
handle_sub_read(op->op.from, op->op, &(reply->op));
get_parent()->send_message_osd_cluster(
op->op.from.osd, reply, get_parent()->get_epoch());
Expand Down Expand Up @@ -829,6 +830,7 @@ void ECBackend::sub_write_committed(
MOSDECSubOpWriteReply *r = new MOSDECSubOpWriteReply;
r->pgid = get_parent()->primary_spg_t();
r->map_epoch = get_parent()->get_epoch();
r->min_epoch = get_parent()->get_interval_start_epoch();
r->op.tid = tid;
r->op.last_complete = last_complete;
r->op.committed = true;
Expand Down Expand Up @@ -871,6 +873,7 @@ void ECBackend::sub_write_applied(
MOSDECSubOpWriteReply *r = new MOSDECSubOpWriteReply;
r->pgid = get_parent()->primary_spg_t();
r->map_epoch = get_parent()->get_epoch();
r->min_epoch = get_parent()->get_interval_start_epoch();
r->op.from = get_parent()->whoami_shard();
r->op.tid = tid;
r->op.applied = true;
Expand Down Expand Up @@ -1636,6 +1639,7 @@ void ECBackend::do_read_op(ReadOp &op)
get_parent()->whoami_spg_t().pgid,
i->first.shard);
msg->map_epoch = get_parent()->get_epoch();
msg->min_epoch = get_parent()->get_interval_start_epoch();
msg->op = i->second;
msg->op.from = get_parent()->whoami_shard();
msg->op.tid = tid;
Expand Down Expand Up @@ -1926,6 +1930,7 @@ bool ECBackend::try_reads_to_commit()
MOSDECSubOpWrite *r = new MOSDECSubOpWrite(sop);
r->pgid = spg_t(get_parent()->primary_spg_t().pgid, i->shard);
r->map_epoch = get_parent()->get_epoch();
r->min_epoch = get_parent()->get_interval_start_epoch();
get_parent()->send_message_osd_cluster(
i->osd, r, get_parent()->get_epoch());
}
Expand Down
5 changes: 3 additions & 2 deletions src/osd/OSD.cc
Expand Up @@ -6361,7 +6361,7 @@ void OSD::dispatch_session_waiting(Session *session, OSDMapRef osdmap)
assert(ms_can_fast_dispatch(op->get_req()));
const MOSDFastDispatchOp *m = static_cast<const MOSDFastDispatchOp*>(
op->get_req());
if (m->get_map_epoch() > osdmap->get_epoch()) {
if (m->get_min_epoch() > osdmap->get_epoch()) {
break;
}
session->waiting_on_map.erase(i++);
Expand Down Expand Up @@ -6403,8 +6403,9 @@ void OSD::ms_fast_dispatch(Message *m)
reqid.name._num, reqid.tid, reqid.inc);
}

// note sender epoch
// note sender epoch, min req'd epoch
op->sent_epoch = static_cast<MOSDFastDispatchOp*>(m)->get_map_epoch();
op->min_epoch = static_cast<MOSDFastDispatchOp*>(m)->get_min_epoch();

service.maybe_inject_dispatch_delay();

Expand Down
1 change: 1 addition & 0 deletions src/osd/OpRequest.h
Expand Up @@ -110,6 +110,7 @@ struct OpRequest : public TrackedOp {

bool check_send_map = true; ///< true until we check if sender needs a map
epoch_t sent_epoch = 0; ///< client's map epoch
epoch_t min_epoch = 0; ///< min epoch needed to handle this msg

bool hitset_inserted;
const Message *get_req() const { return request; }
Expand Down