]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
osd: refactor RepScrubWQ::_process() 3972/head
authorKefu Chai <kchai@redhat.com>
Thu, 12 Mar 2015 03:20:40 +0000 (11:20 +0800)
committerKefu Chai <kchai@redhat.com>
Thu, 12 Mar 2015 04:13:12 +0000 (21:13 -0700)
use Mutex::Locker instead of releasing the lock manually.

Signed-off-by: Kefu Chai <kchai@redhat.com>
src/osd/OSD.h

index f03259843dc5a7abe242487d8c49dd113e0b6ed8..c8e5b8fbe580830600d8690ed3b2c4b0ebf21ee9 100644 (file)
@@ -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()) {