From cf5b9eafb3b60d081ffb57961e606fa568e6a7d6 Mon Sep 17 00:00:00 2001 From: Leonid Chernin Date: Thu, 26 Sep 2024 13:47:00 +0000 Subject: [PATCH] mon/nvmeofgw*: fix tracking gateways in DELETING state 1.Ignore subsystems of GWs in state DELETING when calculate number namespaces 2.Call tracking function always in the monitor's tick - not just if the beacon is active Signed-off-by: Leonid Chernin --- src/mon/NVMeofGwMap.cc | 13 +++++++++---- src/mon/NVMeofGwMon.cc | 33 ++++++++++++++++++++++----------- 2 files changed, 31 insertions(+), 15 deletions(-) diff --git a/src/mon/NVMeofGwMap.cc b/src/mon/NVMeofGwMap.cc index d60d3edefd2d5..068258289af81 100755 --- a/src/mon/NVMeofGwMap.cc +++ b/src/mon/NVMeofGwMap.cc @@ -166,6 +166,7 @@ int NVMeofGwMap::cfg_delete_gw( dout(4) << " Deleting GW :"<< gw_id << " in state " << state.availability << " Resulting GW availability: " << state.availability << dendl; + state.subsystems.clear();//ignore subsystems of this GW return 0; } } @@ -217,10 +218,13 @@ int NVMeofGwMap::do_delete_gw( int NVMeofGwMap::get_num_namespaces(const NvmeGwId &gw_id, const NvmeGroupKey& group_key, const BeaconSubsystems& subs) { - auto grpid = created_gws[group_key][gw_id].ana_grp_id ; + auto grpid = created_gws[group_key][gw_id].ana_grp_id; int num_ns = 0; - for (auto & subs_it:subs) { - for (auto & ns :subs_it.namespaces) { + if (subs.size() == 0) { + dout(20) << "Empty subsystems for GW " << gw_id << dendl; + } + for (auto & subsystem:subs) { + for (auto & ns :subsystem.namespaces) { if (ns.anagrpid == (grpid+1)) { num_ns++; } @@ -241,7 +245,8 @@ void NVMeofGwMap::track_deleting_gws(const NvmeGroupKey& group_key, do_delete_gw(gw_id, group_key); propose_pending = true; } - dout(4) << " to delete ? " << gw_id << " num_ns " << num_ns << dendl; + dout(4) << " to delete ? " << gw_id << " num_ns " << num_ns + << " subsystems size "<< subs.size() << dendl; break; // handle just one GW in "Deleting" state in time. } } diff --git a/src/mon/NVMeofGwMon.cc b/src/mon/NVMeofGwMon.cc index 544ad67472295..734e90defd946 100644 --- a/src/mon/NVMeofGwMon.cc +++ b/src/mon/NVMeofGwMon.cc @@ -115,18 +115,21 @@ void NVMeofGwMon::tick() _propose_pending |= propose; last_beacon.erase(lb); } else { - BeaconSubsystems *subsystems = - &pending_map.created_gws[lb.group_key][lb.gw_id].subsystems; - if (subsystems && subsystems->size() && old_group_key != lb.group_key) { - // to call track_deleting_gws once per each group-key - pending_map.track_deleting_gws(lb.group_key, *subsystems, propose); - old_group_key = lb.group_key; - _propose_pending |= propose; - } dout(20) << "beacon live for GW key: " << lb.gw_id << dendl; } } - + BeaconSubsystems empty_subsystems; + for (auto &[group_key, gws_states]: pending_map.created_gws) { + BeaconSubsystems *subsystems = &empty_subsystems; + for (auto& gw_state : gws_states) { // loop for GWs inside nqn group + subsystems = &gw_state.second.subsystems; + if (subsystems->size()) { // Set subsystems to the valid value + break; + } + } + pending_map.track_deleting_gws(group_key, *subsystems, propose); + _propose_pending |= propose; + } // Periodic: take care of not handled ANA groups pending_map.handle_abandoned_ana_groups(propose); _propose_pending |= propose; @@ -567,10 +570,18 @@ bool NVMeofGwMon::prepare_beacon(MonOpRequestRef op) // At this stage the gw has to be in the Created_gws if (gw == group_gws.end()) { - dout(4) << "Administratively deleted GW sends beacon " << gw_id << dendl; + dout(4) << "GW that does not appear in the map sends beacon, ignore " + << gw_id << dendl; + mon.no_reply(op); + goto false_return; // not sending ack to this beacon + } + if (pending_map.created_gws[group_key][gw_id].availability == + gw_availability_t::GW_DELETING) { + dout(4) << "GW sends beacon in DELETING state, ignore " + << gw_id << dendl; + mon.no_reply(op); goto false_return; // not sending ack to this beacon } - // deep copy the whole nonce map of this GW if (m->get_nonce_map().size()) { if (pending_map.created_gws[group_key][gw_id].nonce_map != -- 2.39.5