]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mon/nvmeofgw*: fix tracking gateways in DELETING state 59999/head
authorLeonid Chernin <leonidc@il.ibm.com>
Thu, 26 Sep 2024 13:47:00 +0000 (13:47 +0000)
committerLeonid Chernin <leonidc@il.ibm.com>
Fri, 27 Sep 2024 08:36:57 +0000 (08:36 +0000)
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 <leonidc@il.ibm.com>
src/mon/NVMeofGwMap.cc
src/mon/NVMeofGwMon.cc

index d60d3edefd2d59f07d80f298e12d751d9d6eb206..068258289af81da8d8167591fced8e912be70708 100755 (executable)
@@ -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.
     }
   }
index 544ad6747229526434818d6cd665a29e43060af6..734e90defd946223008a241b071c1a157389ed6a 100644 (file)
@@ -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 !=