From 0f044e08809758f46d0d8b4b8dc586de0a751e36 Mon Sep 17 00:00:00 2001 From: Patrick Donnelly Date: Fri, 15 Jul 2016 23:29:22 -0400 Subject: [PATCH] mds: add assertions for standby_daemons invariant These assertions catch state changes of an mds in standby_daemons to a state other than MDSMap::STATE_STANDBY. Currently this invariant is (sometimes!) checked in other locations on access of standby_daemons. This commit allows us catch the violated invariant at the time it occurred. Related to: http://tracker.ceph.com/issues/16592 Signed-off-by: Patrick Donnelly --- src/mds/FSMap.cc | 2 ++ src/mds/FSMap.h | 4 +++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/mds/FSMap.cc b/src/mds/FSMap.cc index 55c72f2addcd..bfa97a3d6fd7 100644 --- a/src/mds/FSMap.cc +++ b/src/mds/FSMap.cc @@ -787,6 +787,8 @@ bool FSMap::undamaged(const fs_cluster_id_t fscid, const mds_rank_t rank) void FSMap::insert(const MDSMap::mds_info_t &new_info) { + assert(new_info.state == MDSMap::STATE_STANDBY); + assert(new_info.rank == MDS_RANK_NONE); mds_roles[new_info.global_id] = FS_CLUSTER_ID_NONE; standby_daemons[new_info.global_id] = new_info; standby_epochs[new_info.global_id] = epoch; diff --git a/src/mds/FSMap.h b/src/mds/FSMap.h index d14e365a652a..5bf27838be6e 100644 --- a/src/mds/FSMap.h +++ b/src/mds/FSMap.h @@ -311,7 +311,9 @@ public: std::function fn) { if (mds_roles.at(who) == FS_CLUSTER_ID_NONE) { - fn(&standby_daemons.at(who)); + auto &info = standby_daemons.at(who); + fn(&info); + assert(info.state == MDSMap::STATE_STANDBY); standby_epochs[who] = epoch; } else { auto fs = filesystems[mds_roles.at(who)]; -- 2.47.3