From: James Simmons <jsimmons@infradead.org>
To: Andreas Dilger <adilger@whamcloud.com>,
Oleg Drokin <green@whamcloud.com>, NeilBrown <neilb@suse.de>
Cc: Lustre Development List <lustre-devel@lists.lustre.org>
Subject: [lustre-devel] [PATCH 06/50] lnet: socklnd: prepare for new KSOCK_MSG type
Date: Sun, 20 Mar 2022 09:30:20 -0400 [thread overview]
Message-ID: <1647783064-20688-7-git-send-email-jsimmons@infradead.org> (raw)
In-Reply-To: <1647783064-20688-1-git-send-email-jsimmons@infradead.org>
From: Mr NeilBrown <neilb@suse.de>
Various places in socklnd assume there are only two message type:
KSOCK_MSG_NOOP and KSOCK_MSG_LNET. We will soon add another type to
support a new lnet_hdr type with large addresses.
So do some cleanup first:
- get rid of ksock_lnet_msg - it doesn't add anything to lnet_hdr
- separate out 'struct ksock_hdr'. We often want the size of this
header, and instead request the offset of a field in ksock_msg.
- introduce switch statements in a couple of places to handle the
different types of ksock_msg.
WC-bug-id: https://jira.whamcloud.com/browse/LU-10391
Lustre-commit: 6940303aad5375bb2 ("LU-10391 socklnd: prepare for new KSOCK_MSG type")
Signed-off-by: Mr NeilBrown <neilb@suse.de>
Reviewed-on: https://review.whamcloud.com/43601
Reviewed-by: Chris Horn <chris.horn@hpe.com>
Reviewed-by: Serguei Smirnov <ssmirnov@whamcloud.com>
Reviewed-by: James Simmons <jsimmons@infradead.org>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
Signed-off-by: James Simmons <jsimmons@infradead.org>
---
include/linux/lnet/socklnd.h | 38 ++++++++++++--------------
net/lnet/klnds/socklnd/socklnd_cb.c | 50 +++++++++++++++++-----------------
net/lnet/klnds/socklnd/socklnd_proto.c | 49 ++++++++++++++++++++-------------
3 files changed, 73 insertions(+), 64 deletions(-)
diff --git a/include/linux/lnet/socklnd.h b/include/linux/lnet/socklnd.h
index 9f318b7..97ae0e2 100644
--- a/include/linux/lnet/socklnd.h
+++ b/include/linux/lnet/socklnd.h
@@ -52,33 +52,31 @@ struct ksock_hello_msg {
u32 kshm_ips[0]; /* IP addrs */
} __packed;
-struct ksock_lnet_msg {
- struct lnet_hdr ksnm_hdr; /* lnet hdr */
-
- /*
- * ksnm_payload is removed because of winnt compiler's limitation:
- * zero-sized array can only be placed at the tail of [nested]
- * structure definitions. lnet payload will be stored just after
- * the body of structure ksock_lnet_msg_t
- */
+struct ksock_msg_hdr {
+ u32 ksh_type; /* type of socklnd message */
+ u32 ksh_csum; /* checksum if != 0 */
+ u64 ksh_zc_cookies[2]; /* Zero-Copy request/ACK
+ * cookie
+ */
} __packed;
+#define KSOCK_MSG_NOOP 0xC0 /* empty */
+#define KSOCK_MSG_LNET 0xC1 /* lnet msg */
+
struct ksock_msg {
- u32 ksm_type; /* type of socklnd message */
- u32 ksm_csum; /* checksum if != 0 */
- u64 ksm_zc_cookies[2]; /* Zero-Copy request/ACK cookie */
+ struct ksock_msg_hdr ksm_kh;
union {
- struct ksock_lnet_msg lnetmsg; /* lnet message, it's empty if
- * it's NOOP
- */
+ /* case ksm_kh.ksh_type == KSOCK_MSG_NOOP */
+ /* - nothing */
+ /* case ksm_kh.ksh_type == KSOCK_MSG_LNET */
+ struct lnet_hdr lnetmsg;
} __packed ksm_u;
} __packed;
+#define ksm_type ksm_kh.ksh_type
+#define ksm_csum ksm_kh.ksh_csum
+#define ksm_zc_cookies ksm_kh.ksh_zc_cookies
-#define KSOCK_MSG_NOOP 0xC0 /* ksm_u empty */
-#define KSOCK_MSG_LNET 0xC1 /* lnet msg */
-
-/*
- * We need to know this number to parse hello msg from ksocklnd in
+/* We need to know this number to parse hello msg from ksocklnd in
* other LND (usocklnd, for example)
*/
#define KSOCK_PROTO_V2 2
diff --git a/net/lnet/klnds/socklnd/socklnd_cb.c b/net/lnet/klnds/socklnd/socklnd_cb.c
index d0c3628..feab2a07 100644
--- a/net/lnet/klnds/socklnd/socklnd_cb.c
+++ b/net/lnet/klnds/socklnd/socklnd_cb.c
@@ -1007,10 +1007,10 @@ struct ksock_conn_cb *
case KSOCK_PROTO_V3:
conn->ksnc_rx_state = SOCKNAL_RX_KSM_HEADER;
kvec->iov_base = &conn->ksnc_msg;
- kvec->iov_len = offsetof(struct ksock_msg, ksm_u);
- conn->ksnc_rx_nob_left = offsetof(struct ksock_msg, ksm_u);
+ kvec->iov_len = sizeof(struct ksock_msg_hdr);
+ conn->ksnc_rx_nob_left = sizeof(struct ksock_msg_hdr);
iov_iter_kvec(&conn->ksnc_rx_to, READ, kvec, 1,
- offsetof(struct ksock_msg, ksm_u));
+ sizeof(struct ksock_msg_hdr));
break;
case KSOCK_PROTO_V1:
@@ -1111,16 +1111,6 @@ struct ksock_conn_cb *
__swab64s(&conn->ksnc_msg.ksm_zc_cookies[1]);
}
- if (conn->ksnc_msg.ksm_type != KSOCK_MSG_NOOP &&
- conn->ksnc_msg.ksm_type != KSOCK_MSG_LNET) {
- CERROR("%s: Unknown message type: %x\n",
- libcfs_idstr(&conn->ksnc_peer->ksnp_id),
- conn->ksnc_msg.ksm_type);
- ksocknal_new_packet(conn, 0);
- ksocknal_close_conn_and_siblings(conn, -EPROTO);
- return -EPROTO;
- }
-
if (conn->ksnc_msg.ksm_type == KSOCK_MSG_NOOP &&
conn->ksnc_msg.ksm_csum && /* has checksum */
conn->ksnc_msg.ksm_csum != conn->ksnc_rx_csum) {
@@ -1154,21 +1144,31 @@ struct ksock_conn_cb *
}
}
- if (conn->ksnc_msg.ksm_type == KSOCK_MSG_NOOP) {
+ switch (conn->ksnc_msg.ksm_type) {
+ case KSOCK_MSG_NOOP:
ksocknal_new_packet(conn, 0);
return 0; /* NOOP is done and just return */
- }
- conn->ksnc_rx_state = SOCKNAL_RX_LNET_HEADER;
- conn->ksnc_rx_nob_left = sizeof(struct ksock_lnet_msg);
+ case KSOCK_MSG_LNET:
+ conn->ksnc_rx_state = SOCKNAL_RX_LNET_HEADER;
+ conn->ksnc_rx_nob_left = sizeof(struct lnet_hdr);
+
+ kvec->iov_base = &conn->ksnc_msg.ksm_u.lnetmsg;
+ kvec->iov_len = sizeof(struct lnet_hdr);
- kvec->iov_base = &conn->ksnc_msg.ksm_u.lnetmsg;
- kvec->iov_len = sizeof(struct ksock_lnet_msg);
+ iov_iter_kvec(&conn->ksnc_rx_to, READ, kvec, 1,
+ sizeof(struct lnet_hdr));
- iov_iter_kvec(&conn->ksnc_rx_to, READ, kvec, 1,
- sizeof(struct ksock_lnet_msg));
+ goto again; /* read lnet header now */
- goto again; /* read lnet header now */
+ default:
+ CERROR("%s: Unknown message type: %x\n",
+ libcfs_idstr(&conn->ksnc_peer->ksnp_id),
+ conn->ksnc_msg.ksm_type);
+ ksocknal_new_packet(conn, 0);
+ ksocknal_close_conn_and_siblings(conn, -EPROTO);
+ return -EPROTO;
+ }
case SOCKNAL_RX_LNET_HEADER:
/* unpack message header */
@@ -1176,7 +1176,7 @@ struct ksock_conn_cb *
if (conn->ksnc_peer->ksnp_id.pid & LNET_PID_USERFLAG) {
/* Userspace peer_ni */
- lhdr = &conn->ksnc_msg.ksm_u.lnetmsg.ksnm_hdr;
+ lhdr = &conn->ksnc_msg.ksm_u.lnetmsg;
id = &conn->ksnc_peer->ksnp_id;
/* Substitute process ID assigned at connection time */
@@ -1188,7 +1188,7 @@ struct ksock_conn_cb *
ksocknal_conn_addref(conn); /* ++ref while parsing */
rc = lnet_parse(conn->ksnc_peer->ksnp_ni,
- &conn->ksnc_msg.ksm_u.lnetmsg.ksnm_hdr,
+ &conn->ksnc_msg.ksm_u.lnetmsg,
lnet_nid_to_nid4(&conn->ksnc_peer->ksnp_id.nid),
conn, 0);
if (rc < 0) {
@@ -1225,7 +1225,7 @@ struct ksock_conn_cb *
if (!rc && conn->ksnc_msg.ksm_zc_cookies[0]) {
LASSERT(conn->ksnc_proto != &ksocknal_protocol_v1x);
- lhdr = &conn->ksnc_msg.ksm_u.lnetmsg.ksnm_hdr;
+ lhdr = &conn->ksnc_msg.ksm_u.lnetmsg;
id = &conn->ksnc_peer->ksnp_id;
rc = conn->ksnc_proto->pro_handle_zcreq(conn,
diff --git a/net/lnet/klnds/socklnd/socklnd_proto.c b/net/lnet/klnds/socklnd/socklnd_proto.c
index c3ba070..2ecffb1 100644
--- a/net/lnet/klnds/socklnd/socklnd_proto.c
+++ b/net/lnet/klnds/socklnd/socklnd_proto.c
@@ -287,11 +287,12 @@
if (!tx || !tx->tx_lnetmsg) {
/* noop packet */
- nob = offsetof(struct ksock_msg, ksm_u);
+ nob = sizeof(struct ksock_msg_hdr);
} else {
nob = tx->tx_lnetmsg->msg_len +
((conn->ksnc_proto == &ksocknal_protocol_v1x) ?
- sizeof(struct lnet_hdr) : sizeof(struct ksock_msg));
+ 0 : sizeof(struct ksock_msg_hdr) +
+ sizeof(struct lnet_hdr));
}
/* default checking for typed connection */
@@ -325,9 +326,10 @@
int nob;
if (!tx || !tx->tx_lnetmsg)
- nob = offsetof(struct ksock_msg, ksm_u);
+ nob = sizeof(struct ksock_msg_hdr);
else
- nob = tx->tx_lnetmsg->msg_len + sizeof(struct ksock_msg);
+ nob = sizeof(struct ksock_msg_hdr) + sizeof(struct lnet_hdr) +
+ tx->tx_lnetmsg->msg_len;
switch (conn->ksnc_type) {
default:
@@ -721,24 +723,33 @@
static void
ksocknal_pack_msg_v2(struct ksock_tx *tx)
{
- tx->tx_hdr.iov_base = &tx->tx_msg;
-
- if (tx->tx_lnetmsg) {
- LASSERT(tx->tx_msg.ksm_type != KSOCK_MSG_NOOP);
+ int hdr_size;
- tx->tx_msg.ksm_u.lnetmsg.ksnm_hdr = tx->tx_lnetmsg->msg_hdr;
- tx->tx_hdr.iov_len = sizeof(struct ksock_msg);
- tx->tx_nob = sizeof(struct ksock_msg) + tx->tx_lnetmsg->msg_len;
- tx->tx_resid = sizeof(struct ksock_msg) + tx->tx_lnetmsg->msg_len;
- } else {
- LASSERT(tx->tx_msg.ksm_type == KSOCK_MSG_NOOP);
+ tx->tx_hdr.iov_base = &tx->tx_msg;
- tx->tx_hdr.iov_len = offsetof(struct ksock_msg, ksm_u.lnetmsg.ksnm_hdr);
- tx->tx_nob = offsetof(struct ksock_msg, ksm_u.lnetmsg.ksnm_hdr);
- tx->tx_resid = offsetof(struct ksock_msg, ksm_u.lnetmsg.ksnm_hdr);
+ switch (tx->tx_msg.ksm_type) {
+ case KSOCK_MSG_LNET:
+ LASSERT(tx->tx_lnetmsg);
+ hdr_size = sizeof(struct ksock_msg_hdr) +
+ sizeof(struct lnet_hdr);
+
+ tx->tx_msg.ksm_u.lnetmsg = tx->tx_lnetmsg->msg_hdr;
+ tx->tx_hdr.iov_len = hdr_size;
+ tx->tx_nob = hdr_size + tx->tx_lnetmsg->msg_len;
+ tx->tx_resid = hdr_size + tx->tx_lnetmsg->msg_len;
+ break;
+ case KSOCK_MSG_NOOP:
+ LASSERT(!tx->tx_lnetmsg);
+ hdr_size = sizeof(struct ksock_msg_hdr);
+
+ tx->tx_hdr.iov_len = hdr_size;
+ tx->tx_nob = hdr_size;
+ tx->tx_resid = hdr_size;
+ break;
+ default:
+ LASSERT(0);
}
- /*
- * Don't checksum before start sending, because packet can be
+ /* Don't checksum before start sending, because packet can be
* piggybacked with ACK
*/
}
--
1.8.3.1
_______________________________________________
lustre-devel mailing list
lustre-devel@lists.lustre.org
http://lists.lustre.org/listinfo.cgi/lustre-devel-lustre.org
next prev parent reply other threads:[~2022-03-20 13:31 UTC|newest]
Thread overview: 51+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-03-20 13:30 [lustre-devel] [PATCH 00/50] lustre: update to OpenSFS tree as of March 20, 2022 James Simmons
2022-03-20 13:30 ` [lustre-devel] [PATCH 01/50] lustre: type cleanups and remove debug statements James Simmons
2022-03-20 13:30 ` [lustre-devel] [PATCH 02/50] lustre: osc: Fix grant test for ARM James Simmons
2022-03-20 13:30 ` [lustre-devel] [PATCH 03/50] lnet: extend nids in struct lnet_msg James Simmons
2022-03-20 13:30 ` [lustre-devel] [PATCH 04/50] lnet: Change lnet_send() to take large-addr nids James Simmons
2022-03-20 13:30 ` [lustre-devel] [PATCH 05/50] lnet: use large nids in struct lnet_event James Simmons
2022-03-20 13:30 ` James Simmons [this message]
2022-03-20 13:30 ` [lustre-devel] [PATCH 07/50] lnet: socklnd: don't deref lnet_hdr in LNDs James Simmons
2022-03-20 13:30 ` [lustre-devel] [PATCH 08/50] lustre: sec: make client encryption compatible with ext4 James Simmons
2022-03-20 13:30 ` [lustre-devel] [PATCH 09/50] lustre: sec: allow subdir mount of encrypted dir James Simmons
2022-03-20 13:30 ` [lustre-devel] [PATCH 10/50] lustre: fld: repeat rpc in fld_client_rpc after EAGAIN James Simmons
2022-03-20 13:30 ` [lustre-devel] [PATCH 11/50] lustre: fld: don't obtain a slot for fld request James Simmons
2022-03-20 13:30 ` [lustre-devel] [PATCH 12/50] lustre: update version to 2.14.57 James Simmons
2022-03-20 13:30 ` [lustre-devel] [PATCH 13/50] lustre: llite: deadlock in ll_new_node() James Simmons
2022-03-20 13:30 ` [lustre-devel] [PATCH 14/50] lnet: o2iblnd: avoid static allocation for msg tx James Simmons
2022-03-20 13:30 ` [lustre-devel] [PATCH 15/50] lnet: separate lnet_hdr in msg from that in lnd James Simmons
2022-03-20 13:30 ` [lustre-devel] [PATCH 16/50] lnet: change lnet_hdr to store large nids James Simmons
2022-03-20 13:30 ` [lustre-devel] [PATCH 17/50] lnet: change lnet_prep_send to take net_processid James Simmons
2022-03-20 13:30 ` [lustre-devel] [PATCH 18/50] lnet: convert to struct lnet_process_id in lib-move James Simmons
2022-03-20 13:30 ` [lustre-devel] [PATCH 19/50] lnet: convert LNetGetID to return an large-addr pid James Simmons
2022-03-20 13:30 ` [lustre-devel] [PATCH 20/50] lnet: alter lnd_notify_peer_down() to take lnet_nid James Simmons
2022-03-20 13:30 ` [lustre-devel] [PATCH 21/50] lnet: socklnd: move lnet_hdr unpack into ->pro_unpack James Simmons
2022-03-20 13:30 ` [lustre-devel] [PATCH 22/50] lnet: socklnd: Change ksock_hello_msg to struct lnet_nid James Simmons
2022-03-20 13:30 ` [lustre-devel] [PATCH 23/50] lnet: socklnd: add hello message version 4 James Simmons
2022-03-20 13:30 ` [lustre-devel] [PATCH 24/50] lnet: Convert ping to support 16-bytes address James Simmons
2022-03-20 13:30 ` [lustre-devel] [PATCH 25/50] lnet: convert nids in lnet_parse to lnet_nid James Simmons
2022-03-20 13:30 ` [lustre-devel] [PATCH 26/50] lnet: change src_nid arg to lnet_parse() to 16byte James Simmons
2022-03-20 13:30 ` [lustre-devel] [PATCH 27/50] lnet: Fix NULL-deref in lnet_nidstr_r() James Simmons
2022-03-20 13:30 ` [lustre-devel] [PATCH 28/50] lnet: change lnet_del_route() to take lnet_nid James Simmons
2022-03-20 13:30 ` [lustre-devel] [PATCH 29/50] lustre: llite: Move free user pages James Simmons
2022-03-20 13:30 ` [lustre-devel] [PATCH 30/50] lustre: llite: Do not get/put DIO pages James Simmons
2022-03-20 13:30 ` [lustre-devel] [PATCH 31/50] lustre: llite: Remove unnecessary page get/put James Simmons
2022-03-20 13:30 ` [lustre-devel] [PATCH 32/50] lustre: llite: LL_IOC_LMV_GETSTRIPE 'default' shows inherit layout James Simmons
2022-03-20 13:30 ` [lustre-devel] [PATCH 33/50] lustre: hsm: update size upon completion of data version James Simmons
2022-03-20 13:30 ` [lustre-devel] [PATCH 34/50] lustre: llite: Delay dput in ll_dirty_page_discard_warn James Simmons
2022-03-20 13:30 ` [lustre-devel] [PATCH 35/50] lnet: libcfs: Use FAIL_CHECK_QUIET for fake i/o James Simmons
2022-03-20 13:30 ` [lustre-devel] [PATCH 36/50] lnet: Avoid peer NI recovery for local interface James Simmons
2022-03-20 13:30 ` [lustre-devel] [PATCH 37/50] lustre: osc: add OBD_IOC_GETATTR support for osc James Simmons
2022-03-20 13:30 ` [lustre-devel] [PATCH 38/50] lustre: sec: present .fscrypt in subdir mount James Simmons
2022-03-20 13:30 ` [lustre-devel] [PATCH 39/50] lnet: improve hash distribution across CPTs James Simmons
2022-03-20 13:30 ` [lustre-devel] [PATCH 40/50] lustre: osc: osc_extent_wait() deadlock James Simmons
2022-03-20 13:30 ` [lustre-devel] [PATCH 41/50] lustre: quota: delete unused quota ID James Simmons
2022-03-20 13:30 ` [lustre-devel] [PATCH 42/50] lnet: Check LNET_NID_IS_ANY in LNET_NID_NET James Simmons
2022-03-20 13:30 ` [lustre-devel] [PATCH 43/50] lustre: llite: clear async errors on write commit sync James Simmons
2022-03-20 13:30 ` [lustre-devel] [PATCH 44/50] lnet: lnet_peer_data_present() memory leak James Simmons
2022-03-20 13:30 ` [lustre-devel] [PATCH 45/50] lnet: Don't use pref NI for reserved portal James Simmons
2022-03-20 13:31 ` [lustre-devel] [PATCH 46/50] lnet: o2iblnd: avoid memory copy for short msg James Simmons
2022-03-20 13:31 ` [lustre-devel] [PATCH 47/50] lustre: llite: set default LMV hash type with 2.12 MDS James Simmons
2022-03-20 13:31 ` [lustre-devel] [PATCH 48/50] lnet: Stop discovery on deleted peer NI James Simmons
2022-03-20 13:31 ` [lustre-devel] [PATCH 49/50] lustre: sec: fix DIO for encrypted files James Simmons
2022-03-20 13:31 ` [lustre-devel] [PATCH 50/50] lustre: ptlrpc: Use after free of 'conn' in rhashtable retry James Simmons
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=1647783064-20688-7-git-send-email-jsimmons@infradead.org \
--to=jsimmons@infradead.org \
--cc=adilger@whamcloud.com \
--cc=green@whamcloud.com \
--cc=lustre-devel@lists.lustre.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;
as well as URLs for NNTP newsgroup(s).