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 */
/* 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;
}
}
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;
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;
}
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];
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;
/* save a copy of the string for error messages */
strncpy(cmd, str, sizeof(cmd));
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;
}
}
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) {
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));
*/
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;
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
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;
* if we're sending to the LOLND then the msg_txpeer will not be
* set. So no need to sanity check it.
*/
- if (msg->msg_tx_committed &&
- LNET_NETTYP(LNET_NIDNET(msg->msg_txni->ni_nid)) != LOLND)
+ if (msg->msg_tx_committed && msg->msg_txni->ni_nid != LNET_NID_LO_0)
LASSERT(msg->msg_txpeer);
else if (msg->msg_tx_committed &&
- LNET_NETTYP(LNET_NIDNET(msg->msg_txni->ni_nid)) == LOLND)
+ msg->msg_txni->ni_nid == LNET_NID_LO_0)
lo = true;
if (hstatus != LNET_MSG_STATUS_OK &&
* 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);
* 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) {
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);
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 ||
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)
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;
* can distribute subdirs evenly from the beginning.
*/
while (LNetGetId(i++, &lnet_id) != -ENOENT) {
- if (LNET_NETTYP(LNET_NIDNET(lnet_id.nid)) != LOLND) {
+ if (lnet_id.nid != LNET_NID_LO_0) {
lmv->lmv_qos_rr_index = (u32)lnet_id.nid;
break;
}
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.
*/
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.
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++;
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
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;
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;
}
*/
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;
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));
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);
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 &&
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