From 4c4c6f68776fba084cf5663e91b6b0cc7da5db31 Mon Sep 17 00:00:00 2001 From: Leonid Chernin Date: Tue, 5 Aug 2025 13:19:59 +0300 Subject: [PATCH] nvmeofgw: cleanup pending map upon monitor restart fixes https://tracker.ceph.com/issues/72434 Signed-off-by: Leonid Chernin (cherry picked from commit 924acd1f2c11784790abb2b9c5ff5dacd32934e1) --- src/mon/NVMeofGwMon.cc | 15 +++++++++++++++ src/mon/NVMeofGwMon.h | 1 + 2 files changed, 16 insertions(+) diff --git a/src/mon/NVMeofGwMon.cc b/src/mon/NVMeofGwMon.cc index dcf154674f99d..342631f7a7136 100644 --- a/src/mon/NVMeofGwMon.cc +++ b/src/mon/NVMeofGwMon.cc @@ -29,11 +29,21 @@ void NVMeofGwMon::init() dout(10) << "called " << dendl; } +void NVMeofGwMon::cleanup_pending_map() +{ + dout(10) << "cleanup pending :" << pending_map << dendl; + pending_map.created_gws.clear(); + pending_map.fsm_timers.clear(); + pending_map.gw_epoch.clear(); + pending_map.epoch = 0; +} + void NVMeofGwMon::on_restart() { dout(10) << "called " << dendl; last_beacon.clear(); last_tick = ceph::coarse_mono_clock::now(); + cleanup_pending_map(); synchronize_last_beacon(); } @@ -168,6 +178,11 @@ void NVMeofGwMon::restore_pending_map_info(NVMeofGwMap & tmp_map) { NvmeGwMonStates& gw_created_map = created_map_pair.second; for (auto& gw_created_pair: gw_created_map) { auto gw_id = gw_created_pair.first; + auto& pending_gws_states = pending_map.created_gws[group_key]; + auto gw_state = pending_gws_states.find(gw_id); + if (gw_state == pending_gws_states.end()) { + continue; + } if (gw_created_pair.second.allow_failovers_ts > now) { // restore not persistent information upon new epochs dout(10) << " restore skip-failovers timeout for gw " << gw_id << dendl; diff --git a/src/mon/NVMeofGwMon.h b/src/mon/NVMeofGwMon.h index 2eceeaee3a77d..1c4617e37230e 100644 --- a/src/mon/NVMeofGwMon.h +++ b/src/mon/NVMeofGwMon.h @@ -99,6 +99,7 @@ private: epoch_t get_ack_map_epoch(bool gw_created, const NvmeGroupKey& group_key); void recreate_gw_epoch(); void restore_pending_map_info(NVMeofGwMap & tmp_map); + void cleanup_pending_map(); }; #endif /* MON_NVMEGWMONITOR_H_ */ -- 2.39.5