From: Jianjian Huo Date: Thu, 25 Feb 2016 15:24:16 +0000 (-0800) Subject: os/kstore: fix a race condition in _txc_finish() X-Git-Tag: v10.1.0~267^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=9dbac6c3b36741f3480cecca3c421bc3338d8633;p=ceph.git os/kstore: fix a race condition in _txc_finish() {} was missed, which limits the scope of the lock_guard. osr->qlock has to be unlocked before calling _osr_reap_done(), since _osr_reap_done needs acquire osr->qlock in the first beginning. Signed-off-by: Jianjian Huo --- diff --git a/src/os/kstore/KStore.cc b/src/os/kstore/KStore.cc index 729cd14edbdf..97ce03eb4460 100644 --- a/src/os/kstore/KStore.cc +++ b/src/os/kstore/KStore.cc @@ -2280,8 +2280,10 @@ void KStore::_txc_finish(TransContext *txc) } OpSequencerRef osr = txc->osr; - std::lock_guard l(osr->qlock); - txc->state = TransContext::STATE_DONE; + { + std::lock_guard l(osr->qlock); + txc->state = TransContext::STATE_DONE; + } _osr_reap_done(osr.get()); }