From ff718c8b094651d6326e9521ff60eb2e0f81685a Mon Sep 17 00:00:00 2001 From: Pan Liu Date: Tue, 13 Dec 2016 16:27:14 +0800 Subject: [PATCH] osd: remove the lock heartbeat_update_lock, and change heatbeat_need_update to atomic_bool Signed-off-by: Pan Liu --- src/osd/OSD.cc | 2 +- src/osd/OSD.h | 12 ++++-------- 2 files changed, 5 insertions(+), 9 deletions(-) diff --git a/src/osd/OSD.cc b/src/osd/OSD.cc index eb8f5a753ec..e19f7e7f2bf 100644 --- a/src/osd/OSD.cc +++ b/src/osd/OSD.cc @@ -1675,7 +1675,7 @@ OSD::OSD(CephContext *cct_, ObjectStore *store_, command_tp(cct, "OSD::command_tp", "tp_osd_cmd", 1), session_waiting_lock("OSD::session_waiting_lock"), heartbeat_lock("OSD::heartbeat_lock"), - heartbeat_stop(false), heartbeat_update_lock("OSD::heartbeat_update_lock"), + heartbeat_stop(false), heartbeat_need_update(true), hbclient_messenger(hb_clientm), hb_front_server_messenger(hb_front_serverm), diff --git a/src/osd/OSD.h b/src/osd/OSD.h index 349fcaeec2f..877d9490aa2 100644 --- a/src/osd/OSD.h +++ b/src/osd/OSD.h @@ -1631,8 +1631,7 @@ private: map debug_heartbeat_drops_remaining; Cond heartbeat_cond; bool heartbeat_stop; - Mutex heartbeat_update_lock; // orders under heartbeat_lock - bool heartbeat_need_update; ///< true if we need to refresh our heartbeat peers + std::atomic_bool heartbeat_need_update; map heartbeat_peers; ///< map of osd id to HeartbeatInfo utime_t last_mon_heartbeat; Messenger *hbclient_messenger; @@ -1647,16 +1646,13 @@ private: void maybe_update_heartbeat_peers(); void reset_heartbeat_peers(); bool heartbeat_peers_need_update() { - Mutex::Locker l(heartbeat_update_lock); - return heartbeat_need_update; + return heartbeat_need_update.load(); } void heartbeat_set_peers_need_update() { - Mutex::Locker l(heartbeat_update_lock); - heartbeat_need_update = true; + heartbeat_need_update.store(true); } void heartbeat_clear_peers_need_update() { - Mutex::Locker l(heartbeat_update_lock); - heartbeat_need_update = false; + heartbeat_need_update.store(false); } void heartbeat(); void heartbeat_check(); -- 2.47.3