* \see LNetMEAttach
* @{ */
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);
bool LNetIsPeerLocal(lnet_nid_t nid);
}
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;
* \retval -EHOSTUNREACH If \a 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 list_head *e;
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
* (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 */
+ * 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 != NULL)
- *srcnidp = dstnid;
+ if (nid_same(&ni->ni_nid, dstnid)) {
if (orderp != NULL) {
- 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
}
if (matched_dstnet) {
+ if (srcnid)
+ *srcnid = matched_dstnet->ni_nid;
lnet_net_unlock(cpt);
return 1;
}
LASSERT(shortest != NULL);
hops = shortest_hops;
- if (srcnidp != NULL) {
+ 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 != NULL)
*orderp = order;
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,
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;
break;
rc = 0;
- *peer_nid = data->un_nids[index];
+ lnet_nid4_to_nid(data->un_nids[index], peer_nid);
break;
}
}
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;
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;
}
}