@@ -115,18 +115,21 @@ void NVMeofGwMon::tick()
115115 _propose_pending |= propose;
116116 last_beacon.erase (lb);
117117 } else {
118- BeaconSubsystems *subsystems =
119- &pending_map.created_gws [lb.group_key ][lb.gw_id ].subsystems ;
120- if (subsystems && subsystems->size () && old_group_key != lb.group_key ) {
121- // to call track_deleting_gws once per each group-key
122- pending_map.track_deleting_gws (lb.group_key , *subsystems, propose);
123- old_group_key = lb.group_key ;
124- _propose_pending |= propose;
125- }
126118 dout (20 ) << " beacon live for GW key: " << lb.gw_id << dendl;
127119 }
128120 }
129-
121+ BeaconSubsystems empty_subsystems;
122+ for (auto &[group_key, gws_states]: pending_map.created_gws ) {
123+ BeaconSubsystems *subsystems = &empty_subsystems;
124+ for (auto & gw_state : gws_states) { // loop for GWs inside nqn group
125+ subsystems = &gw_state.second .subsystems ;
126+ if (subsystems->size ()) { // Set subsystems to the valid value
127+ break ;
128+ }
129+ }
130+ pending_map.track_deleting_gws (group_key, *subsystems, propose);
131+ _propose_pending |= propose;
132+ }
130133 // Periodic: take care of not handled ANA groups
131134 pending_map.handle_abandoned_ana_groups (propose);
132135 _propose_pending |= propose;
@@ -567,10 +570,18 @@ bool NVMeofGwMon::prepare_beacon(MonOpRequestRef op)
567570
568571 // At this stage the gw has to be in the Created_gws
569572 if (gw == group_gws.end ()) {
570- dout (4 ) << " Administratively deleted GW sends beacon " << gw_id << dendl;
573+ dout (4 ) << " GW that does not appear in the map sends beacon, ignore "
574+ << gw_id << dendl;
575+ mon.no_reply (op);
576+ goto false_return; // not sending ack to this beacon
577+ }
578+ if (pending_map.created_gws [group_key][gw_id].availability ==
579+ gw_availability_t ::GW_DELETING) {
580+ dout (4 ) << " GW sends beacon in DELETING state, ignore "
581+ << gw_id << dendl;
582+ mon.no_reply (op);
571583 goto false_return; // not sending ack to this beacon
572584 }
573-
574585 // deep copy the whole nonce map of this GW
575586 if (m->get_nonce_map ().size ()) {
576587 if (pending_map.created_gws [group_key][gw_id].nonce_map !=
0 commit comments