auto& sdata = osd->shards[shard_index];
ceph_assert(sdata);
- // If all threads of shards do oncommits, there is a out-of-order problem.
- // So we choose the thread which has the smallest thread_index(thread_index < num_shards) of shard
- // to do oncommit callback.
+ // If all threads of shards do oncommits, there is a out-of-order
+ // problem. So we choose the thread which has the smallest
+ // thread_index(thread_index < num_shards) of shard to do oncommit
+ // callback.
bool is_smallest_thread_index = thread_index < osd->num_shards;
// peek at spg_t
sdata->shard_lock.Lock();
if (sdata->pqueue->empty() &&
- !(is_smallest_thread_index && !sdata->context_queue.empty())) {
+ (!is_smallest_thread_index || sdata->context_queue.empty())) {
sdata->sdata_wait_lock.Lock();
- if (!sdata->stop_waiting) {
+ if (is_smallest_thread_index && !sdata->context_queue.empty()) {
+ // we raced with a context_queue addition, don't wait
+ sdata->sdata_wait_lock.Unlock();
+ } else if (!sdata->stop_waiting) {
dout(20) << __func__ << " empty q, waiting" << dendl;
osd->cct->get_heartbeat_map()->clear_timeout(hb);
sdata->shard_lock.Unlock();