From nobody Tue Apr 09 16:17:55 2024 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4VDWMl391bz5HG3s; Tue, 9 Apr 2024 16:17:55 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4VDWMl2fcXz4X3d; Tue, 9 Apr 2024 16:17:55 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1712679475; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=qpkhgTt9SHcYX3ZFb8HigWF0nc+qd/z5sBRX2nO3Obo=; b=GBAI24Hu4aBnd47+sEfp9B4QnQRpLUwhYhIg2DuaOB2qvXZAO5MDNDM2KY7UN7FkkBNB+/ mtsXRoMVmVrXLEVWHSQ2OBKaMsmqm1GyZ7xIZ+BwJ38LpKtwCUYrJZ5xHScR1L4rGUe/9t HOV/Xv4ikKaVy+GxSs3Yrq1rZcUuVDpcGAug+HPER6nv3nZ8QnpGEWPCkmF67vkWX3Nipn 0PmHvogxFMsbgSzaRSC8ww40d0cd8Kkppnjnmx/fQvQ07UFB9ed0K7ZsLalZQNV8TYTuKx pmAe8L1JwyPNfU7ly0/leVHQXt29JoHPUzYKRhzb1GftudRK05G3zJ5/6m/4IQ== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1712679475; a=rsa-sha256; cv=none; b=S1Xwn3cpy9tsNLAM8evEjj6ThkCyx9ymxVgex+FGY1zhZIJ3GtHsmYJGcfn7re5h2nQMWx VSFhovb2HPAjHCTw0/pNGOCOGIk9tkGGNOKlildiryXM8QXg5u8pQ6/lCVUTHnyRdef5xX txj6EQTLuxg4LA6vk516b0MQ9YtbdPBIqjoSQyISddj13OnKZKOGtvghsk5CJakoICaUs8 sREwpzmQi7PtiXr+5QqY249B9cXf1uIQtqnRbstqPXO9TLbd4gX02fDcIR84n/3pVbEFgv ot1UyoA0n8R2/ZmwJktoDSuZDXwsF0Z2QlaUjUTBoxiTz0Ab9R6QDo670PVK2g== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1712679475; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=qpkhgTt9SHcYX3ZFb8HigWF0nc+qd/z5sBRX2nO3Obo=; b=GXlCv63Ve7eZgp22Z4FUfTvoiXeTls+rRYzpF/Nbchn1zgC6ASE6vvWHr7HVkkA5WXVx96 YWvRGkzWa6BLg0kER0XUjEblLiDEMTFgnEGC6skJpuxSC/+jIVPjOPhjGz9bebdPH3knyQ FaEd5B1cq79pfZD+WwK591QQyxaybmNoCCm4KlWfXwszwxLiGvevjiN0PXTwrQGfOe5mir aPW5qekVkrQFG1UAyI7Z5X6SRTkY+M2ISGZ981VazrFyfO3rj1QLw2le+SiEM9lRamj/Xp NXYzfgXnIp/TE/f/jtCgQEoyRABb51f+2ck4UfIFNmtbTFw0k6t7Dia+kIifHw== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4VDWMl2FhNz11L5; Tue, 9 Apr 2024 16:17:55 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.17.1/8.17.1) with ESMTP id 439GHtSg058756; Tue, 9 Apr 2024 16:17:55 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 439GHtxI058753; Tue, 9 Apr 2024 16:17:55 GMT (envelope-from git) Date: Tue, 9 Apr 2024 16:17:55 GMT Message-Id: <202404091617.439GHtxI058753@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Gleb Smirnoff Subject: git: e205fd318a29 - main - rpc: use new macros to lock socket buffers List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: dev-commits-src-all+owner@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: glebius X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: e205fd318a296ffdb7392486cdcec7f660fcffcf Auto-Submitted: auto-generated The branch main has been updated by glebius: URL: https://cgit.FreeBSD.org/src/commit/?id=e205fd318a296ffdb7392486cdcec7f660fcffcf commit e205fd318a296ffdb7392486cdcec7f660fcffcf Author: Gleb Smirnoff AuthorDate: 2024-04-09 16:17:19 +0000 Commit: Gleb Smirnoff CommitDate: 2024-04-09 16:17:19 +0000 rpc: use new macros to lock socket buffers Fixes: d80a97def9a1db6f07f5d2e68f7ad62b27918947 --- sys/rpc/clnt_bck.c | 4 ++-- sys/rpc/clnt_dg.c | 24 ++++++++++++------------ sys/rpc/clnt_vc.c | 24 ++++++++++++------------ sys/rpc/svc_dg.c | 16 ++++++++-------- sys/rpc/svc_vc.c | 20 ++++++++++---------- 5 files changed, 44 insertions(+), 44 deletions(-) diff --git a/sys/rpc/clnt_bck.c b/sys/rpc/clnt_bck.c index ab8fd514465c..7e4781ec7e9d 100644 --- a/sys/rpc/clnt_bck.c +++ b/sys/rpc/clnt_bck.c @@ -318,9 +318,9 @@ if (error != 0) printf("sosend=%d\n", error); mreq = NULL; if (error == EMSGSIZE) { printf("emsgsize\n"); - SOCKBUF_LOCK(&xprt->xp_socket->so_snd); + SOCK_SENDBUF_LOCK(xprt->xp_socket); sbwait(xprt->xp_socket, SO_SND); - SOCKBUF_UNLOCK(&xprt->xp_socket->so_snd); + SOCK_SENDBUF_UNLOCK(xprt->xp_socket); sx_xunlock(&xprt->xp_lock); AUTH_VALIDATE(auth, xid, NULL, NULL); mtx_lock(&ct->ct_lock); diff --git a/sys/rpc/clnt_dg.c b/sys/rpc/clnt_dg.c index f06f6b034c9a..b6a8cdce0d76 100644 --- a/sys/rpc/clnt_dg.c +++ b/sys/rpc/clnt_dg.c @@ -112,7 +112,7 @@ TAILQ_HEAD(cu_request_list, cu_request); * member. It is separate from the client private data to facilitate * multiple clients sharing the same socket. The cs_lock mutex is used * to protect all fields of this structure, the socket's receive - * buffer SOCKBUF_LOCK is used to ensure that exactly one of these + * buffer lock is used to ensure that exactly one of these * structures is installed on the socket. */ struct cu_socket { @@ -270,11 +270,11 @@ clnt_dg_create( } sb = &so->so_rcv; - SOCKBUF_LOCK(&so->so_rcv); + SOCK_RECVBUF_LOCK(so); recheck_socket: if (sb->sb_upcall) { if (sb->sb_upcall != clnt_dg_soupcall) { - SOCKBUF_UNLOCK(&so->so_rcv); + SOCK_RECVBUF_UNLOCK(so); printf("clnt_dg_create(): socket already has an incompatible upcall\n"); goto err2; } @@ -287,9 +287,9 @@ recheck_socket: * We are the first on this socket - allocate the * structure and install it in the socket. */ - SOCKBUF_UNLOCK(&so->so_rcv); + SOCK_RECVBUF_UNLOCK(so); cs = mem_alloc(sizeof(*cs)); - SOCKBUF_LOCK(&so->so_rcv); + SOCK_RECVBUF_LOCK(so); if (sb->sb_upcall) { /* * We have lost a race with some other client. @@ -303,7 +303,7 @@ recheck_socket: TAILQ_INIT(&cs->cs_pending); soupcall_set(so, SO_RCV, clnt_dg_soupcall, cs); } - SOCKBUF_UNLOCK(&so->so_rcv); + SOCK_RECVBUF_UNLOCK(so); cl->cl_refs = 1; cl->cl_ops = &clnt_dg_ops; @@ -993,7 +993,7 @@ clnt_dg_destroy(CLIENT *cl) cs = cu->cu_socket->so_rcv.sb_upcallarg; clnt_dg_close(cl); - SOCKBUF_LOCK(&cu->cu_socket->so_rcv); + SOCK_RECVBUF_LOCK(cu->cu_socket); mtx_lock(&cs->cs_lock); cs->cs_refs--; @@ -1001,13 +1001,13 @@ clnt_dg_destroy(CLIENT *cl) mtx_unlock(&cs->cs_lock); soupcall_clear(cu->cu_socket, SO_RCV); clnt_dg_upcallsdone(cu->cu_socket, cs); - SOCKBUF_UNLOCK(&cu->cu_socket->so_rcv); + SOCK_RECVBUF_UNLOCK(cu->cu_socket); mtx_destroy(&cs->cs_lock); mem_free(cs, sizeof(*cs)); lastsocketref = TRUE; } else { mtx_unlock(&cs->cs_lock); - SOCKBUF_UNLOCK(&cu->cu_socket->so_rcv); + SOCK_RECVBUF_UNLOCK(cu->cu_socket); lastsocketref = FALSE; } @@ -1052,14 +1052,14 @@ clnt_dg_soupcall(struct socket *so, void *arg, int waitflag) uio.uio_resid = 1000000000; uio.uio_td = curthread; do { - SOCKBUF_UNLOCK(&so->so_rcv); + SOCK_RECVBUF_UNLOCK(so); m = NULL; control = NULL; rcvflag = MSG_DONTWAIT; error = soreceive(so, NULL, &uio, &m, &control, &rcvflag); if (control) m_freem(control); - SOCKBUF_LOCK(&so->so_rcv); + SOCK_RECVBUF_LOCK(so); if (error == EWOULDBLOCK) break; @@ -1140,7 +1140,7 @@ static void clnt_dg_upcallsdone(struct socket *so, struct cu_socket *cs) { - SOCKBUF_LOCK_ASSERT(&so->so_rcv); + SOCK_RECVBUF_LOCK_ASSERT(so); while (cs->cs_upcallrefs > 0) (void) msleep(&cs->cs_upcallrefs, SOCKBUF_MTX(&so->so_rcv), 0, diff --git a/sys/rpc/clnt_vc.c b/sys/rpc/clnt_vc.c index 8b69117ba2ac..386153dc1f36 100644 --- a/sys/rpc/clnt_vc.c +++ b/sys/rpc/clnt_vc.c @@ -263,9 +263,9 @@ clnt_vc_create( cl->cl_private = ct; cl->cl_auth = authnone_create(); - SOCKBUF_LOCK(&ct->ct_socket->so_rcv); + SOCK_RECVBUF_LOCK(ct->ct_socket); soupcall_set(ct->ct_socket, SO_RCV, clnt_vc_soupcall, ct); - SOCKBUF_UNLOCK(&ct->ct_socket->so_rcv); + SOCK_RECVBUF_UNLOCK(ct->ct_socket); ct->ct_raw = NULL; ct->ct_record = NULL; @@ -437,9 +437,9 @@ call_again: mreq = NULL; if (error == EMSGSIZE || (error == ERESTART && (ct->ct_waitflag & PCATCH) == 0 && trycnt-- > 0)) { - SOCKBUF_LOCK(&ct->ct_socket->so_snd); + SOCK_SENDBUF_LOCK(ct->ct_socket); sbwait(ct->ct_socket, SO_SND); - SOCKBUF_UNLOCK(&ct->ct_socket->so_snd); + SOCK_SENDBUF_UNLOCK(ct->ct_socket); AUTH_VALIDATE(auth, xid, NULL, NULL); mtx_lock(&ct->ct_lock); TAILQ_REMOVE(&ct->ct_pending, cr, cr_link); @@ -821,12 +821,12 @@ clnt_vc_close(CLIENT *cl) ct->ct_closing = TRUE; mtx_unlock(&ct->ct_lock); - SOCKBUF_LOCK(&ct->ct_socket->so_rcv); + SOCK_RECVBUF_LOCK(ct->ct_socket); if (ct->ct_socket->so_rcv.sb_upcall != NULL) { soupcall_clear(ct->ct_socket, SO_RCV); clnt_vc_upcallsdone(ct); } - SOCKBUF_UNLOCK(&ct->ct_socket->so_rcv); + SOCK_RECVBUF_UNLOCK(ct->ct_socket); /* * Abort any pending requests and wait until everyone @@ -967,7 +967,7 @@ clnt_vc_soupcall(struct socket *so, void *arg, int waitflag) /* * If another thread is already here, it must be in * soreceive(), so just return to avoid races with it. - * ct_upcallrefs is protected by the SOCKBUF_LOCK(), + * ct_upcallrefs is protected by the socket receive buffer lock * which is held in this function, except when * soreceive() is called. */ @@ -987,9 +987,9 @@ clnt_vc_soupcall(struct socket *so, void *arg, int waitflag) if (ct->ct_sslrefno != 0 && (ct->ct_rcvstate & RPCRCVSTATE_NORMAL) != 0) rcvflag |= MSG_TLSAPPDATA; - SOCKBUF_UNLOCK(&so->so_rcv); + SOCK_RECVBUF_UNLOCK(so); error = soreceive(so, NULL, &uio, &m, &m2, &rcvflag); - SOCKBUF_LOCK(&so->so_rcv); + SOCK_RECVBUF_LOCK(so); if (error == EWOULDBLOCK) { /* @@ -1255,7 +1255,7 @@ static void clnt_vc_upcallsdone(struct ct_data *ct) { - SOCKBUF_LOCK_ASSERT(&ct->ct_socket->so_rcv); + SOCK_RECVBUF_LOCK_ASSERT(ct->ct_socket); while (ct->ct_upcallrefs > 0) (void) msleep(&ct->ct_upcallrefs, @@ -1296,9 +1296,9 @@ clnt_vc_dotlsupcall(void *data) if ((ct->ct_rcvstate & RPCRCVSTATE_SOUPCALLNEEDED) != 0) { ct->ct_rcvstate &= ~RPCRCVSTATE_SOUPCALLNEEDED; mtx_unlock(&ct->ct_lock); - SOCKBUF_LOCK(&ct->ct_socket->so_rcv); + SOCK_RECVBUF_LOCK(ct->ct_socket); clnt_vc_soupcall(ct->ct_socket, ct, M_NOWAIT); - SOCKBUF_UNLOCK(&ct->ct_socket->so_rcv); + SOCK_RECVBUF_UNLOCK(ct->ct_socket); mtx_lock(&ct->ct_lock); } msleep(&ct->ct_sslrefno, &ct->ct_lock, 0, "clntvcdu", hz); diff --git a/sys/rpc/svc_dg.c b/sys/rpc/svc_dg.c index d77a727e820d..02e0c9a43fd9 100644 --- a/sys/rpc/svc_dg.c +++ b/sys/rpc/svc_dg.c @@ -130,9 +130,9 @@ svc_dg_create(SVCPOOL *pool, struct socket *so, size_t sendsize, xprt_register(xprt); - SOCKBUF_LOCK(&so->so_rcv); + SOCK_RECVBUF_LOCK(so); soupcall_set(so, SO_RCV, svc_dg_soupcall, xprt); - SOCKBUF_UNLOCK(&so->so_rcv); + SOCK_RECVBUF_UNLOCK(so); return (xprt); freedata: @@ -190,18 +190,18 @@ svc_dg_recv(SVCXPRT *xprt, struct rpc_msg *msg, * from racing the upcall after our soreadable() call * returns false. */ - SOCKBUF_LOCK(&xprt->xp_socket->so_rcv); + SOCK_RECVBUF_LOCK(xprt->xp_socket); if (!soreadable(xprt->xp_socket)) xprt_inactive_self(xprt); - SOCKBUF_UNLOCK(&xprt->xp_socket->so_rcv); + SOCK_RECVBUF_UNLOCK(xprt->xp_socket); sx_xunlock(&xprt->xp_lock); return (FALSE); } if (error) { - SOCKBUF_LOCK(&xprt->xp_socket->so_rcv); + SOCK_RECVBUF_LOCK(xprt->xp_socket); soupcall_clear(xprt->xp_socket, SO_RCV); - SOCKBUF_UNLOCK(&xprt->xp_socket->so_rcv); + SOCK_RECVBUF_UNLOCK(xprt->xp_socket); xprt_inactive_self(xprt); sx_xunlock(&xprt->xp_lock); return (FALSE); @@ -266,9 +266,9 @@ static void svc_dg_destroy(SVCXPRT *xprt) { - SOCKBUF_LOCK(&xprt->xp_socket->so_rcv); + SOCK_RECVBUF_LOCK(xprt->xp_socket); soupcall_clear(xprt->xp_socket, SO_RCV); - SOCKBUF_UNLOCK(&xprt->xp_socket->so_rcv); + SOCK_RECVBUF_UNLOCK(xprt->xp_socket); sx_destroy(&xprt->xp_lock); if (xprt->xp_socket) diff --git a/sys/rpc/svc_vc.c b/sys/rpc/svc_vc.c index 8e7ff888eaa2..9fc4108a5149 100644 --- a/sys/rpc/svc_vc.c +++ b/sys/rpc/svc_vc.c @@ -315,10 +315,10 @@ svc_vc_create_conn(SVCPOOL *pool, struct socket *so, struct sockaddr *raddr) xprt_register(xprt); - SOCKBUF_LOCK(&so->so_rcv); + SOCK_RECVBUF_LOCK(so); xprt->xp_upcallset = 1; soupcall_set(so, SO_RCV, svc_vc_soupcall, xprt); - SOCKBUF_UNLOCK(&so->so_rcv); + SOCK_RECVBUF_UNLOCK(so); /* * Throw the transport into the active list in case it already @@ -537,13 +537,13 @@ svc_vc_destroy(SVCXPRT *xprt) struct cf_conn *cd = (struct cf_conn *)xprt->xp_p1; CLIENT *cl = (CLIENT *)xprt->xp_p2; - SOCKBUF_LOCK(&xprt->xp_socket->so_rcv); + SOCK_RECVBUF_LOCK(xprt->xp_socket); if (xprt->xp_upcallset) { xprt->xp_upcallset = 0; if (xprt->xp_socket->so_rcv.sb_upcall != NULL) soupcall_clear(xprt->xp_socket, SO_RCV); } - SOCKBUF_UNLOCK(&xprt->xp_socket->so_rcv); + SOCK_RECVBUF_UNLOCK(xprt->xp_socket); if (cl != NULL) CLNT_RELEASE(cl); @@ -780,10 +780,10 @@ svc_vc_recv(SVCXPRT *xprt, struct rpc_msg *msg, /* Check for next request in a pending queue. */ svc_vc_process_pending(xprt); if (cd->mreq == NULL || cd->resid != 0) { - SOCKBUF_LOCK(&so->so_rcv); + SOCK_RECVBUF_LOCK(so); if (!soreadable(so)) xprt_inactive_self(xprt); - SOCKBUF_UNLOCK(&so->so_rcv); + SOCK_RECVBUF_UNLOCK(so); } sx_xunlock(&xprt->xp_lock); @@ -834,10 +834,10 @@ tryagain: * after our call to soreceive fails with * EWOULDBLOCK. */ - SOCKBUF_LOCK(&so->so_rcv); + SOCK_RECVBUF_LOCK(so); if (!soreadable(so)) xprt_inactive_self(xprt); - SOCKBUF_UNLOCK(&so->so_rcv); + SOCK_RECVBUF_UNLOCK(so); sx_xunlock(&xprt->xp_lock); return (FALSE); } @@ -877,12 +877,12 @@ tryagain: if (error) { KRPC_CURVNET_RESTORE(); - SOCKBUF_LOCK(&so->so_rcv); + SOCK_RECVBUF_LOCK(so); if (xprt->xp_upcallset) { xprt->xp_upcallset = 0; soupcall_clear(so, SO_RCV); } - SOCKBUF_UNLOCK(&so->so_rcv); + SOCK_RECVBUF_UNLOCK(so); xprt_inactive_self(xprt); cd->strm_stat = XPRT_DIED; sx_xunlock(&xprt->xp_lock);