]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
osd: Use lock_guard for sched_scrub_lock like in master 31444/head
authorDavid Zafman <dzafman@redhat.com>
Wed, 6 Nov 2019 19:36:54 +0000 (11:36 -0800)
committerDavid Zafman <dzafman@redhat.com>
Wed, 13 Nov 2019 23:04:28 +0000 (15:04 -0800)
Signed-off-by: David Zafman <dzafman@redhat.com>
src/osd/OSD.cc

index df187b0f4199b4d543a09113d54d3d24da3b3687..a3e26a06c325e29bb808ce55dbc7294aaa5d10d5 100644 (file)
@@ -1370,8 +1370,7 @@ bool OSDService::can_inc_scrubs()
 bool OSDService::inc_scrubs_local()
 {
   bool result = false;
-
-  sched_scrub_lock.Lock();
+  std::lock_guard l{sched_scrub_lock};
   if (scrubs_local + scrubs_remote < cct->_conf->osd_max_scrubs) {
     dout(20) << __func__ << " " << scrubs_local << " -> " << (scrubs_local+1)
             << " (max " << cct->_conf->osd_max_scrubs << ", remote " << scrubs_remote << ")" << dendl;
@@ -1380,25 +1379,22 @@ bool OSDService::inc_scrubs_local()
   } else {
     dout(20) << __func__ << " " << scrubs_local << " local + " << scrubs_remote << " remote >= max " << cct->_conf->osd_max_scrubs << dendl;
   }
-  sched_scrub_lock.Unlock();
-
   return result;
 }
 
 void OSDService::dec_scrubs_local()
 {
-  sched_scrub_lock.Lock();
+  std::lock_guard l{sched_scrub_lock};
   dout(20) << __func__ << " " << scrubs_local << " -> " << (scrubs_local-1)
           << " (max " << cct->_conf->osd_max_scrubs << ", remote " << scrubs_remote << ")" << dendl;
   --scrubs_local;
   ceph_assert(scrubs_local >= 0);
-  sched_scrub_lock.Unlock();
 }
 
 bool OSDService::inc_scrubs_remote()
 {
   bool result = false;
-  sched_scrub_lock.Lock();
+  std::lock_guard l{sched_scrub_lock};
   if (scrubs_local + scrubs_remote < cct->_conf->osd_max_scrubs) {
     dout(20) << __func__ << " " << scrubs_remote << " -> " << (scrubs_remote+1)
             << " (max " << cct->_conf->osd_max_scrubs << ", local " << scrubs_local << ")" << dendl;
@@ -1407,18 +1403,16 @@ bool OSDService::inc_scrubs_remote()
   } else {
     dout(20) << __func__ << " " << scrubs_local << " local + " << scrubs_remote << " remote >= max " << cct->_conf->osd_max_scrubs << dendl;
   }
-  sched_scrub_lock.Unlock();
   return result;
 }
 
 void OSDService::dec_scrubs_remote()
 {
-  sched_scrub_lock.Lock();
+  std::lock_guard l{sched_scrub_lock};
   dout(20) << __func__ << " " << scrubs_remote << " -> " << (scrubs_remote-1)
           << " (max " << cct->_conf->osd_max_scrubs << ", local " << scrubs_local << ")" << dendl;
   --scrubs_remote;
   ceph_assert(scrubs_remote >= 0);
-  sched_scrub_lock.Unlock();
 }
 
 void OSDService::dump_scrub_reservations(Formatter *f)