"administratively disables nvmeof gateway id for (pool, group)",
"mgr", "rw")
-COMMAND("nvme-gw set-locale"
+COMMAND("nvme-gw set-location"
" name=id,type=CephString"
" name=pool,type=CephString"
" name=group,type=CephString"
- " name=locale,type=CephString",
+ " name=location,type=CephString",
"set location for nvmeof gateway id for (pool, group)",
"mgr", "rw")
COMMAND("nvme-gw start-failback"
" name=pool,type=CephString"
" name=group,type=CephString"
- " name=locale,type=CephString",
+ " name=location,type=CephString",
"start failbacks for recovered location within (pool, group)",
"mgr", "rw")
return 0;
}
+bool NVMeofGwMap::validate_number_locations(int num_gws, int num_locations)
+{
+ int approved_locations;
+
+ if (num_gws <= 2) {
+ approved_locations = 1;
+ } else if (num_gws <= 6) {
+ approved_locations = 2;
+ } else {
+ approved_locations = 3;
+ }
+ return num_locations <= approved_locations;
+}
+
int NVMeofGwMap::cfg_set_location(const NvmeGwId &gw_id,
const NvmeGroupKey& group_key,
std::string &location, bool &propose_pending, bool test) {
// validate that location differs from gw location
auto& gws_states = created_gws[group_key];
auto gw_state = gws_states.find(gw_id);
+ std::set<std::string> locations;
+ if (!HAVE_FEATURE(mon->get_quorum_con_features(), NVMEOF_BEACON_DIFF)) {
+ dout(4) << "Command is not allowed - feature is not installed"
+ << group_key << " " << gw_id << dendl;
+ return -EINVAL;
+ }
+ int num_gws = gws_states.size();
if (gw_state != gws_states.end()) {
auto& st = gw_state->second;
if (st.location == location) {
dout(4) << "GW-id same location is set " << group_key
- << " " << gw_id << " " << location << dendl;
+ << " " << gw_id << " " << location << dendl;
return 0;
}
else {
- //TODO check that old location still valid
- // if location completely removed need to find namespaces
- // belong to location - if found at least one - reject the command
bool last_gw = true;
for (auto& states: created_gws[group_key]) {
auto &state = states.second;
+ // calculate number set locations
+ locations.insert(state.location);
if (state.location == st.location && states.first != gw_id) {
last_gw = false;
break;
}
}
+ if (last_gw) { // this location would be removed so erase from set
+ locations.erase(st.location);
+ }
+ locations.insert(location);
+ dout(10) << "num GWs " << num_gws << " num set locations "
+ << locations.size() << dendl;
+ /*bool rc = validate_number_locations(num_gws, locations.size());
+ if (rc ==false) {
+ dout(4) << "Try to define invalid number of locations "
+ << locations.size() << dendl;
+ return -EINVAL;
+ }*/
if (last_gw) {
//const BeaconSubsystems subs;
//int num = get_num_namespaces(gw_id, group_key, subs, st.location);
void increment_gw_epoch(const NvmeGroupKey& group_key);
int find_failover_gw_logic(NvmeGwMonStates& gws_states,
NvmeLocation& location, NvmeGwId& min_loaded_gw_id);
+ bool validate_number_locations(int num_gws, int num_locations);
public:
int blocklist_gw(
if (rc == 0 && propose == true) {
response = true;
}
- } else if (prefix == "nvme-gw set-locale") {
+ } else if (prefix == "nvme-gw set-location") {
- std::string id, pool, group, locale;
+ std::string id, pool, group, location;
cmd_getval(cmdmap, "id", id);
cmd_getval(cmdmap, "pool", pool);
cmd_getval(cmdmap, "group", group);
- cmd_getval(cmdmap, "locale", locale);
+ cmd_getval(cmdmap, "location", location);
auto group_key = std::make_pair(pool, group);
dout(10) << " id "<< id <<" pool "<< pool << " group "<< group
- <<" locale "<< locale << dendl;
+ <<" location "<< location << dendl;
bool propose = false;
- rc = pending_map.cfg_set_location(id, group_key, locale, propose);
+ rc = pending_map.cfg_set_location(id, group_key, location, propose);
if (rc == -EINVAL || rc == -EEXIST) {
err = rc;
dout (4) << "Error: GW cannot set location " << id
response = true;
}
} else if (prefix == "nvme-gw start-failback") {
- std::string id, pool, group, locale;
+ std::string id, pool, group, location;
bool propose = false;
cmd_getval(cmdmap, "pool", pool);
cmd_getval(cmdmap, "group", group);
- cmd_getval(cmdmap, "locale", locale);
+ cmd_getval(cmdmap, "location", location);
auto group_key = std::make_pair(pool, group);
dout(10) << id <<" pool "<< pool << " group "<< group
- <<" locale "<< locale << dendl;
+ <<" location "<< location << dendl;
rc = pending_map.cfg_start_inter_location_failback(group_key,
- locale, propose);
+ location, propose);
}
getline(sstrm, rs);
if (response == false) {