Commit b5fb6f1f authored by Chris Horn's avatar Chris Horn Committed by Oleg Drokin
Browse files

LU-12222 lnet: Introduce constant for the lolnd NID

This patch adds a new constant, LNET_NID_LO_0, to represent the lolnd
NID 0@lo.

Lustre-change: https://review.whamcloud.com/38312
Lustre-commit: 56203e4b



HPE-bug-id: LUS-8457
Signed-off-by: default avatarChris Horn <hornc@cray.com>
Change-Id: I3e57637f297b8de306905a447af8f025e31d1fcf
Reviewed-on: https://review.whamcloud.com/38863

Tested-by: default avatarjenkins <devops@whamcloud.com>
Tested-by: default avatarMaloo <maloo@whamcloud.com>
Reviewed-by: default avatarSerguei Smirnov <ssmirnov@whamcloud.com>
Reviewed-by: default avatarAndreas Dilger <adilger@whamcloud.com>
parent 07aa6595
......@@ -107,6 +107,9 @@ static inline __u32 LNET_MKNET(__u32 type, __u32 num)
return (type << 16) | num;
}
/** The lolnd NID (i.e. myself) */
#define LNET_NID_LO_0 LNET_MKNID(LNET_MKNET(LOLND, 0), 0)
#define WIRE_ATTR __attribute__((packed))
/* Packed version of struct lnet_process_id to transfer via network */
......
......@@ -1579,7 +1579,7 @@ lnet_ping_info_validate(struct lnet_ping_info *pinfo)
/* Loopback is guaranteed to be present */
if (pinfo->pi_nnis < 1 || pinfo->pi_nnis > lnet_interfaces_max)
return -ERANGE;
if (LNET_NETTYP(LNET_NIDNET(LNET_PING_INFO_LONI(pinfo))) != LOLND)
if (LNET_PING_INFO_LONI(pinfo) != LNET_NID_LO_0)
return -EPROTO;
return 0;
}
......@@ -2756,7 +2756,7 @@ lnet_fill_ni_info(struct lnet_ni *ni, struct lnet_ioctl_config_ni *cfg_ni,
}
cfg_ni->lic_nid = ni->ni_nid;
if (LNET_NETTYP(LNET_NIDNET(ni->ni_nid)) == LOLND)
if (ni->ni_nid == LNET_NID_LO_0)
cfg_ni->lic_status = LNET_NI_STATUS_UP;
else
cfg_ni->lic_status = ni->ni_status->ns_status;
......@@ -2848,7 +2848,7 @@ lnet_fill_ni_info_legacy(struct lnet_ni *ni,
config->cfg_config_u.cfg_net.net_peer_rtr_credits =
ni->ni_net->net_tunables.lct_peer_rtr_credits;
if (LNET_NETTYP(LNET_NIDNET(ni->ni_nid)) == LOLND)
if (ni->ni_nid == LNET_NID_LO_0)
net_config->ni_status = LNET_NI_STATUS_UP;
else
net_config->ni_status = ni->ni_status->ns_status;
......
......@@ -1124,26 +1124,26 @@ lnet_parse_priority(char *str, unsigned int *priority, char **token)
}
static int
lnet_parse_route (char *str, int *im_a_router)
lnet_parse_route(char *str, int *im_a_router)
{
/* static scratch buffer OK (single threaded) */
static char cmd[LNET_SINGLE_TEXTBUF_NOB];
static char cmd[LNET_SINGLE_TEXTBUF_NOB];
struct list_head nets;
struct list_head gateways;
struct list_head nets;
struct list_head gateways;
struct list_head *tmp1;
struct list_head *tmp2;
__u32 net;
lnet_nid_t nid;
struct lnet_text_buf *ltb;
int rc;
char *sep;
char *token = str;
int ntokens = 0;
int myrc = -1;
__u32 hops;
int got_hops = 0;
unsigned int priority = 0;
__u32 net;
lnet_nid_t nid;
struct lnet_text_buf *ltb;
int rc;
char *sep;
char *token = str;
int ntokens = 0;
int myrc = -1;
__u32 hops;
int got_hops = 0;
unsigned int priority = 0;
INIT_LIST_HEAD(&gateways);
INIT_LIST_HEAD(&nets);
......@@ -1217,8 +1217,7 @@ lnet_parse_route (char *str, int *im_a_router)
goto token_error;
nid = libcfs_str2nid(ltb->ltb_text);
if (nid == LNET_NID_ANY ||
LNET_NETTYP(LNET_NIDNET(nid)) == LOLND)
if (nid == LNET_NID_ANY || nid == LNET_NID_LO_0)
goto token_error;
}
}
......
......@@ -756,12 +756,12 @@ lnet_prep_send(struct lnet_msg *msg, int type, struct lnet_process_id target,
static void
lnet_ni_send(struct lnet_ni *ni, struct lnet_msg *msg)
{
void *priv = msg->msg_private;
void *priv = msg->msg_private;
int rc;
LASSERT (!in_interrupt ());
LASSERT (LNET_NETTYP(LNET_NIDNET(ni->ni_nid)) == LOLND ||
(msg->msg_txcredit && msg->msg_peertxcredit));
LASSERT(!in_interrupt());
LASSERT(ni->ni_nid == LNET_NID_LO_0 ||
(msg->msg_txcredit && msg->msg_peertxcredit));
rc = (ni->ni_net->net_lnd->lnd_send)(ni, priv, msg);
if (rc < 0) {
......@@ -2508,12 +2508,12 @@ static int
lnet_select_pathway(lnet_nid_t src_nid, lnet_nid_t dst_nid,
struct lnet_msg *msg, lnet_nid_t rtr_nid)
{
struct lnet_peer_ni *lpni;
struct lnet_peer *peer;
struct lnet_send_data send_data;
int cpt, rc;
int md_cpt;
__u32 send_case = 0;
struct lnet_peer_ni *lpni;
struct lnet_peer *peer;
struct lnet_send_data send_data;
int cpt, rc;
int md_cpt;
__u32 send_case = 0;
memset(&send_data, 0, sizeof(send_data));
......@@ -2541,7 +2541,7 @@ again:
*/
send_data.sd_msg = msg;
send_data.sd_cpt = cpt;
if (LNET_NETTYP(LNET_NIDNET(dst_nid)) == LOLND) {
if (dst_nid == LNET_NID_LO_0) {
rc = lnet_handle_lo_send(&send_data);
lnet_net_unlock(cpt);
return rc;
......@@ -4955,14 +4955,14 @@ EXPORT_SYMBOL(LNetGet);
int
LNetDist(lnet_nid_t dstnid, lnet_nid_t *srcnidp, __u32 *orderp)
{
struct list_head *e;
struct list_head *e;
struct lnet_ni *ni = NULL;
struct lnet_remotenet *rnet;
__u32 dstnet = LNET_NIDNET(dstnid);
int hops;
int cpt;
__u32 order = 2;
struct list_head *rn_list;
__u32 dstnet = LNET_NIDNET(dstnid);
int hops;
int cpt;
__u32 order = 2;
struct list_head *rn_list;
/* if !local_nid_dist_zero, I don't return a distance of 0 ever
* (when lustre sees a distance of 0, it substitutes 0@lo), so I
......@@ -4978,7 +4978,7 @@ LNetDist(lnet_nid_t dstnid, lnet_nid_t *srcnidp, __u32 *orderp)
if (srcnidp != NULL)
*srcnidp = dstnid;
if (orderp != NULL) {
if (LNET_NETTYP(LNET_NIDNET(dstnid)) == LOLND)
if (dstnid == LNET_NID_LO_0)
*orderp = 0;
else
*orderp = 1;
......
......@@ -777,7 +777,7 @@ lnet_health_check(struct lnet_msg *msg)
* if we're sending to the LOLND then the msg_txpeer will not be
* set. So no need to sanity check it.
*/
if (LNET_NETTYP(LNET_NIDNET(msg->msg_txni->ni_nid)) != LOLND)
if (msg->msg_txni->ni_nid != LNET_NID_LO_0)
LASSERT(msg->msg_txpeer);
else
lo = true;
......
......@@ -262,7 +262,7 @@ lnet_peer_alloc(lnet_nid_t nid)
* to ever use a different interface when sending messages to
* myself.
*/
if (LNET_NETTYP(LNET_NIDNET(nid)) == LOLND)
if (nid == LNET_NID_LO_0)
lp->lp_state = LNET_PEER_NO_DISCOVERY;
lp->lp_cpt = lnet_nid_cpt_hash(nid, LNET_CPT_NUMBER);
......@@ -2467,7 +2467,7 @@ static int lnet_peer_merge_data(struct lnet_peer *lp,
* present in curnis[] then this peer is for this node.
*/
for (i = 0; i < ncurnis; i++) {
if (LNET_NETTYP(LNET_NIDNET(curnis[i])) == LOLND)
if (curnis[i] == LNET_NID_LO_0)
continue;
for (j = 1; j < pbuf->pb_info.pi_nnis; j++)
if (curnis[i] == pbuf->pb_info.pi_ni[j].ns_nid)
......@@ -2643,7 +2643,7 @@ __must_hold(&lp->lp_lock)
if (pbuf->pb_info.pi_nnis <= 1)
goto out;
nid = pbuf->pb_info.pi_ni[1].ns_nid;
if (LNET_NETTYP(LNET_NIDNET(lp->lp_primary_nid)) == LOLND) {
if (lp->lp_primary_nid == LNET_NID_LO_0) {
rc = lnet_peer_set_primary_nid(lp, nid, flags);
if (!rc)
rc = lnet_peer_merge_data(lp, pbuf);
......
......@@ -331,7 +331,7 @@ lnet_add_route(__u32 net, __u32 hops, lnet_nid_t gateway,
libcfs_net2str(net), hops, priority, libcfs_nid2str(gateway));
if (gateway == LNET_NID_ANY ||
LNET_NETTYP(LNET_NIDNET(gateway)) == LOLND ||
gateway == LNET_NID_LO_0 ||
net == LNET_NIDNET(LNET_NID_ANY) ||
LNET_NETTYP(net) == LOLND ||
LNET_NIDNET(gateway) == net ||
......@@ -743,7 +743,7 @@ lnet_parse_rc_info(struct lnet_rc_data *rcd)
goto out;
}
if (LNET_NETTYP(LNET_NIDNET(nid)) == LOLND)
if (nid == LNET_NID_LO_0)
continue;
if (stat->ns_status == LNET_NI_STATUS_DOWN) {
......
......@@ -602,8 +602,7 @@ static int infra_ping_nid(char *ping_nids, char *oper, int param, int ioc_call,
goto out;
for (i = 0; i < ping.ping_count; i++) {
if (!strcmp(libcfs_nid2str(ping.ping_buf[i].nid),
"0@lo"))
if (ping.ping_buf[i].nid == LNET_NID_LO_0)
continue;
peer_ni = cYAML_create_seq_item(tmp);
if (peer_ni == NULL)
......
......@@ -2812,7 +2812,7 @@ void ll_compute_rootsquash_state(struct ll_sb_info *sbi)
matched = false;
i = 0;
while (LNetGetId(i++, &id) != -ENOENT) {
if (LNET_NETTYP(LNET_NIDNET(id.nid)) == LOLND)
if (id.nid == LNET_NID_LO_0)
continue;
if (cfs_match_nid(id.nid, &squash->rsi_nosquash_nids)) {
matched = true;
......
......@@ -133,7 +133,7 @@ static int __init lustre_init(void)
if (LNetGetId(i, &lnet_id) == -ENOENT)
break;
if (LNET_NETTYP(LNET_NIDNET(lnet_id.nid)) != LOLND)
if (lnet_id.nid != LNET_NID_LO_0)
seed[0] ^= LNET_NIDADDR(lnet_id.nid);
}
......
......@@ -1372,7 +1372,7 @@ static int lmv_select_statfs_mdt(struct lmv_obd *lmv, __u32 flags)
if (LNetGetId(i, &lnet_id) == -ENOENT)
break;
if (LNET_NETTYP(LNET_NIDNET(lnet_id.nid)) != LOLND) {
if (lnet_id.nid != LNET_NID_LO_0) {
/* We dont need a full 64-bit modulus, just enough
* to distribute the requests across MDTs evenly.
*/
......
......@@ -1637,8 +1637,7 @@ static int mgc_process_recover_nodemap_log(struct obd_device *obd,
mgc_conn = class_exp2cliimp(cld->cld_mgcexp)->imp_connection;
/* don't need to get local config */
if (cld_is_nodemap(cld) &&
(LNET_NETTYP(LNET_NIDNET(mgc_conn->c_peer.nid)) == LOLND))
if (cld_is_nodemap(cld) && (mgc_conn->c_peer.nid == LNET_NID_LO_0))
GOTO(out, rc = 0);
/* allocate buffer for bulk transfer.
......
......@@ -242,7 +242,7 @@ int lustre_start_mgc(struct super_block *sb)
struct lnet_process_id id;
while ((rc = LNetGetId(i++, &id)) != -ENOENT) {
if (LNET_NETTYP(LNET_NIDNET(id.nid)) == LOLND)
if (id.nid == LNET_NID_LO_0)
continue;
nid = id.nid;
i++;
......
......@@ -1139,7 +1139,7 @@ static int server_lsi2mti(struct lustre_sb_info *lsi,
mti->mti_nid_count = 0;
while (LNetGetId(i++, &id) != -ENOENT) {
if (LNET_NETTYP(LNET_NIDNET(id.nid)) == LOLND)
if (id.nid == LNET_NID_LO_0)
continue;
/* server use --servicenode param, only allow specified
......
......@@ -501,14 +501,14 @@ static void ptlrpc_master_callback(struct lnet_event *ev)
int ptlrpc_uuid_to_peer(struct obd_uuid *uuid,
struct lnet_process_id *peer, lnet_nid_t *self)
{
int best_dist = 0;
__u32 best_order = 0;
int count = 0;
int rc = -ENOENT;
int dist;
__u32 order;
lnet_nid_t dst_nid;
lnet_nid_t src_nid;
int best_dist = 0;
__u32 best_order = 0;
int count = 0;
int rc = -ENOENT;
int dist;
__u32 order;
lnet_nid_t dst_nid;
lnet_nid_t src_nid;
peer->pid = LNET_PID_LUSTRE;
......@@ -523,7 +523,7 @@ int ptlrpc_uuid_to_peer(struct obd_uuid *uuid,
continue;
if (dist == 0) { /* local! use loopback LND */
peer->nid = *self = LNET_MKNID(LNET_MKNET(LOLND, 0), 0);
peer->nid = *self = LNET_NID_LO_0;
rc = 0;
break;
}
......
......@@ -257,14 +257,14 @@ struct lu_nodemap *nodemap_lookup(const char *name)
*/
struct lu_nodemap *nodemap_classify_nid(lnet_nid_t nid)
{
struct lu_nid_range *range;
struct lu_nodemap *nodemap;
struct lu_nid_range *range;
struct lu_nodemap *nodemap;
int rc;
ENTRY;
/* don't use 0@lo, use the first non-lo local NID instead */
if (LNET_NETTYP(LNET_NIDNET(nid)) == LOLND) {
if (nid == LNET_NID_LO_0) {
struct lnet_process_id id;
int i = 0;
......@@ -272,7 +272,7 @@ struct lu_nodemap *nodemap_classify_nid(lnet_nid_t nid)
rc = LNetGetId(i++, &id);
if (rc < 0)
RETURN(ERR_PTR(-EINVAL));
} while (LNET_NETTYP(LNET_NIDNET(id.nid)) == LOLND);
} while (id.nid == LNET_NID_LO_0);
nid = id.nid;
CDEBUG(D_INFO, "found nid %s\n", libcfs_nid2str(nid));
......
......@@ -876,9 +876,9 @@ EXPORT_SYMBOL(tgt_counter_incr);
int tgt_connect_check_sptlrpc(struct ptlrpc_request *req, struct obd_export *exp)
{
struct lu_target *tgt = class_exp2tgt(exp);
struct sptlrpc_flavor flvr;
int rc = 0;
struct lu_target *tgt = class_exp2tgt(exp);
struct sptlrpc_flavor flvr;
int rc = 0;
LASSERT(tgt);
LASSERT(tgt->lut_obd);
......@@ -908,8 +908,7 @@ int tgt_connect_check_sptlrpc(struct ptlrpc_request *req, struct obd_export *exp
if ((strcmp(exp->exp_obd->obd_type->typ_name,
LUSTRE_MGS_NAME) == 0) &&
(exp->exp_flvr.sf_rpc == SPTLRPC_FLVR_NULL ||
LNET_NETTYP(LNET_NIDNET(exp->exp_connection->c_peer.nid))
== LOLND))
exp->exp_connection->c_peer.nid == LNET_NID_LO_0))
exp->exp_flvr.sf_rpc = SPTLRPC_FLVR_ANY;
if (exp->exp_flvr.sf_rpc != SPTLRPC_FLVR_ANY &&
......
......@@ -352,44 +352,44 @@ int jt_ptl_network(int argc, char **argv)
int
jt_ptl_list_nids(int argc, char **argv)
{
struct libcfs_ioctl_data data;
int all = 0, return_nid = 0;
int count;
int rc;
struct libcfs_ioctl_data data;
int all = 0, return_nid = 0;
int count;
int rc;
all = (argc == 2) && (strcmp(argv[1], "all") == 0);
/* Hack to pass back value */
return_nid = (argc == 2) && (argv[1][0] == 1);
all = (argc == 2) && (strcmp(argv[1], "all") == 0);
/* Hack to pass back value */
return_nid = (argc == 2) && (argv[1][0] == 1);
if ((argc > 2) && !(all || return_nid)) {
fprintf(stderr, "usage: %s [all]\n", argv[0]);
return 0;
}
if ((argc > 2) && !(all || return_nid)) {
fprintf(stderr, "usage: %s [all]\n", argv[0]);
return 0;
}
for (count = 0;; count++) {
LIBCFS_IOC_INIT (data);
data.ioc_count = count;
rc = l_ioctl(LNET_DEV_ID, IOC_LIBCFS_GET_NI, &data);
if (rc < 0) {
if ((count > 0) && (errno == ENOENT))
/* We found them all */
break;
fprintf(stderr,"IOC_LIBCFS_GET_NI error %d: %s\n",
errno, strerror(errno));
return -1;
}
for (count = 0;; count++) {
LIBCFS_IOC_INIT(data);
data.ioc_count = count;
rc = l_ioctl(LNET_DEV_ID, IOC_LIBCFS_GET_NI, &data);
if (rc < 0) {
if ((count > 0) && (errno == ENOENT))
/* We found them all */
break;
fprintf(stderr, "IOC_LIBCFS_GET_NI error %d: %s\n",
errno, strerror(errno));
return -1;
}
if (all || (LNET_NETTYP(LNET_NIDNET(data.ioc_nid)) != LOLND)) {
printf("%s\n", libcfs_nid2str(data.ioc_nid));
if (return_nid) {
*(__u64 *)(argv[1]) = data.ioc_nid;
return_nid--;
}
}
}
if (all || (data.ioc_nid != LNET_NID_LO_0)) {
printf("%s\n", libcfs_nid2str(data.ioc_nid));
if (return_nid) {
*(__u64 *)(argv[1]) = data.ioc_nid;
return_nid--;
}
}
}
return 0;
return 0;
}
int
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment