@@ -1688,7 +1688,8 @@ struct lwp_register_item {
int lustre_check_exclusion(struct super_block *sb, char *svname);
/* lustre_peer.c */
-int lustre_uuid_to_peer(const char *uuid, lnet_nid_t *peer_nid, int index);
+int lustre_uuid_to_peer(const char *uuid, struct lnet_nid *peer_nid,
+ int index);
int class_add_uuid(const char *uuid, u64 nid);
int class_del_uuid(const char *uuid);
int class_add_nids_to_uuid(struct obd_uuid *uuid, lnet_nid_t *nids,
@@ -51,7 +51,7 @@ struct uuid_nid_data {
static LIST_HEAD(g_uuid_list);
static DEFINE_SPINLOCK(g_uuid_lock);
-int lustre_uuid_to_peer(const char *uuid, lnet_nid_t *peer_nid, int index)
+int lustre_uuid_to_peer(const char *uuid, struct lnet_nid *peer_nid, int index)
{
struct uuid_nid_data *data;
struct obd_uuid tmp;
@@ -65,7 +65,7 @@ int lustre_uuid_to_peer(const char *uuid, lnet_nid_t *peer_nid, int index)
break;
rc = 0;
- *peer_nid = data->un_nids[index];
+ lnet_nid4_to_nid(data->un_nids[index], peer_nid);
break;
}
}
@@ -476,18 +476,18 @@ int ptlrpc_uuid_to_peer(struct obd_uuid *uuid,
int rc = -ENOENT;
int dist;
u32 order;
- lnet_nid_t dst_nid;
- lnet_nid_t src_nid;
+ struct lnet_nid dst_nid;
+ struct lnet_nid src_nid;
peer->pid = LNET_PID_LUSTRE;
/* Choose the matching UUID that's closest */
while (lustre_uuid_to_peer(uuid->uuid, &dst_nid, count++) == 0) {
if (peer->nid != LNET_NID_ANY && LNET_NIDADDR(peer->nid) == 0 &&
- LNET_NIDNET(dst_nid) != LNET_NIDNET(peer->nid))
+ LNET_NID_NET(&dst_nid) != LNET_NIDNET(peer->nid))
continue;
- dist = LNetDist(dst_nid, &src_nid, &order);
+ dist = LNetDist(&dst_nid, &src_nid, &order);
if (dist < 0)
continue;
@@ -503,8 +503,8 @@ int ptlrpc_uuid_to_peer(struct obd_uuid *uuid,
best_dist = dist;
best_order = order;
- peer->nid = dst_nid;
- *self = src_nid;
+ peer->nid = lnet_nid_to_nid4(&dst_nid);
+ *self = lnet_nid_to_nid4(&src_nid);
rc = 0;
}
}
@@ -76,7 +76,7 @@
* @{
*/
int LNetGetId(unsigned int index, struct lnet_processid *id);
-int LNetDist(lnet_nid_t nid, lnet_nid_t *srcnid, u32 *order);
+int LNetDist(struct lnet_nid *nid, struct lnet_nid *srcnid, u32 *order);
void LNetPrimaryNID(struct lnet_nid *nid);
/** @} lnet_addr */
@@ -4261,10 +4261,12 @@ u32 lnet_get_dlc_seq_locked(void)
}
case IOC_LIBCFS_LNET_DIST:
- rc = LNetDist(data->ioc_nid, &data->ioc_nid, &data->ioc_u32[1]);
+ lnet_nid4_to_nid(data->ioc_nid, &nid);
+ rc = LNetDist(&nid, &nid, &data->ioc_u32[1]);
if (rc < 0 && rc != -EHOSTUNREACH)
return rc;
+ data->ioc_nid = lnet_nid_to_nid4(&nid);
data->ioc_u32[0] = rc;
return 0;
@@ -5072,55 +5072,51 @@ struct lnet_msg *
* -EHOSTUNREACH If @dstnid is not reachable.
*/
int
-LNetDist(lnet_nid_t dstnid, lnet_nid_t *srcnidp, u32 *orderp)
+LNetDist(struct lnet_nid *dstnid, struct lnet_nid *srcnid, u32 *orderp)
{
struct lnet_ni *ni = NULL;
struct lnet_remotenet *rnet;
- u32 dstnet = LNET_NIDNET(dstnid);
+ u32 dstnet = LNET_NID_NET(dstnid);
int hops;
int cpt;
u32 order = 2;
struct list_head *rn_list;
- bool matched_dstnet = false;
+ struct lnet_ni *matched_dstnet = NULL;
- /*
- * if !local_nid_dist_zero, I don't return a distance of 0 ever
+ /* 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
* keep order 0 free for 0@lo and order 1 free for a local NID
* match
+ * WARNING: dstnid and srcnid might point to same place.
+ * Don't set *srcnid until late.
*/
LASSERT(the_lnet.ln_refcount > 0);
cpt = lnet_net_lock_current();
while ((ni = lnet_get_next_ni_locked(NULL, ni))) {
- /* FIXME support large-addr nid */
- if (lnet_nid_to_nid4(&ni->ni_nid) == dstnid) {
- if (srcnidp)
- *srcnidp = dstnid;
+ if (nid_same(&ni->ni_nid, dstnid)) {
if (orderp) {
- if (dstnid == LNET_NID_LO_0)
+ if (nid_is_lo0(dstnid))
*orderp = 0;
else
*orderp = 1;
}
+ if (srcnid)
+ *srcnid = *dstnid;
lnet_net_unlock(cpt);
return local_nid_dist_zero ? 0 : 1;
}
if (!matched_dstnet && LNET_NID_NET(&ni->ni_nid) == dstnet) {
- matched_dstnet = true;
+ matched_dstnet = ni;
/* We matched the destination net, but we may have
* additional local NIs to inspect.
*
- * We record the nid and order as appropriate, but
+ * We record the order as appropriate, but
* they may be overwritten if we match local NI above.
*/
- if (srcnidp)
- /* FIXME support large-addr nids */
- *srcnidp = lnet_nid_to_nid4(&ni->ni_nid);
-
if (orderp) {
/* Check if ni was originally created in
* current net namespace.
@@ -5140,6 +5136,8 @@ struct lnet_msg *
}
if (matched_dstnet) {
+ if (srcnid)
+ *srcnid = matched_dstnet->ni_nid;
lnet_net_unlock(cpt);
return 1;
}
@@ -5168,14 +5166,13 @@ struct lnet_msg *
LASSERT(shortest);
hops = shortest_hops;
- if (srcnidp) {
+ if (srcnid) {
struct lnet_net *net;
net = lnet_get_net_locked(shortest->lr_lnet);
LASSERT(net);
ni = lnet_get_next_ni_locked(net, NULL);
- /* FIXME support large-addr nids */
- *srcnidp = lnet_nid_to_nid4(&ni->ni_nid);
+ *srcnid = ni->ni_nid;
}
if (orderp)
*orderp = order;