diff options
author | Sage Weil <sage@redhat.com> | 2018-10-26 22:07:27 -0500 |
---|---|---|
committer | Sage Weil <sage@redhat.com> | 2018-10-26 22:07:27 -0500 |
commit | f755bed3e438d2e7d5ed0df30b8d5bebf2d0cf5a (patch) | |
tree | 94a352d57d6965905bcfd5009cb08bc97a9a817d | |
parent | 143f6011553be61ff09f5b27eaab701823af0cec (diff) | |
parent | d76789444cc09df822a9b83097456e63cb0e030c (diff) | |
download | ceph-f755bed3e438d2e7d5ed0df30b8d5bebf2d0cf5a.tar.gz |
Merge PR #24761 into nautilus
* refs/pull/24761/head:
osd: fix race between op_wq and context_queue
Reviewed-by: xie xingguo <xie.xingguo@zte.com.cn>
Reviewed-by: Jianpeng Ma <jianpeng.ma@intel.com>
-rw-r--r-- | src/osd/OSD.cc | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/src/osd/OSD.cc b/src/osd/OSD.cc index 0c07b1b2945..5479b598dc6 100644 --- a/src/osd/OSD.cc +++ b/src/osd/OSD.cc @@ -10196,17 +10196,21 @@ void OSD::ShardedOpWQ::_process(uint32_t thread_index, heartbeat_handle_d *hb) 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(); |