From: James Simmons <jsimmons@infradead.org>
To: Eric Biggers <ebiggers@google.com>,
Andreas Dilger <adilger@whamcloud.com>, NeilBrown <neilb@suse.de>
Cc: linux-fscrypt@vger.kernel.org, James Simmons <jsimmons@infradead.org>
Subject: [PATCH 07/18] lnet: Change LNetDist to work with struct lnet_nid
Date: Thu, 9 Jun 2022 08:33:03 -0400 [thread overview]
Message-ID: <1654777994-29806-8-git-send-email-jsimmons@infradead.org> (raw)
In-Reply-To: <1654777994-29806-1-git-send-email-jsimmons@infradead.org>
From: Mr NeilBrown <neilb@suse.de>
LNetDist now takes and returns 'struct lnet_nid'
lustre_uuid_to_peer() is also updated.
The 'dst' and 'src' parameters to LNetDist are now both pointers, and
that can point to the same 'struct lnet_nid'. Code needs to be
careful not to set *src until after the last use of *dst.
WC-bug-id: https://jira.whamcloud.com/browse/LU-10391
Lustre-commit: c87f70acd86c59425 ("LU-10391 lnet: Change LNetDist to work with struct lnet_nid")
Signed-off-by: Mr NeilBrown <neilb@suse.de>
Reviewed-on: https://review.whamcloud.com/43618
Reviewed-by: James Simmons <jsimmons@infradead.org>
Reviewed-by: Chris Horn <chris.horn@hpe.com>
Reviewed-by: Amir Shehata <ashehata@whamcloud.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
Signed-off-by: James Simmons <jsimmons@infradead.org>
---
fs/lustre/include/obd_class.h | 3 ++-
fs/lustre/obdclass/lustre_peer.c | 4 ++--
fs/lustre/ptlrpc/events.c | 12 ++++++------
include/linux/lnet/api.h | 2 +-
net/lnet/lnet/api-ni.c | 4 +++-
net/lnet/lnet/lib-move.c | 35 ++++++++++++++++-------------------
6 files changed, 30 insertions(+), 30 deletions(-)
diff --git a/fs/lustre/include/obd_class.h b/fs/lustre/include/obd_class.h
index 3f444b0..f603140 100644
--- a/fs/lustre/include/obd_class.h
+++ b/fs/lustre/include/obd_class.h
@@ -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,
diff --git a/fs/lustre/obdclass/lustre_peer.c b/fs/lustre/obdclass/lustre_peer.c
index f7e6a0f..5eae2eb 100644
--- a/fs/lustre/obdclass/lustre_peer.c
+++ b/fs/lustre/obdclass/lustre_peer.c
@@ -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;
}
}
diff --git a/fs/lustre/ptlrpc/events.c b/fs/lustre/ptlrpc/events.c
index 385a6f2..140ea85 100644
--- a/fs/lustre/ptlrpc/events.c
+++ b/fs/lustre/ptlrpc/events.c
@@ -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;
}
}
diff --git a/include/linux/lnet/api.h b/include/linux/lnet/api.h
index 447b41d..3657c13 100644
--- a/include/linux/lnet/api.h
+++ b/include/linux/lnet/api.h
@@ -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 */
diff --git a/net/lnet/lnet/api-ni.c b/net/lnet/lnet/api-ni.c
index 44d5014..c977b47 100644
--- a/net/lnet/lnet/api-ni.c
+++ b/net/lnet/lnet/api-ni.c
@@ -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;
diff --git a/net/lnet/lnet/lib-move.c b/net/lnet/lnet/lib-move.c
index 080bfe6..bca33bf 100644
--- a/net/lnet/lnet/lib-move.c
+++ b/net/lnet/lnet/lib-move.c
@@ -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;
--
1.8.3.1
next prev parent reply other threads:[~2022-06-09 12:33 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-06-09 12:32 [PATCH 00/18] lustre: sync with OpenSFS tree June 8, 2022 James Simmons
2022-06-09 12:32 ` [PATCH 01/18] lustre: llite: reenable fast_read by default James Simmons
2022-06-09 12:32 ` [PATCH 02/18] lustre: llite: Check vmpage in releasepage James Simmons
2022-06-09 12:32 ` [PATCH 03/18] lustre: update version to 2.15.50 James Simmons
2022-06-09 12:33 ` [PATCH 04/18] lustre: llog: read canceled records in llog_backup James Simmons
2022-06-09 12:33 ` [PATCH 05/18] lnet: change LNetPrimaryNID to use struct lnet_nid James Simmons
2022-06-09 12:33 ` [PATCH 06/18] lnet: alter lnet_drop_rule_match() to take lnet_nid James Simmons
2022-06-09 12:33 ` James Simmons [this message]
2022-06-09 12:33 ` [PATCH 08/18] lnet: convert LNetPut to take 16byte nid and pid James Simmons
2022-06-09 12:33 ` [PATCH 09/18] lnet: change LNetGet " James Simmons
2022-06-09 12:33 ` [PATCH 10/18] lnet: socklnd: pass large processid to ksocknal_add_peer James Simmons
2022-06-09 12:33 ` [PATCH 11/18] lnet: socklnd: large processid for ksocknal_get_peer_info James Simmons
2022-06-09 12:33 ` [PATCH 12/18] lnet: socklnd: switch ksocknal_del_peer to lnet_processid James Simmons
2022-06-09 12:33 ` [PATCH 13/18] lustre: llite: access lli_lsm_md with lock in all places James Simmons
2022-06-09 12:33 ` [PATCH 14/18] lustre: quota: fallocate does not increase projectid usage James Simmons
2022-06-09 12:33 ` [PATCH 15/18] lnet: selftest: improve lnet_selftest speed James Simmons
2022-06-09 12:33 ` [PATCH 16/18] lustre: mdc: Use early cancels for hsm requests James Simmons
2022-06-09 12:33 ` [PATCH 17/18] lustre: ptlrpc: send disconnected events James Simmons
2022-06-09 12:33 ` [PATCH 18/18] lnet: Avoid redundant peer NI lookups James Simmons
2022-06-10 0:09 ` [PATCH 00/18] lustre: sync with OpenSFS tree June 8, 2022 Eric Biggers
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1654777994-29806-8-git-send-email-jsimmons@infradead.org \
--to=jsimmons@infradead.org \
--cc=adilger@whamcloud.com \
--cc=ebiggers@google.com \
--cc=linux-fscrypt@vger.kernel.org \
--cc=neilb@suse.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox