Skip to content

Commit

Permalink
we don't need to drop sdata lock if pg is null. clean up!
Browse files Browse the repository at this point in the history
  • Loading branch information
liewegas committed Feb 22, 2018
1 parent ea65399 commit 2b57d4f
Showing 1 changed file with 57 additions and 62 deletions.
119 changes: 57 additions & 62 deletions src/osd/OSD.cc
Expand Up @@ -9402,18 +9402,15 @@ void OSD::ShardedOpWQ::_process(uint32_t thread_index, heartbeat_handle_d *hb)
sdata->sdata_op_ordering_lock.Unlock();
return; // OSD shutdown, discard.
}
PGRef pg;
uint64_t requeue_seq;
const auto token = item.get_ordering_token();
{
auto r = sdata->pg_slots.emplace(token, make_unique<OSDShardPGSlot>());
auto *slot = r.first->second.get();
dout(30) << __func__ << " " << token
<< (r.second ? " (new)" : "")
<< " to_process " << slot->to_process
<< " waiting " << slot->waiting
<< " waiting_peering " << slot->waiting_peering
<< dendl;
auto r = sdata->pg_slots.emplace(token, make_unique<OSDShardPGSlot>());
OSDShardPGSlot *slot = r.first->second.get();
dout(20) << __func__ << " " << token
<< (r.second ? " (new)" : "")
<< " to_process " << slot->to_process
<< " waiting " << slot->waiting
<< " waiting_peering " << slot->waiting_peering
<< dendl;
// this is an optimization
/*if (slot->num_running == 0 &&
(slot->waiting_for_split
Expand All @@ -9425,68 +9422,66 @@ void OSD::ShardedOpWQ::_process(uint32_t thread_index, heartbeat_handle_d *hb)
sdata->sdata_op_ordering_lock.Unlock();
return;
}*/
// note the requeue seq now...
requeue_seq = slot->requeue_seq;
pg = slot->pg;
slot->to_process.push_back(std::move(item));
dout(20) << __func__ << " " << slot->to_process.back()
<< " queued" << dendl;
++slot->num_running;
}
sdata->sdata_op_ordering_lock.Unlock();

osd->service.maybe_inject_dispatch_delay();
PGRef pg = slot->pg;
slot->to_process.push_back(std::move(item));
dout(20) << __func__ << " " << slot->to_process.back()
<< " queued" << dendl;

// lock pg (if we have it)
if (pg) {
pg->lock();
}

osd->service.maybe_inject_dispatch_delay();

// we don't use a Mutex::Locker here because of the
// osd->service.release_reserved_pushes() call below
sdata->sdata_op_ordering_lock.Lock();
// note the requeue seq now...
uint64_t requeue_seq = slot->requeue_seq;
++slot->num_running;

auto q = sdata->pg_slots.find(token);
if (q == sdata->pg_slots.end()) {
// this can happen if we race with pg removal.
dout(20) << __func__ << " slot " << token << " no longer there" << dendl;
pg->unlock();
sdata->sdata_op_ordering_lock.Unlock();
return;
}
auto *slot = q->second.get();
--slot->num_running;
osd->service.maybe_inject_dispatch_delay();
pg->lock();
osd->service.maybe_inject_dispatch_delay();
sdata->sdata_op_ordering_lock.Lock();

if (pg && !slot->pg) {
// this can happen if we race with pg removal.
dout(20) << __func__ << " slot " << token << " no longer attached" << dendl;
pg->unlock();
pg = nullptr;
}
if (slot->to_process.empty()) {
// raced with wake_pg_waiters or consume_map
dout(20) << __func__ << " " << token
<< " nothing queued" << dendl;
if (pg) {
auto q = sdata->pg_slots.find(token);
if (q == sdata->pg_slots.end()) {
// this can happen if we race with pg removal.
dout(20) << __func__ << " slot " << token << " no longer there" << dendl;
pg->unlock();
sdata->sdata_op_ordering_lock.Unlock();
return;
}
sdata->sdata_op_ordering_lock.Unlock();
return;
}
if (requeue_seq != slot->requeue_seq) {
dout(20) << __func__ << " " << token
<< " requeue_seq " << slot->requeue_seq << " > our "
<< requeue_seq << ", we raced with wake_pg_waiters"
<< dendl;
if (pg) {
slot = q->second.get();
--slot->num_running;

if (slot->pg != pg) {
// this can happen if we race with pg removal.
dout(20) << __func__ << " slot " << token << " no longer attached to "
<< pg << dendl;
pg->unlock();
pg = slot->pg;
}

if (slot->to_process.empty()) {
// raced with wake_pg_waiters or consume_map
dout(20) << __func__ << " " << token
<< " nothing queued" << dendl;
if (pg) {
pg->unlock();
}
sdata->sdata_op_ordering_lock.Unlock();
return;
}
if (requeue_seq != slot->requeue_seq) {
dout(20) << __func__ << " " << token
<< " requeue_seq " << slot->requeue_seq << " > our "
<< requeue_seq << ", we raced with wake_pg_waiters"
<< dendl;
if (pg) {
pg->unlock();
}
sdata->sdata_op_ordering_lock.Unlock();
return;
}
sdata->sdata_op_ordering_lock.Unlock();
return;
}
dout(30) << __func__ << " " << token

dout(20) << __func__ << " " << token
<< " to_process " << slot->to_process
<< " waiting " << slot->waiting
<< " waiting_peering " << slot->waiting_peering << dendl;
Expand Down

0 comments on commit 2b57d4f

Please sign in to comment.