From: David Zafman Date: Wed, 6 Nov 2019 19:36:54 +0000 (-0800) Subject: osd: Use lock_guard for sched_scrub_lock like in master X-Git-Tag: v14.2.5~29^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=16f68715e36ac0ddc4e72a25c55d208d27cd1dbf;p=ceph.git osd: Use lock_guard for sched_scrub_lock like in master Signed-off-by: David Zafman --- diff --git a/src/osd/OSD.cc b/src/osd/OSD.cc index df187b0f4199..a3e26a06c325 100644 --- a/src/osd/OSD.cc +++ b/src/osd/OSD.cc @@ -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)