From 973829132bf7206eff6c2cf30dd0aa32fb0ce706 Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Fri, 31 Mar 2017 09:33:19 -0400 Subject: [PATCH] mon/OSDMonitor: spinlock -> std::mutex I think spinlock is dangerous here: we're doing semi-unbounded work (decode). Also seemingly innocuous code like dout macros take mutexes. Signed-off-by: Sage Weil --- src/mon/OSDMonitor.cc | 8 ++++---- src/mon/OSDMonitor.h | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/mon/OSDMonitor.cc b/src/mon/OSDMonitor.cc index 543338bdf3d59..6fa5e8de4be7f 100644 --- a/src/mon/OSDMonitor.cc +++ b/src/mon/OSDMonitor.cc @@ -245,7 +245,7 @@ void OSDMonitor::update_from_paxos(bool *need_bootstrap) bufferlist bl; mon->store->get(OSD_PG_CREATING_PREFIX, "creating", bl); auto p = bl.begin(); - std::lock_guard l(creating_pgs_lock); + std::lock_guard l(creating_pgs_lock); creating_pgs.decode(p); dout(7) << __func__ << " loading creating_pgs e" << creating_pgs.last_scan_epoch << dendl; } @@ -1043,7 +1043,7 @@ OSDMonitor::update_pending_creatings(const OSDMap::Incremental& inc) { creating_pgs_t pending_creatings; { - std::lock_guard l(creating_pgs_lock); + std::lock_guard l(creating_pgs_lock); pending_creatings = creating_pgs; } if (pending_creatings.last_scan_epoch > inc.epoch) { @@ -1477,7 +1477,7 @@ version_t OSDMonitor::get_trim_to() { if (mon->monmap->get_required_features().contains_all( ceph::features::mon::FEATURE_LUMINOUS)) { - std::lock_guard l(creating_pgs_lock); + std::lock_guard l(creating_pgs_lock); if (!creating_pgs.pgs.empty()) { return 0; } @@ -3234,7 +3234,7 @@ void OSDMonitor::scan_for_creating_pgs(const map& pools, void OSDMonitor::update_creating_pgs() { creating_pgs_by_osd_epoch.clear(); - std::lock_guard l(creating_pgs_lock); + std::lock_guard l(creating_pgs_lock); for (const auto& pg : creating_pgs.pgs) { int acting_primary = -1; auto pgid = pg.first; diff --git a/src/mon/OSDMonitor.h b/src/mon/OSDMonitor.h index d7c4b64ee3023..b02067ac5f24e 100644 --- a/src/mon/OSDMonitor.h +++ b/src/mon/OSDMonitor.h @@ -432,7 +432,7 @@ private: // the epoch when the pg mapping was calculated epoch_t creating_pgs_epoch = 0; creating_pgs_t creating_pgs; - Spinlock creating_pgs_lock; + std::mutex creating_pgs_lock; creating_pgs_t update_pending_creatings(const OSDMap::Incremental& inc); void trim_creating_pgs(creating_pgs_t *creating_pgs, const PGMap& pgm); -- 2.39.5