From: James Simmons <jsimmons@infradead.org>
To: Andreas Dilger <adilger@whamcloud.com>,
Oleg Drokin <green@whamcloud.com>, NeilBrown <neilb@suse.de>
Cc: Serguei Smirnov <ssmirnov@whamcloud.com>,
Lustre Development List <lustre-devel@lists.lustre.org>
Subject: [lustre-devel] [PATCH 10/24] lnet: socklnd: decrement connection counters on close
Date: Thu, 13 Jan 2022 20:37:49 -0500 [thread overview]
Message-ID: <1642124283-10148-11-git-send-email-jsimmons@infradead.org> (raw)
In-Reply-To: <1642124283-10148-1-git-send-email-jsimmons@infradead.org>
From: Serguei Smirnov <ssmirnov@whamcloud.com>
To gracefully handle potential race with delayed connection create,
decrement connection counters per type as connections are being
closed.
Fixes: 511ace4a ("lnet: socklnd: add conns_per_peer parameter")
WC-bug-id: https://jira.whamcloud.com/browse/LU-15137
Lustre-commit: 7e26413aa85fdc931 ("LU-15137 socklnd: decrement connection counters on close")
Signed-off-by: Serguei Smirnov <ssmirnov@whamcloud.com>
Reviewed-on: https://review.whamcloud.com/45422
Reviewed-by: Amir Shehata <ashehata@whamcloud.com>
Reviewed-by: Cyril Bordage <cbordage@whamcloud.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
Signed-off-by: James Simmons <jsimmons@infradead.org>
---
net/lnet/klnds/socklnd/socklnd.c | 69 ++++++++++++++++++++++++++++++++++------
1 file changed, 60 insertions(+), 9 deletions(-)
diff --git a/net/lnet/klnds/socklnd/socklnd.c b/net/lnet/klnds/socklnd/socklnd.c
index b014aa8..6d1f85c 100644
--- a/net/lnet/klnds/socklnd/socklnd.c
+++ b/net/lnet/klnds/socklnd/socklnd.c
@@ -422,7 +422,9 @@ struct ksock_peer_ni *
switch (type) {
case SOCKLND_CONN_CONTROL:
conn_cb->ksnr_ctrl_conn_count++;
- /* there's a single control connection per peer */
+ /* there's a single control connection per peer,
+ * two in case of loopback
+ */
conn_cb->ksnr_connected |= BIT(type);
break;
case SOCKLND_CONN_BULK_IN:
@@ -449,6 +451,45 @@ struct ksock_peer_ni *
}
static void
+ksocknal_decr_conn_count(struct ksock_conn_cb *conn_cb,
+ int type)
+{
+ conn_cb->ksnr_conn_count--;
+
+ /* check if all connections of the given type got created */
+ switch (type) {
+ case SOCKLND_CONN_CONTROL:
+ conn_cb->ksnr_ctrl_conn_count--;
+ /* there's a single control connection per peer,
+ * two in case of loopback
+ */
+ if (conn_cb->ksnr_ctrl_conn_count == 0)
+ conn_cb->ksnr_connected &= ~BIT(type);
+ break;
+ case SOCKLND_CONN_BULK_IN:
+ conn_cb->ksnr_blki_conn_count--;
+ if (conn_cb->ksnr_blki_conn_count < conn_cb->ksnr_max_conns)
+ conn_cb->ksnr_connected &= ~BIT(type);
+ break;
+ case SOCKLND_CONN_BULK_OUT:
+ conn_cb->ksnr_blko_conn_count--;
+ if (conn_cb->ksnr_blko_conn_count < conn_cb->ksnr_max_conns)
+ conn_cb->ksnr_connected &= ~BIT(type);
+ break;
+ case SOCKLND_CONN_ANY:
+ if (conn_cb->ksnr_conn_count < conn_cb->ksnr_max_conns)
+ conn_cb->ksnr_connected &= ~BIT(type);
+ break;
+ default:
+ LBUG();
+ break;
+ }
+
+ CDEBUG(D_NET, "Del conn type %d, ksnr_connected %x ksnr_max_conns %d\n",
+ type, conn_cb->ksnr_connected, conn_cb->ksnr_max_conns);
+}
+
+static void
ksocknal_associate_cb_conn_locked(struct ksock_conn_cb *conn_cb,
struct ksock_conn *conn)
{
@@ -1249,6 +1290,8 @@ struct ksock_peer_ni *
struct ksock_peer_ni *peer_ni = conn->ksnc_peer;
struct ksock_conn_cb *conn_cb;
struct ksock_conn *conn2;
+ int conn_count;
+ int duplicate_count = 0;
LASSERT(!peer_ni->ksnp_error);
LASSERT(!conn->ksnc_closing);
@@ -1262,21 +1305,29 @@ struct ksock_peer_ni *
/* dissociate conn from cb... */
LASSERT(!conn_cb->ksnr_deleted);
+ conn_count = ksocknal_get_conn_count_by_type(conn_cb,
+ conn->ksnc_type);
/* connected bit is set only if all connections
* of the given type got created
*/
- if (ksocknal_get_conn_count_by_type(conn_cb, conn->ksnc_type) ==
- conn_cb->ksnr_max_conns)
+ if (conn_count == conn_cb->ksnr_max_conns)
LASSERT((conn_cb->ksnr_connected &
BIT(conn->ksnc_type)) != 0);
- list_for_each_entry(conn2, &peer_ni->ksnp_conns, ksnc_list) {
- if (conn2->ksnc_conn_cb == conn_cb &&
- conn2->ksnc_type == conn->ksnc_type)
- goto conn2_found;
+ if (conn_count == 1) {
+ list_for_each_entry(conn2, &peer_ni->ksnp_conns,
+ ksnc_list) {
+ if (conn2->ksnc_conn_cb == conn_cb &&
+ conn2->ksnc_type == conn->ksnc_type)
+ duplicate_count += 1;
+ }
+ if (duplicate_count > 0)
+ CERROR("Found %d duplicate conns type %d\n",
+ duplicate_count,
+ conn->ksnc_type);
}
- conn_cb->ksnr_connected &= ~BIT(conn->ksnc_type);
-conn2_found:
+ ksocknal_decr_conn_count(conn_cb, conn->ksnc_type);
+
conn->ksnc_conn_cb = NULL;
/* drop conn's ref on route */
--
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-01-14 1:38 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-01-14 1:37 [lustre-devel] [PATCH 00/24] lustre: update to OpenSFS Jan 13, 2022 James Simmons
2022-01-14 1:37 ` [lustre-devel] [PATCH 01/24] lustre: osc: don't have extra gpu call James Simmons
2022-01-14 1:37 ` [lustre-devel] [PATCH 02/24] lustre: llite: add trusted.projid virtual xattr James Simmons
2022-01-14 1:37 ` [lustre-devel] [PATCH 03/24] lnet: o2iblnd: cleanup James Simmons
2022-01-14 1:37 ` [lustre-devel] [PATCH 04/24] lustre: ptlrpc: make rq_replied flag always correct James Simmons
2022-01-14 1:37 ` [lustre-devel] [PATCH 05/24] lustre: mgc: do not ignore target registration failure James Simmons
2022-01-14 1:37 ` [lustre-devel] [PATCH 06/24] lustre: llite: make foreign symlinks aware of mount namespaces James Simmons
2022-01-14 1:37 ` [lustre-devel] [PATCH 07/24] lustre: lov: Cache stripe offset calculation James Simmons
2022-01-14 1:37 ` [lustre-devel] [PATCH 08/24] lnet: o2iblnd: treat cmid->device == NULL as an error James Simmons
2022-01-14 1:37 ` [lustre-devel] [PATCH 09/24] lustre: lmv: set default LMV for "lfs mkdir -c 1" James Simmons
2022-01-14 1:37 ` James Simmons [this message]
2022-01-14 1:37 ` [lustre-devel] [PATCH 11/24] lustre: lmv: improve MDT QOS space balance James Simmons
2022-01-14 1:37 ` [lustre-devel] [PATCH 12/24] lustre: llite: access striped directory with missing stripe James Simmons
2022-01-14 1:37 ` [lustre-devel] [PATCH 13/24] lnet: libcfs: Remove D_TTY James Simmons
2022-01-14 1:37 ` [lustre-devel] [PATCH 14/24] lustre: llite: Add D_IOTRACE James Simmons
2022-01-14 1:37 ` [lustre-devel] [PATCH 15/24] lustre: llite: Add start_idx debug James Simmons
2022-01-14 1:37 ` [lustre-devel] [PATCH 16/24] lnet: Skip router discovery on send path James Simmons
2022-01-14 1:37 ` [lustre-devel] [PATCH 17/24] lustre: mdc: GET(X)ATTR to READPAGE portal James Simmons
2022-01-14 1:37 ` [lustre-devel] [PATCH 18/24] lnet: libcfs: set x->ls_len to 0 when x->ls_str is NULL James Simmons
2022-01-14 1:37 ` [lustre-devel] [PATCH 19/24] lustre: uapi: set default max-inherit to 3 James Simmons
2022-01-14 1:37 ` [lustre-devel] [PATCH 20/24] lustre: llite: Switch pcc to lookup_one_len James Simmons
2022-01-14 1:38 ` [lustre-devel] [PATCH 21/24] lustre: llite: revalidate dentry if LOOKUP lock fetched James Simmons
2022-01-14 1:38 ` [lustre-devel] [PATCH 22/24] lustre: llite: Simplify cda_no_aio_complete use James Simmons
2022-01-14 1:38 ` [lustre-devel] [PATCH 23/24] lustre: osc: Always set aio in anchor James Simmons
2022-01-14 1:38 ` [lustre-devel] [PATCH 24/24] lustre: llite: Implement lower/upper aio 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=1642124283-10148-11-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 \
--cc=ssmirnov@whamcloud.com \
/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).