mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH 0/2] sunrpc: cleanup patches for svc_tcp_sendto() and svc_tcp_sendmsg()
@ 2025-08-11 14:37 Jeff Layton
  2025-08-11 14:37 ` [PATCH 1/2] sunrpc: fix pr_notice in svc_tcp_sendto() to show correct length Jeff Layton
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Jeff Layton @ 2025-08-11 14:37 UTC (permalink / raw)
  To: Chuck Lever, NeilBrown, Olga Kornievskaia, Dai Ngo, Tom Talpey,
	Trond Myklebust, Anna Schumaker
  Cc: linux-nfs, linux-kernel, Jeff Layton

These patches fix a minor annoyance in a pr_notice() and clean up
svc_tcp_sendmsg() to not require a return pointer. Please consider for
v6.18.

Signed-off-by: Jeff Layton <jlayton@kernel.org>
---
Jeff Layton (2):
      sunrpc: fix pr_notice in svc_tcp_sendto() to show correct length
      sunrpc: eliminate return pointer in svc_tcp_sendmsg()

 net/sunrpc/svcsock.c | 23 +++++++++--------------
 1 file changed, 9 insertions(+), 14 deletions(-)
---
base-commit: 8f5ae30d69d7543eee0d70083daf4de8fe15d585
change-id: 20250811-nfsd-testing-03aafd313a72

Best regards,
-- 
Jeff Layton <jlayton@kernel.org>


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH 1/2] sunrpc: fix pr_notice in svc_tcp_sendto() to show correct length
  2025-08-11 14:37 [PATCH 0/2] sunrpc: cleanup patches for svc_tcp_sendto() and svc_tcp_sendmsg() Jeff Layton
@ 2025-08-11 14:37 ` Jeff Layton
  2025-08-11 14:37 ` [PATCH 2/2] sunrpc: eliminate return pointer in svc_tcp_sendmsg() Jeff Layton
  2025-08-11 15:06 ` [PATCH 0/2] sunrpc: cleanup patches for svc_tcp_sendto() and svc_tcp_sendmsg() Chuck Lever
  2 siblings, 0 replies; 4+ messages in thread
From: Jeff Layton @ 2025-08-11 14:37 UTC (permalink / raw)
  To: Chuck Lever, NeilBrown, Olga Kornievskaia, Dai Ngo, Tom Talpey,
	Trond Myklebust, Anna Schumaker
  Cc: linux-nfs, linux-kernel, Jeff Layton

This pr_notice() is confusing since it only prints xdr->len, which
doesn't include the 4-byte record marker.  That can make it sometimes
look like the socket sent more than was requested if it's short by just
a few bytes.

Add sizeof(marker) to the size and fix the format accordingly.

Signed-off-by: Jeff Layton <jlayton@kernel.org>
---
 net/sunrpc/svcsock.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/net/sunrpc/svcsock.c b/net/sunrpc/svcsock.c
index 46c156b121db43c1bd1806a08a3a9bf08b332699..22f59289fdcf17137fcac59e13975281ecf3e380 100644
--- a/net/sunrpc/svcsock.c
+++ b/net/sunrpc/svcsock.c
@@ -1266,10 +1266,10 @@ static int svc_tcp_sendto(struct svc_rqst *rqstp)
 	mutex_unlock(&xprt->xpt_mutex);
 	return -ENOTCONN;
 out_close:
-	pr_notice("rpc-srv/tcp: %s: %s %d when sending %d bytes - shutting down socket\n",
+	pr_notice("rpc-srv/tcp: %s: %s %d when sending %zu bytes - shutting down socket\n",
 		  xprt->xpt_server->sv_name,
 		  (err < 0) ? "got error" : "sent",
-		  (err < 0) ? err : sent, xdr->len);
+		  (err < 0) ? err : sent, xdr->len + sizeof(marker));
 	svc_xprt_deferred_close(xprt);
 	mutex_unlock(&xprt->xpt_mutex);
 	return -EAGAIN;

-- 
2.50.1


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH 2/2] sunrpc: eliminate return pointer in svc_tcp_sendmsg()
  2025-08-11 14:37 [PATCH 0/2] sunrpc: cleanup patches for svc_tcp_sendto() and svc_tcp_sendmsg() Jeff Layton
  2025-08-11 14:37 ` [PATCH 1/2] sunrpc: fix pr_notice in svc_tcp_sendto() to show correct length Jeff Layton
@ 2025-08-11 14:37 ` Jeff Layton
  2025-08-11 15:06 ` [PATCH 0/2] sunrpc: cleanup patches for svc_tcp_sendto() and svc_tcp_sendmsg() Chuck Lever
  2 siblings, 0 replies; 4+ messages in thread
From: Jeff Layton @ 2025-08-11 14:37 UTC (permalink / raw)
  To: Chuck Lever, NeilBrown, Olga Kornievskaia, Dai Ngo, Tom Talpey,
	Trond Myklebust, Anna Schumaker
  Cc: linux-nfs, linux-kernel, Jeff Layton

Return a positive value if something was sent, or a negative error code.
Eliminate the "err" variable in the only caller as well.

Signed-off-by: Jeff Layton <jlayton@kernel.org>
---
 net/sunrpc/svcsock.c | 21 ++++++++-------------
 1 file changed, 8 insertions(+), 13 deletions(-)

diff --git a/net/sunrpc/svcsock.c b/net/sunrpc/svcsock.c
index 22f59289fdcf17137fcac59e13975281ecf3e380..2b531d6d5edd92b2c2fe3b774f67e5ecaa9fd57f 100644
--- a/net/sunrpc/svcsock.c
+++ b/net/sunrpc/svcsock.c
@@ -1197,7 +1197,7 @@ static int svc_tcp_recvfrom(struct svc_rqst *rqstp)
  * that the pages backing @xdr are unchanging.
  */
 static int svc_tcp_sendmsg(struct svc_sock *svsk, struct svc_rqst *rqstp,
-			   rpc_fraghdr marker, int *sentp)
+			   rpc_fraghdr marker)
 {
 	struct msghdr msg = {
 		.msg_flags	= MSG_SPLICE_PAGES,
@@ -1206,8 +1206,6 @@ static int svc_tcp_sendmsg(struct svc_sock *svsk, struct svc_rqst *rqstp,
 	void *buf;
 	int ret;
 
-	*sentp = 0;
-
 	/* The stream record marker is copied into a temporary page
 	 * fragment buffer so that it can be included in rq_bvec.
 	 */
@@ -1225,10 +1223,7 @@ static int svc_tcp_sendmsg(struct svc_sock *svsk, struct svc_rqst *rqstp,
 		      1 + count, sizeof(marker) + rqstp->rq_res.len);
 	ret = sock_sendmsg(svsk->sk_sock, &msg);
 	page_frag_free(buf);
-	if (ret < 0)
-		return ret;
-	*sentp += ret;
-	return 0;
+	return ret;
 }
 
 /**
@@ -1247,7 +1242,7 @@ static int svc_tcp_sendto(struct svc_rqst *rqstp)
 	struct xdr_buf *xdr = &rqstp->rq_res;
 	rpc_fraghdr marker = cpu_to_be32(RPC_LAST_STREAM_FRAGMENT |
 					 (u32)xdr->len);
-	int sent, err;
+	int sent;
 
 	svc_tcp_release_ctxt(xprt, rqstp->rq_xprt_ctxt);
 	rqstp->rq_xprt_ctxt = NULL;
@@ -1255,9 +1250,9 @@ static int svc_tcp_sendto(struct svc_rqst *rqstp)
 	mutex_lock(&xprt->xpt_mutex);
 	if (svc_xprt_is_dead(xprt))
 		goto out_notconn;
-	err = svc_tcp_sendmsg(svsk, rqstp, marker, &sent);
-	trace_svcsock_tcp_send(xprt, err < 0 ? (long)err : sent);
-	if (err < 0 || sent != (xdr->len + sizeof(marker)))
+	sent = svc_tcp_sendmsg(svsk, rqstp, marker);
+	trace_svcsock_tcp_send(xprt, sent);
+	if (sent < 0 || sent != (xdr->len + sizeof(marker)))
 		goto out_close;
 	mutex_unlock(&xprt->xpt_mutex);
 	return sent;
@@ -1268,8 +1263,8 @@ static int svc_tcp_sendto(struct svc_rqst *rqstp)
 out_close:
 	pr_notice("rpc-srv/tcp: %s: %s %d when sending %zu bytes - shutting down socket\n",
 		  xprt->xpt_server->sv_name,
-		  (err < 0) ? "got error" : "sent",
-		  (err < 0) ? err : sent, xdr->len + sizeof(marker));
+		  (sent < 0) ? "got error" : "sent",
+		  sent, xdr->len + sizeof(marker));
 	svc_xprt_deferred_close(xprt);
 	mutex_unlock(&xprt->xpt_mutex);
 	return -EAGAIN;

-- 
2.50.1


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH 0/2] sunrpc: cleanup patches for svc_tcp_sendto() and svc_tcp_sendmsg()
  2025-08-11 14:37 [PATCH 0/2] sunrpc: cleanup patches for svc_tcp_sendto() and svc_tcp_sendmsg() Jeff Layton
  2025-08-11 14:37 ` [PATCH 1/2] sunrpc: fix pr_notice in svc_tcp_sendto() to show correct length Jeff Layton
  2025-08-11 14:37 ` [PATCH 2/2] sunrpc: eliminate return pointer in svc_tcp_sendmsg() Jeff Layton
@ 2025-08-11 15:06 ` Chuck Lever
  2 siblings, 0 replies; 4+ messages in thread
From: Chuck Lever @ 2025-08-11 15:06 UTC (permalink / raw)
  To: NeilBrown, Olga Kornievskaia, Dai Ngo, Tom Talpey,
	Trond Myklebust, Anna Schumaker, Jeff Layton
  Cc: Chuck Lever, linux-nfs, linux-kernel

From: Chuck Lever <chuck.lever@oracle.com>

On Mon, 11 Aug 2025 10:37:06 -0400, Jeff Layton wrote:
> These patches fix a minor annoyance in a pr_notice() and clean up
> svc_tcp_sendmsg() to not require a return pointer. Please consider for
> v6.18.
> 
> 

Applied to nfsd-testing, thanks!

[1/2] sunrpc: fix pr_notice in svc_tcp_sendto() to show correct length
      commit: 0ce84089fb1ab484cafb219355bee967f9d12311
[2/2] sunrpc: eliminate return pointer in svc_tcp_sendmsg()
      commit: 2a8e3cfc134a8e198c25a1680a83bbbbcdc1901d

--
Chuck Lever


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2025-08-11 15:06 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-08-11 14:37 [PATCH 0/2] sunrpc: cleanup patches for svc_tcp_sendto() and svc_tcp_sendmsg() Jeff Layton
2025-08-11 14:37 ` [PATCH 1/2] sunrpc: fix pr_notice in svc_tcp_sendto() to show correct length Jeff Layton
2025-08-11 14:37 ` [PATCH 2/2] sunrpc: eliminate return pointer in svc_tcp_sendmsg() Jeff Layton
2025-08-11 15:06 ` [PATCH 0/2] sunrpc: cleanup patches for svc_tcp_sendto() and svc_tcp_sendmsg() Chuck Lever

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®