struct lnet_ioctl_peer_cfg {
struct libcfs_ioctl_hdr prcfg_hdr;
- lnet_nid_t prcfg_key_nid;
+ lnet_nid_t prcfg_prim_nid;
lnet_nid_t prcfg_cfg_nid;
__u32 prcfg_idx;
bool prcfg_mr;
return -EINVAL;
mutex_lock(&the_lnet.ln_api_mutex);
- rc = lnet_add_peer_ni_to_peer(cfg->prcfg_key_nid,
+ rc = lnet_add_peer_ni_to_peer(cfg->prcfg_prim_nid,
cfg->prcfg_cfg_nid,
cfg->prcfg_mr);
mutex_unlock(&the_lnet.ln_api_mutex);
return -EINVAL;
mutex_lock(&the_lnet.ln_api_mutex);
- rc = lnet_del_peer_ni_from_peer(cfg->prcfg_key_nid,
+ rc = lnet_del_peer_ni_from_peer(cfg->prcfg_prim_nid,
cfg->prcfg_cfg_nid);
mutex_unlock(&the_lnet.ln_api_mutex);
return rc;
(cfg->prcfg_bulk + sizeof(*lpni_cri));
mutex_lock(&the_lnet.ln_api_mutex);
- rc = lnet_get_peer_info(cfg->prcfg_idx, &cfg->prcfg_key_nid,
+ rc = lnet_get_peer_info(cfg->prcfg_idx, &cfg->prcfg_prim_nid,
&cfg->prcfg_cfg_nid, &cfg->prcfg_mr,
lpni_cri, lpni_stats);
mutex_unlock(&the_lnet.ln_api_mutex);
}
static int
-lnet_add_peer_ni_to_prim_lpni(lnet_nid_t key_nid, lnet_nid_t nid)
+lnet_add_peer_ni_to_prim_lpni(lnet_nid_t prim_nid, lnet_nid_t nid)
{
struct lnet_peer *peer, *primary_peer;
struct lnet_peer_ni *lpni = NULL, *klpni = NULL;
- LASSERT(key_nid != LNET_NID_ANY && nid != LNET_NID_ANY);
+ LASSERT(prim_nid != LNET_NID_ANY && nid != LNET_NID_ANY);
/*
* key nid must be created by this point. If not then this
* operation is not permitted
*/
- klpni = lnet_find_peer_ni_locked(key_nid);
+ klpni = lnet_find_peer_ni_locked(prim_nid);
if (!klpni)
return -ENOENT;
* lpni already exists in the system but it belongs to
* a different peer. We can't re-added it
*/
- if (peer->lp_primary_nid != key_nid && peer->lp_multi_rail) {
+ if (peer->lp_primary_nid != prim_nid && peer->lp_multi_rail) {
CERROR("Cannot add NID %s owned by peer %s to peer %s\n",
libcfs_nid2str(lpni->lpni_nid),
libcfs_nid2str(peer->lp_primary_nid),
- libcfs_nid2str(key_nid));
+ libcfs_nid2str(prim_nid));
return -EEXIST;
- } else if (peer->lp_primary_nid == key_nid) {
+ } else if (peer->lp_primary_nid == prim_nid) {
/*
* found a peer_ni that is already part of the
* peer. This is a no-op operation.
}
/*
- * TODO: else if (peer->lp_primary_nid != key_nid &&
+ * TODO: else if (peer->lp_primary_nid != prim_nid &&
* !peer->lp_multi_rail)
* peer is not an MR peer and it will be moved in the next
* step to klpni, so update its flags accordingly.
/*
* This API handles the following combinations:
- * Create a primary NI if only the key_nid is provided
+ * Create a primary NI if only the prim_nid is provided
* Create or add an lpni to a primary NI. Primary NI must've already
* been created
* Create a non-MR peer.
*/
int
-lnet_add_peer_ni_to_peer(lnet_nid_t key_nid, lnet_nid_t nid, bool mr)
+lnet_add_peer_ni_to_peer(lnet_nid_t prim_nid, lnet_nid_t nid, bool mr)
{
/*
* Caller trying to setup an MR like peer hierarchy but
* specifying it to be non-MR. This is not allowed.
*/
- if (key_nid != LNET_NID_ANY &&
+ if (prim_nid != LNET_NID_ANY &&
nid != LNET_NID_ANY && !mr)
return -EPERM;
/* Add the primary NID of a peer */
- if (key_nid != LNET_NID_ANY &&
+ if (prim_nid != LNET_NID_ANY &&
nid == LNET_NID_ANY && mr)
- return lnet_add_prim_lpni(key_nid);
+ return lnet_add_prim_lpni(prim_nid);
/* Add a NID to an existing peer */
- if (key_nid != LNET_NID_ANY &&
+ if (prim_nid != LNET_NID_ANY &&
nid != LNET_NID_ANY && mr)
- return lnet_add_peer_ni_to_prim_lpni(key_nid, nid);
+ return lnet_add_peer_ni_to_prim_lpni(prim_nid, nid);
/* Add a non-MR peer NI */
- if (((key_nid != LNET_NID_ANY &&
+ if (((prim_nid != LNET_NID_ANY &&
nid == LNET_NID_ANY) ||
- (key_nid == LNET_NID_ANY &&
+ (prim_nid == LNET_NID_ANY &&
nid != LNET_NID_ANY)) && !mr)
- return lnet_peer_ni_add_non_mr(key_nid != LNET_NID_ANY ?
- key_nid : nid);
+ return lnet_peer_ni_add_non_mr(prim_nid != LNET_NID_ANY ?
+ prim_nid : nid);
return 0;
}
int
-lnet_del_peer_ni_from_peer(lnet_nid_t key_nid, lnet_nid_t nid)
+lnet_del_peer_ni_from_peer(lnet_nid_t prim_nid, lnet_nid_t nid)
{
lnet_nid_t local_nid;
struct lnet_peer *peer;
struct lnet_peer_ni *lpni;
int rc;
- if (key_nid == LNET_NID_ANY)
+ if (prim_nid == LNET_NID_ANY)
return -EINVAL;
- local_nid = (nid != LNET_NID_ANY) ? nid : key_nid;
+ local_nid = (nid != LNET_NID_ANY) ? nid : prim_nid;
lpni = lnet_find_peer_ni_locked(local_nid);
if (!lpni)
return array;
}
-static int dispatch_peer_ni_cmd(lnet_nid_t knid, lnet_nid_t nid, __u32 cmd,
+static int dispatch_peer_ni_cmd(lnet_nid_t pnid, lnet_nid_t nid, __u32 cmd,
struct lnet_ioctl_peer_cfg *data,
char *err_str, char *cmd_str)
{
int rc;
- data->prcfg_key_nid = knid;
+ data->prcfg_prim_nid = pnid;
data->prcfg_cfg_nid = nid;
rc = l_ioctl(LNET_DEV_ID, cmd, data);
return rc;
}
-int lustre_lnet_config_peer_nid(char *knid, char **nid, int num_nids,
+int lustre_lnet_config_peer_nid(char *pnid, char **nid, int num_nids,
bool mr, int seq_no, struct cYAML **err_rc)
{
struct lnet_ioctl_peer_cfg data;
- lnet_nid_t key_nid = LNET_NID_ANY;
+ lnet_nid_t prim_nid = LNET_NID_ANY;
int rc = LUSTRE_CFG_RC_NO_ERR;
int idx = 0;
bool nid0_used = false;
char err_str[LNET_MAX_STR_LEN] = {0};
lnet_nid_t *nids = allocate_create_nid_array(nid, num_nids, err_str);
- if (knid) {
- key_nid = libcfs_str2nid(knid);
- if (key_nid == LNET_NID_ANY) {
+ if (pnid) {
+ prim_nid = libcfs_str2nid(pnid);
+ if (prim_nid == LNET_NID_ANY) {
snprintf(err_str, sizeof(err_str),
"bad key NID: '%s'",
- knid);
+ pnid);
rc = LUSTRE_CFG_RC_MISSING_PARAM;
goto out;
}
rc = LUSTRE_CFG_RC_MISSING_PARAM;
goto out;
} else {
- key_nid = LNET_NID_ANY;
+ prim_nid = LNET_NID_ANY;
}
snprintf(err_str, sizeof(err_str), "\"Success\"");
data.prcfg_mr = mr;
/*
- * if key_nid is not specified use the first nid in the list of
- * nids provided as the key_nid. NOTE: on entering 'if' we must
+ * if prim_nid is not specified use the first nid in the list of
+ * nids provided as the prim_nid. NOTE: on entering 'if' we must
* have at least 1 NID
*/
- if (key_nid == LNET_NID_ANY) {
+ if (prim_nid == LNET_NID_ANY) {
nid0_used = true;
- key_nid = nids[0];
+ prim_nid = nids[0];
}
- /* Create the key_nid first */
- rc = dispatch_peer_ni_cmd(key_nid, LNET_NID_ANY,
+ /* Create the prim_nid first */
+ rc = dispatch_peer_ni_cmd(prim_nid, LNET_NID_ANY,
IOC_LIBCFS_ADD_PEER_NI,
&data, err_str, "add");
/* add the rest of the nids to the key nid if any are available */
for (idx = nid0_used ? 1 : 0 ; nids && idx < num_nids; idx++) {
/*
- * If key_nid is not provided then the first nid in the
- * list becomes the key_nid. First time round the loop use
+ * If prim_nid is not provided then the first nid in the
+ * list becomes the prim_nid. First time round the loop use
* LNET_NID_ANY for the first parameter, then use nid[0]
* as the key nid after wards
*/
- rc = dispatch_peer_ni_cmd(key_nid, nids[idx],
+ rc = dispatch_peer_ni_cmd(prim_nid, nids[idx],
IOC_LIBCFS_ADD_PEER_NI, &data,
err_str, "add");
return rc;
}
-int lustre_lnet_del_peer_nid(char *knid, char **nid, int num_nids,
+int lustre_lnet_del_peer_nid(char *pnid, char **nid, int num_nids,
int seq_no, struct cYAML **err_rc)
{
struct lnet_ioctl_peer_cfg data;
- lnet_nid_t key_nid;
+ lnet_nid_t prim_nid;
int rc = LUSTRE_CFG_RC_NO_ERR;
int idx = 0;
char err_str[LNET_MAX_STR_LEN] = {0};
lnet_nid_t *nids = allocate_create_nid_array(nid, num_nids, err_str);
- if (knid == NULL) {
+ if (pnid == NULL) {
snprintf(err_str, sizeof(err_str),
"\"Primary nid is not provided\"");
rc = LUSTRE_CFG_RC_MISSING_PARAM;
goto out;
} else {
- key_nid = libcfs_str2nid(knid);
- if (key_nid == LNET_NID_ANY) {
+ prim_nid = libcfs_str2nid(pnid);
+ if (prim_nid == LNET_NID_ANY) {
rc = LUSTRE_CFG_RC_BAD_PARAM;
snprintf(err_str, sizeof(err_str),
"bad key NID: '%s'",
- knid);
+ pnid);
goto out;
}
}
LIBCFS_IOC_INIT_V2(data, prcfg_hdr);
if (!nids || nids[0] == LNET_NID_ANY) {
- rc = dispatch_peer_ni_cmd(key_nid, LNET_NID_ANY,
+ rc = dispatch_peer_ni_cmd(prim_nid, LNET_NID_ANY,
IOC_LIBCFS_DEL_PEER_NI,
&data, err_str, "del");
goto out;
}
for (idx = 0; nids && idx < num_nids; idx++) {
- rc = dispatch_peer_ni_cmd(key_nid, nids[idx],
+ rc = dispatch_peer_ni_cmd(prim_nid, nids[idx],
IOC_LIBCFS_DEL_PEER_NI, &data,
err_str, "del");
int lustre_lnet_show_peer(char *knid, int detail, int seq_no,
struct cYAML **show_rc, struct cYAML **err_rc)
{
+ /*
+ * TODO: This function is changing in a future patch to accommodate
+ * PEER_LIST and proper filtering on any nid of the peer
+ */
struct lnet_ioctl_peer_cfg *peer_info;
struct lnet_peer_ni_credit_info *lpni_cri;
struct lnet_ioctl_element_stats *lpni_stats;
}
if (primary_nid != LNET_NID_ANY &&
- primary_nid != peer_info->prcfg_key_nid)
+ primary_nid != peer_info->prcfg_prim_nid)
continue;
lpni_cri = (struct lnet_peer_ni_credit_info*)peer_info->prcfg_bulk;
if (peer == NULL)
goto out;
- if (peer_info->prcfg_key_nid != prev_primary_nid) {
- prev_primary_nid = peer_info->prcfg_key_nid;
+ if (peer_info->prcfg_prim_nid != prev_primary_nid) {
+ prev_primary_nid = peer_info->prcfg_prim_nid;
new_peer = true;
}
if (new_peer) {
- lnet_nid_t pnid = peer_info->prcfg_key_nid;
+ lnet_nid_t pnid = peer_info->prcfg_prim_nid;
if (cYAML_create_string(peer, "primary nid",
libcfs_nid2str(pnid))
== NULL)
{
char **nids = NULL;
int num, rc;
- struct cYAML *seq_no, *key_nid, *non_mr;
+ struct cYAML *seq_no, *prim_nid, *non_mr;
num = yaml_copy_peer_nids(tree, &nids);
if (num < 0)
return num;
seq_no = cYAML_get_object_item(tree, "seq_no");
- key_nid = cYAML_get_object_item(tree, "primary nid");
+ prim_nid = cYAML_get_object_item(tree, "primary nid");
non_mr = cYAML_get_object_item(tree, "non_mr");
- rc = lustre_lnet_config_peer_nid((key_nid) ? key_nid->cy_valuestring : NULL,
+ rc = lustre_lnet_config_peer_nid((prim_nid) ? prim_nid->cy_valuestring : NULL,
nids, num,
(non_mr) ? false : true,
(seq_no) ? seq_no->cy_valueint : -1,
{
char **nids = NULL;
int num, rc;
- struct cYAML *seq_no, *key_nid;
+ struct cYAML *seq_no, *prim_nid;
num = yaml_copy_peer_nids(tree, &nids);
if (num < 0)
return num;
seq_no = cYAML_get_object_item(tree, "seq_no");
- key_nid = cYAML_get_object_item(tree, "primary nid");
+ prim_nid = cYAML_get_object_item(tree, "primary nid");
- rc = lustre_lnet_del_peer_nid((key_nid) ? key_nid->cy_valuestring : NULL,
+ rc = lustre_lnet_del_peer_nid((prim_nid) ? prim_nid->cy_valuestring : NULL,
nids, num,
(seq_no) ? seq_no->cy_valueint : -1,
err_rc);
show_rc, err_rc);
}
-static int handle_yaml_show_credits(struct cYAML *tree, struct cYAML **show_rc,
- struct cYAML **err_rc)
+static int handle_yaml_show_peers(struct cYAML *tree, struct cYAML **show_rc,
+ struct cYAML **err_rc)
{
- struct cYAML *seq_no, *key_nid, *detail;
+ struct cYAML *seq_no, *nid, *detail;
seq_no = cYAML_get_object_item(tree, "seq_no");
detail = cYAML_get_object_item(tree, "detail");
- key_nid = cYAML_get_object_item(tree, "key_nid");
+ nid = cYAML_get_object_item(tree, "nid");
- return lustre_lnet_show_peer((key_nid) ? key_nid->cy_valuestring : NULL,
+ return lustre_lnet_show_peer((nid) ? nid->cy_valuestring : NULL,
(detail) ? detail->cy_valueint : 0,
(seq_no) ? seq_no->cy_valueint : -1,
show_rc, err_rc);
{"net", handle_yaml_show_net},
{"buffers", handle_yaml_show_routing},
{"routing", handle_yaml_show_routing},
- {"credits", handle_yaml_show_credits},
+ {"peer", handle_yaml_show_peers},
{"statistics", handle_yaml_show_stats},
{"numa", handle_yaml_show_numa},
{NULL, NULL}
/*
* lustre_lnet_config_peer_nid
- * Add a peer nid to an peer identified by knid. If no knid is given
+ * Add a peer nid to a peer with primary nid pnid. If no pnid is given
* then the first nid in the nid list becomes the primary nid for
* a newly created peer.
- * Otherwise if knid is provided an it's unique then a new peer is
- * created with knid as the primary NID and the nids in the nid list as
+ * Otherwise if pnid is provided and it's unique then a new peer is
+ * created with pnid as the primary NID and the nids in the nid list as
* secondary nids.
- * If any of the peers nids provided in with exception to the knid is
+ * If any of the peers nids provided in with exception to the pnid is
* not unique the operation fails. Some peer nids might have already
* been added. It's the role of the caller of this API to remove the
* added NIDs if they wish.
*
- * knid - Key NID of the peer
+ * pnid - Primary NID of the peer
* nid - list of nids to add
* num_nids - number of nids in the nid array
* mr - true if this peer is MR capable.
* seq_no - sequence number of the command
* err_rc - YAML strucutre of the resultant return code.
*/
-int lustre_lnet_config_peer_nid(char *knid, char **nid, int num_nids,
+int lustre_lnet_config_peer_nid(char *pnid, char **nid, int num_nids,
bool mr, int seq_no, struct cYAML **err_rc);
/*
* lustre_lnet_del_peer_nid
- * Delete the nids identified in the nid list from the peer identified by
- * knid. If knid is NULL or it doesn't identify a peer the operation
+ * Delete the nids given in the nid list from the peer with primary NID
+ * pnid. If pnid is NULL or it doesn't identify a peer the operation
* fails and no change happens to the system.
* The operation is aborted on the first NID that fails to be deleted.
*
- * knid - Key NID of the peer
+ * pnid - Primary NID of the peer
* nid - list of nids to add
* num_nids - number of nids in the nid array
* seq_no - sequence number of the command
* err_rc - YAML strucutre of the resultant return code.
*/
-int lustre_lnet_del_peer_nid(char *knid, char **nid, int num_nids,
+int lustre_lnet_del_peer_nid(char *pnid, char **nid, int num_nids,
int seq_no, struct cYAML **err_rc);
/*
* lustre_lnet_show_peer
- * Show the peer identified by knid. If knid is NULL all peers in the
- * system are shown.
+ * Show the peer identified by nid, knid. If knid is NULL all
+ * peers in the system are shown.
*
- * knid - Key NID of the peer
+ * knid - A NID of the peer
* detail - display detailed information
* seq_no - sequence number of the command
* show_rc - YAML structure of the resultant show
command_t peer_cmds[] = {
{"add", jt_add_peer_nid, 0, "add a peer NID\n"
- "\t--key_nid: NID to identify peer. If not provided then the first\n"
- "\t NID in the list becomes the key NID of a newly created\n"
- "\t peer. \n"
+ "\t--prim_nid: Primary NID of the peer. If not provided then the first\n"
+ "\t NID in the list becomes the Primary NID of a newly created\n"
+ "\t peer. \n"
"\t--nid: one or more peer NIDs\n"
"\t--non_mr: create this peer as not Multi-Rail capable\n"},
{"del", jt_del_peer_nid, 0, "delete a peer NID\n"
- "\t--key_nid: NID to identify peer.\n"
+ "\t--prim_nid: Primary NID of the peer.\n"
"\t--nid: list of NIDs to remove. If none provided,\n"
"\t peer is deleted\n"},
{"show", jt_show_peer, 0, "show peer credits\n"
- "\t--primary_nid: NID of peer to filter on.\n"},
+ "\t--nid: NID of peer to filter on.\n"},
{ 0, 0, 0, NULL }
};
static int jt_add_peer_nid(int argc, char **argv)
{
- char *key_nid = NULL;
+ char *prim_nid = NULL;
char **nids = NULL, **nids2 = NULL;
int size = 0;
struct cYAML *err_rc = NULL;
const char *const short_options = "k:n:mh";
const struct option long_options[] = {
- { "key_nid", 1, NULL, 'k' },
+ { "prim_nid", 1, NULL, 'k' },
{ "nid", 1, NULL, 'n' },
{ "non_mr", 0, NULL, 'm'},
{ "help", 0, NULL, 'h' },
long_options, NULL)) != -1) {
switch (opt) {
case 'k':
- key_nid = optarg;
+ prim_nid = optarg;
break;
case 'n':
size = lustre_lnet_parse_nids(optarg, nids, size,
}
}
- rc = lustre_lnet_config_peer_nid(key_nid, nids, size,
+ rc = lustre_lnet_config_peer_nid(prim_nid, nids, size,
!non_mr, -1, &err_rc);
failed:
static int jt_del_peer_nid(int argc, char **argv)
{
- char *key_nid = NULL;
+ char *prim_nid = NULL;
char **nids = NULL, **nids2 = NULL;
struct cYAML *err_rc = NULL;
int rc = LUSTRE_CFG_RC_NO_ERR, opt, i, size = 0;
const char *const short_options = "k:n:h";
const struct option long_options[] = {
- { "key_nid", 1, NULL, 'k' },
+ { "prim_nid", 1, NULL, 'k' },
{ "nid", 1, NULL, 'n' },
{ "help", 0, NULL, 'h' },
{ NULL, 0, NULL, 0 },
long_options, NULL)) != -1) {
switch (opt) {
case 'k':
- key_nid = optarg;
+ prim_nid = optarg;
break;
case 'n':
size = lustre_lnet_parse_nids(optarg, nids, size,
}
}
- rc = lustre_lnet_del_peer_nid(key_nid, nids, size, -1, &err_rc);
+ rc = lustre_lnet_del_peer_nid(prim_nid, nids, size, -1, &err_rc);
failed:
for (i = 0; i < size; i++)
static int jt_show_peer(int argc, char **argv)
{
- char *key_nid = NULL;
+ char *nid = NULL;
int rc, opt;
struct cYAML *err_rc = NULL, *show_rc = NULL;
int detail = 0;
const char *const short_options = "k:vh";
const struct option long_options[] = {
- { "key_nid", 1, NULL, 'k' },
+ { "nid", 1, NULL, 'n' },
{ "verbose", 0, NULL, 'v' },
{ "help", 0, NULL, 'h' },
{ NULL, 0, NULL, 0 },
long_options, NULL)) != -1) {
switch (opt) {
case 'k':
- key_nid = optarg;
+ nid = optarg;
break;
case 'v':
detail = 1;
break;
case 'h':
- print_help(peer_cmds, "peer", "add");
+ print_help(peer_cmds, "peer", "show");
return 0;
default:
return 0;
}
}
- rc = lustre_lnet_show_peer(key_nid, detail, -1, &show_rc, &err_rc);
+ rc = lustre_lnet_show_peer(nid, detail, -1, &show_rc, &err_rc);
if (rc != LUSTRE_CFG_RC_NO_ERR)
cYAML_print_tree2file(stderr, err_rc);