@@ -83,6 +83,14 @@ int NVMeofGwMap::cfg_add_gw(
8383 const NvmeGwId &gw_id, const NvmeGroupKey& group_key)
8484{
8585 std::set<NvmeAnaGrpId> allocated;
86+ if (HAVE_FEATURE (mon->get_quorum_con_features (), NVMEOFHAMAP)) {
87+ auto gw_epoch_it = gw_epoch.find (group_key);
88+ if (gw_epoch_it == gw_epoch.end ()) {
89+ gw_epoch[group_key] = epoch;
90+ dout (10 ) << " Allocated first gw_epoch : group_key "
91+ << group_key << " epoch " << gw_epoch[group_key] << dendl;
92+ }
93+ }
8694 for (auto & itr: created_gws[group_key]) {
8795 allocated.insert (itr.second .ana_grp_id );
8896 if (itr.first == gw_id) {
@@ -190,8 +198,10 @@ int NVMeofGwMap::do_erase_gw_id(const NvmeGwId &gw_id,
190198 fsm_timers.erase (group_key);
191199
192200 created_gws[group_key].erase (gw_id);
193- if (created_gws[group_key].size () == 0 )
201+ if (created_gws[group_key].size () == 0 ) {
194202 created_gws.erase (group_key);
203+ gw_epoch.erase (group_key);
204+ }
195205 return 0 ;
196206}
197207
@@ -221,6 +231,23 @@ int NVMeofGwMap::do_delete_gw(
221231 return -EINVAL;
222232}
223233
234+ void NVMeofGwMap::gw_performed_startup (const NvmeGwId &gw_id,
235+ const NvmeGroupKey& group_key, bool &propose_pending)
236+ {
237+ dout (4 ) << " GW performed the full startup " << gw_id << dendl;
238+ propose_pending = true ;
239+ increment_gw_epoch ( group_key);
240+ }
241+
242+ void NVMeofGwMap::increment_gw_epoch (const NvmeGroupKey& group_key)
243+ {
244+ if (HAVE_FEATURE (mon->get_quorum_con_features (), NVMEOFHAMAP)) {
245+ gw_epoch[group_key] ++;
246+ dout (4 ) << " incremented epoch of " << group_key
247+ << " " << gw_epoch[group_key] << dendl;
248+ }
249+ }
250+
224251int NVMeofGwMap::get_num_namespaces (const NvmeGwId &gw_id,
225252 const NvmeGroupKey& group_key, const BeaconSubsystems& subs)
226253{
@@ -273,7 +300,10 @@ int NVMeofGwMap::process_gw_map_gw_no_subsys_no_listeners(
273300 gw_id, group_key, state_itr.second ,state_itr.first , propose_pending);
274301 }
275302 propose_pending = true ; // map should reflect that gw becames Created
276- if (propose_pending) validate_gw_map (group_key);
303+ if (propose_pending) {
304+ validate_gw_map (group_key);
305+ increment_gw_epoch (group_key);
306+ }
277307 } else {
278308 dout (1 ) << __FUNCTION__ << " ERROR GW-id was not found in the map "
279309 << gw_id << dendl;
@@ -299,7 +329,10 @@ int NVMeofGwMap::process_gw_map_gw_down(
299329 state_itr.second = gw_states_per_group_t ::GW_STANDBY_STATE;
300330 }
301331 propose_pending = true ; // map should reflect that gw becames Unavailable
302- if (propose_pending) validate_gw_map (group_key);
332+ if (propose_pending) {
333+ validate_gw_map (group_key);
334+ increment_gw_epoch (group_key);
335+ }
303336 } else {
304337 dout (1 ) << __FUNCTION__ << " ERROR GW-id was not found in the map "
305338 << gw_id << dendl;
@@ -338,7 +371,10 @@ void NVMeofGwMap::process_gw_map_ka(
338371 state_itr.first , last_osd_epoch, propose_pending);
339372 }
340373 }
341- if (propose_pending) validate_gw_map (group_key);
374+ if (propose_pending) {
375+ validate_gw_map (group_key);
376+ increment_gw_epoch (group_key);
377+ }
342378}
343379
344380void NVMeofGwMap::handle_abandoned_ana_groups (bool & propose)
@@ -387,6 +423,7 @@ void NVMeofGwMap::handle_abandoned_ana_groups(bool& propose)
387423 }
388424 if (propose) {
389425 validate_gw_map (group_key);
426+ increment_gw_epoch (group_key);
390427 }
391428 }
392429}
@@ -751,7 +788,10 @@ void NVMeofGwMap::fsm_handle_gw_delete(
751788 << " for GW " << gw_id << dendl;
752789 }
753790 }
754- if (map_modified) validate_gw_map (group_key);
791+ if (map_modified) {
792+ validate_gw_map (group_key);
793+ increment_gw_epoch (group_key);
794+ }
755795}
756796
757797void NVMeofGwMap::fsm_handle_to_expired (
@@ -817,7 +857,10 @@ void NVMeofGwMap::fsm_handle_to_expired(
817857 // another Trigger for GW down (failover)
818858 process_gw_map_gw_down (gw_id, group_key, map_modified);
819859 }
820- if (map_modified) validate_gw_map (group_key);
860+ if (map_modified) {
861+ validate_gw_map (group_key);
862+ increment_gw_epoch (group_key);
863+ }
821864}
822865
823866struct CMonRequestProposal : public Context {
0 commit comments