From: Kefu Chai Date: Thu, 12 Mar 2015 03:20:40 +0000 (+0800) Subject: osd: refactor RepScrubWQ::_process() X-Git-Tag: v0.94~38^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=refs%2Fpull%2F3972%2Fhead;p=ceph.git osd: refactor RepScrubWQ::_process() use Mutex::Locker instead of releasing the lock manually. Signed-off-by: Kefu Chai --- diff --git a/src/osd/OSD.h b/src/osd/OSD.h index f03259843dc5..c8e5b8fbe580 100644 --- a/src/osd/OSD.h +++ b/src/osd/OSD.h @@ -2173,22 +2173,20 @@ protected: void _process( MOSDRepScrub *msg, ThreadPool::TPHandle &handle) { - osd->osd_lock.Lock(); - if (osd->is_stopping()) { - msg->put(); - osd->osd_lock.Unlock(); - return; - } - if (osd->_have_pg(msg->pgid)) { - PG *pg = osd->_lookup_lock_pg(msg->pgid); - osd->osd_lock.Unlock(); - pg->replica_scrub(msg, handle); - msg->put(); - pg->unlock(); - } else { - msg->put(); - osd->osd_lock.Unlock(); + PG *pg = NULL; + { + Mutex::Locker lock(osd->osd_lock); + if (osd->is_stopping() || + !osd->_have_pg(msg->pgid)) { + msg->put(); + return; + } + pg = osd->_lookup_lock_pg(msg->pgid); } + assert(pg); + pg->replica_scrub(msg, handle); + msg->put(); + pg->unlock(); } void _clear() { while (!rep_scrub_queue.empty()) {