From: Sage Weil Date: Fri, 19 Oct 2018 18:38:05 +0000 (-0500) Subject: osd: guardedly_lock -> std::lock_guard X-Git-Tag: v14.1.0~820^2~15 X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=e313ce52a7b2d1853a2d1495c979fbd08befecd4;p=ceph-ci.git osd: guardedly_lock -> std::lock_guard Signed-off-by: Sage Weil --- diff --git a/src/osd/OSD.cc b/src/osd/OSD.cc index 8f3bd8e6afc..1024631d72c 100644 --- a/src/osd/OSD.cc +++ b/src/osd/OSD.cc @@ -4287,7 +4287,7 @@ bool OSD::maybe_wait_for_max_pg(const OSDMapRef& osdmap, return false; } - [[gnu::unused]] auto&& pending_creates_locker = guardedly_lock(pending_creates_lock); + std::lock_guard l(pending_creates_lock); if (is_mon_create) { pending_creates_from_mon++; } else { @@ -4325,7 +4325,7 @@ void OSD::resume_creating_pg() return; } unsigned spare_pgs = max_pgs_per_osd - num_pgs; - [[gnu::unused]] auto&& locker = guardedly_lock(pending_creates_lock); + std::lock_guard l(pending_creates_lock); if (pending_creates_from_mon > 0) { dout(20) << __func__ << " pending_creates_from_mon " << pending_creates_from_mon << dendl; @@ -7308,15 +7308,16 @@ vector OSD::get_health_metrics() metrics.emplace_back(daemon_metric::SLOW_OPS, 0, 0); } } - with_unique_lock(pending_creates_lock, [&]() { - auto n_primaries = pending_creates_from_mon; - for (const auto& create : pending_creates_from_osd) { - if (create.second) { - n_primaries++; - } + { + std::lock_guard l(pending_creates_lock); + auto n_primaries = pending_creates_from_mon; + for (const auto& create : pending_creates_from_osd) { + if (create.second) { + n_primaries++; } - metrics.emplace_back(daemon_metric::PENDING_CREATING_PGS, n_primaries); - }); + } + metrics.emplace_back(daemon_metric::PENDING_CREATING_PGS, n_primaries); + } return metrics; } @@ -8359,7 +8360,7 @@ void OSD::consume_map() { // FIXME (as part of seastar rewrite): move to OSDShard - [[gnu::unused]] auto&& pending_create_locker = guardedly_lock(pending_creates_lock); + std::lock_guard l(pending_creates_lock); for (auto pg = pending_creates_from_osd.begin(); pg != pending_creates_from_osd.end();) { if (osdmap->get_pg_acting_rank(pg->first, whoami) < 0) { @@ -8684,11 +8685,12 @@ void OSD::handle_pg_create(OpRequestRef op) ))); } - with_unique_lock(pending_creates_lock, [=]() { - if (pending_creates_from_mon == 0) { - last_pg_create_epoch = m->epoch; - } - }); + { + std::lock_guard l(pending_creates_lock); + if (pending_creates_from_mon == 0) { + last_pg_create_epoch = m->epoch; + } + } maybe_update_heartbeat_peers(); } @@ -8895,11 +8897,12 @@ void OSD::handle_fast_pg_create(MOSDPGCreate2 *m) ))); } - with_unique_lock(pending_creates_lock, [=]() { - if (pending_creates_from_mon == 0) { - last_pg_create_epoch = m->epoch; - } - }); + { + std::lock_guard l(pending_creates_lock); + if (pending_creates_from_mon == 0) { + last_pg_create_epoch = m->epoch; + } + } m->put(); }