Skip to content

Commit 985ae32

Browse files
authored
Merge pull request ceph#59999 from leonidc/tracking-gw-deleting
mon/nvmeofgw*: fix tracking gateways in DELETING state
2 parents 04da732 + cf5b9ea commit 985ae32

File tree

2 files changed

+31
-15
lines changed

2 files changed

+31
-15
lines changed

src/mon/NVMeofGwMap.cc

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,7 @@ int NVMeofGwMap::cfg_delete_gw(
166166
dout(4) << " Deleting GW :"<< gw_id << " in state "
167167
<< state.availability << " Resulting GW availability: "
168168
<< state.availability << dendl;
169+
state.subsystems.clear();//ignore subsystems of this GW
169170
return 0;
170171
}
171172
}
@@ -217,10 +218,13 @@ int NVMeofGwMap::do_delete_gw(
217218
int NVMeofGwMap::get_num_namespaces(const NvmeGwId &gw_id,
218219
const NvmeGroupKey& group_key, const BeaconSubsystems& subs)
219220
{
220-
auto grpid = created_gws[group_key][gw_id].ana_grp_id ;
221+
auto grpid = created_gws[group_key][gw_id].ana_grp_id;
221222
int num_ns = 0;
222-
for (auto & subs_it:subs) {
223-
for (auto & ns :subs_it.namespaces) {
223+
if (subs.size() == 0) {
224+
dout(20) << "Empty subsystems for GW " << gw_id << dendl;
225+
}
226+
for (auto & subsystem:subs) {
227+
for (auto & ns :subsystem.namespaces) {
224228
if (ns.anagrpid == (grpid+1)) {
225229
num_ns++;
226230
}
@@ -241,7 +245,8 @@ void NVMeofGwMap::track_deleting_gws(const NvmeGroupKey& group_key,
241245
do_delete_gw(gw_id, group_key);
242246
propose_pending = true;
243247
}
244-
dout(4) << " to delete ? " << gw_id << " num_ns " << num_ns << dendl;
248+
dout(4) << " to delete ? " << gw_id << " num_ns " << num_ns
249+
<< " subsystems size "<< subs.size() << dendl;
245250
break; // handle just one GW in "Deleting" state in time.
246251
}
247252
}

src/mon/NVMeofGwMon.cc

Lines changed: 22 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)