Skip to content

Commit

Permalink
PG::op_must_wait_for_map: pass the epoch rather than the map
Browse files Browse the repository at this point in the history
have_same_or_newer_map is also modified to accept epoch instead of
map.

Signed-off-by: Somnath Roy <[email protected]>
  • Loading branch information
Somnath Roy committed Jul 10, 2014
1 parent 4689467 commit 74f5e5e
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 19 deletions.
30 changes: 15 additions & 15 deletions src/osd/PG.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1696,7 +1696,7 @@ void PG::take_op_map_waiters()
for (list<OpRequestRef>::iterator i = waiting_for_map.begin();
i != waiting_for_map.end();
) {
if (op_must_wait_for_map(get_osdmap_with_maplock(), *i)) {
if (op_must_wait_for_map(get_osdmap_with_maplock()->get_epoch(), *i)) {
break;
} else {
osd->op_wq.queue(make_pair(PGRef(this), *i));
Expand All @@ -1713,7 +1713,7 @@ void PG::queue_op(OpRequestRef& op)
waiting_for_map.push_back(op);
return;
}
if (op_must_wait_for_map(get_osdmap_with_maplock(), op)) {
if (op_must_wait_for_map(get_osdmap_with_maplock()->get_epoch(), op)) {
waiting_for_map.push_back(op);
return;
}
Expand Down Expand Up @@ -4868,67 +4868,67 @@ bool PG::can_discard_request(OpRequestRef& op)
return true;
}

bool PG::op_must_wait_for_map(OSDMapRef curmap, OpRequestRef op)
bool PG::op_must_wait_for_map(epoch_t cur_epoch, OpRequestRef& op)
{
switch (op->get_req()->get_type()) {
case CEPH_MSG_OSD_OP:
return !have_same_or_newer_map(
curmap,
cur_epoch,
static_cast<MOSDOp*>(op->get_req())->get_map_epoch());

case MSG_OSD_SUBOP:
return !have_same_or_newer_map(
curmap,
cur_epoch,
static_cast<MOSDSubOp*>(op->get_req())->map_epoch);

case MSG_OSD_SUBOPREPLY:
return !have_same_or_newer_map(
curmap,
cur_epoch,
static_cast<MOSDSubOpReply*>(op->get_req())->map_epoch);

case MSG_OSD_PG_SCAN:
return !have_same_or_newer_map(
curmap,
cur_epoch,
static_cast<MOSDPGScan*>(op->get_req())->map_epoch);

case MSG_OSD_PG_BACKFILL:
return !have_same_or_newer_map(
curmap,
cur_epoch,
static_cast<MOSDPGBackfill*>(op->get_req())->map_epoch);

case MSG_OSD_PG_PUSH:
return !have_same_or_newer_map(
curmap,
cur_epoch,
static_cast<MOSDPGPush*>(op->get_req())->map_epoch);

case MSG_OSD_PG_PULL:
return !have_same_or_newer_map(
curmap,
cur_epoch,
static_cast<MOSDPGPull*>(op->get_req())->map_epoch);

case MSG_OSD_PG_PUSH_REPLY:
return !have_same_or_newer_map(
curmap,
cur_epoch,
static_cast<MOSDPGPushReply*>(op->get_req())->map_epoch);

case MSG_OSD_EC_WRITE:
return !have_same_or_newer_map(
curmap,
cur_epoch,
static_cast<MOSDECSubOpWrite*>(op->get_req())->map_epoch);

case MSG_OSD_EC_WRITE_REPLY:
return !have_same_or_newer_map(
curmap,
cur_epoch,
static_cast<MOSDECSubOpWriteReply*>(op->get_req())->map_epoch);

case MSG_OSD_EC_READ:
return !have_same_or_newer_map(
curmap,
cur_epoch,
static_cast<MOSDECSubOpRead*>(op->get_req())->map_epoch);

case MSG_OSD_EC_READ_REPLY:
return !have_same_or_newer_map(
curmap,
cur_epoch,
static_cast<MOSDECSubOpReadReply*>(op->get_req())->map_epoch);
}
assert(0);
Expand Down
6 changes: 3 additions & 3 deletions src/osd/PG.h
Original file line number Diff line number Diff line change
Expand Up @@ -2057,14 +2057,14 @@ class PG {
template<typename T, int MSGTYPE>
bool can_discard_replica_op(OpRequestRef& op);

static bool op_must_wait_for_map(OSDMapRef curmap, OpRequestRef op);
static bool op_must_wait_for_map(epoch_t cur_epoch, OpRequestRef& op);

bool old_peering_msg(epoch_t reply_epoch, epoch_t query_epoch);
bool old_peering_evt(CephPeeringEvtRef evt) {
return old_peering_msg(evt->get_epoch_sent(), evt->get_epoch_requested());
}
static bool have_same_or_newer_map(OSDMapRef osdmap, epoch_t e) {
return e <= osdmap->get_epoch();
static bool have_same_or_newer_map(epoch_t cur_epoch, epoch_t e) {
return e <= cur_epoch;
}
bool have_same_or_newer_map(epoch_t e) {
return e <= get_osdmap()->get_epoch();
Expand Down
2 changes: 1 addition & 1 deletion src/osd/ReplicatedPG.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1081,7 +1081,7 @@ void ReplicatedPG::do_request(
osd->reply_op_error(op, -EPERM);
return;
}
assert(!op_must_wait_for_map(get_osdmap(), op));
assert(!op_must_wait_for_map(get_osdmap()->get_epoch(), op));
if (can_discard_request(op)) {
return;
}
Expand Down

0 comments on commit 74f5e5e

Please sign in to comment.