Skip to content

Commit

Permalink
add validation of the map
Browse files Browse the repository at this point in the history
Signed-off-by: Leonid Chernin <[email protected]>
  • Loading branch information
Leonid Chernin committed Apr 18, 2024
1 parent 1c8eaae commit 78ac9ff
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 0 deletions.
35 changes: 35 additions & 0 deletions src/mon/NVMeofGwMap.cc
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ int NVMeofGwMap::process_gw_map_gw_down(const NvmeGwId &gw_id, const NvmeGroupKe
st.standby_state(i);
}
propose_pending = true; // map should reflect that gw becames unavailable
if (propose_pending) validate_gw_map(group_key);
}
else {
dout(1) << __FUNCTION__ << "ERROR GW-id was not found in the map " << gw_id << dendl;
Expand Down Expand Up @@ -152,6 +153,7 @@ void NVMeofGwMap::process_gw_map_ka(const NvmeGwId &gw_id, const NvmeGroupKey& g
fsm_handle_gw_alive (gw_id, group_key, gw_state->second, st.sm_state[i], i, last_osd_epoch, propose_pending);
}
}
if (propose_pending) validate_gw_map(group_key);
}


Expand Down Expand Up @@ -192,6 +194,9 @@ void NVMeofGwMap::handle_abandoned_ana_groups(bool& propose)
find_failback_gw(gw_id, group_key, propose);
}
}
if (propose) {
validate_gw_map(group_key);
}
}
}

Expand Down Expand Up @@ -453,6 +458,7 @@ void NVMeofGwMap::fsm_handle_gw_delete (const NvmeGwId &gw_id, const NvmeGroupKe
ceph_assert(false);
}
}
if (map_modified) validate_gw_map(group_key);
}

void NVMeofGwMap::fsm_handle_to_expired(const NvmeGwId &gw_id, const NvmeGroupKey& group_key, NvmeAnaGrpId grpid, bool &map_modified)
Expand Down Expand Up @@ -494,6 +500,7 @@ void NVMeofGwMap::fsm_handle_to_expired(const NvmeGwId &gw_id, const NvmeGroupKe
dout(1) << " Expired GW_WAIT_FAILOVER_PREPARED timer from GW " << gw_id << " ANA groupId: "<< grpid << dendl;
ceph_assert(false);
}
if (map_modified) validate_gw_map(group_key);
}

NvmeGwCreated& NVMeofGwMap::find_already_created_gw(const NvmeGwId &gw_id, const NvmeGroupKey& group_key)
Expand Down Expand Up @@ -555,6 +562,34 @@ int NVMeofGwMap::blocklist_gw(const NvmeGwId &gw_id, const NvmeGroupKey& group_k
return 0;
}

void NVMeofGwMap::validate_gw_map(const NvmeGroupKey& group_key)
{
NvmeAnaGrpId anas[MAX_SUPPORTED_ANA_GROUPS];
int i = 0;
int max_groups = 0;
for (auto& gw_created_pair: Created_gws[group_key]) {
auto& st = gw_created_pair.second;
anas[i++] = st.ana_grp_id;
}
max_groups = i;
for(int i = 0; i < max_groups; i++)
{
int ana_group = anas[i];
int count = 0;
for (auto& gw_created_pair: Created_gws[group_key]) {
auto& st = gw_created_pair.second;
if (st.sm_state[ana_group] == GW_STATES_PER_AGROUP_E::GW_ACTIVE_STATE){
count ++;
if(count == 2) {
dout(1) << "number active states per ana-group " << ana_group << "more than 1 in pool-group " << group_key << dendl;
dout(1) << Created_gws[group_key] << dendl;
ceph_assert(false);
}
}
}
}
}

void NVMeofGwMap::update_active_timers( bool &propose_pending ){

//dout(4) << __func__ << " called, p_monitor: " << mon << dendl;
Expand Down
1 change: 1 addition & 0 deletions src/mon/NVMeofGwMap.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ class NVMeofGwMap

int get_timer (const NvmeGwId &gw_id, const NvmeGroupKey& group_key, NvmeAnaGrpId anagrpid);
void cancel_timer(const NvmeGwId &gw_id, const NvmeGroupKey& group_key, NvmeAnaGrpId anagrpid);
void validate_gw_map(const NvmeGroupKey& group_key);

public:
void encode(ceph::buffer::list &bl) const {
Expand Down
1 change: 1 addition & 0 deletions src/mon/NVMeofGwMon.cc
Original file line number Diff line number Diff line change
Expand Up @@ -332,6 +332,7 @@ bool NVMeofGwMon::prepare_command(MonOpRequestRef op)

if( map.Created_gws[group_key].size()){
f->open_object_section("common");
f->dump_unsigned("epoch", map.epoch);
f->dump_string("pool", pool);
f->dump_string("group", group);
f->dump_unsigned("num gws", map.Created_gws[group_key].size());
Expand Down

0 comments on commit 78ac9ff

Please sign in to comment.