SUNRPC: Fix a slow server-side memory leak with RPC-over-TCP
authorChuck Lever <chuck.lever@oracle.com>
Wed, 3 Apr 2024 14:36:25 +0000 (10:36 -0400)
committerChuck Lever <chuck.lever@oracle.com>
Thu, 4 Apr 2024 13:43:02 +0000 (09:43 -0400)
commit05258a0a69b3c5d2c003f818702c0a52b6fea861
treec76a5d2475d8a7f76086cb491949bc2e7619dbad
parent99dc2ef0397d082b63404c01cf841cf80f1418dc
SUNRPC: Fix a slow server-side memory leak with RPC-over-TCP

Jan Schunk reports that his small NFS servers suffer from memory
exhaustion after just a few days. A bisect shows that commit
e18e157bb5c8 ("SUNRPC: Send RPC message on TCP with a single
sock_sendmsg() call") is the first bad commit.

That commit assumed that sock_sendmsg() releases all the pages in
the underlying bio_vec array, but the reality is that it doesn't.
svc_xprt_release() releases the rqst's response pages, but the
record marker page fragment isn't one of those, so it is never
released.

This is a narrow fix that can be applied to stable kernels. A
more extensive fix is in the works.

Reported-by: Jan Schunk <scpcom@gmx.de>
Closes: https://bugzilla.kernel.org/show_bug.cgi?id=218671
Fixes: e18e157bb5c8 ("SUNRPC: Send RPC message on TCP with a single sock_sendmsg() call")
Cc: Alexander Duyck <alexander.duyck@gmail.com>
Cc: Jakub Kacinski <kuba@kernel.org>
Cc: David Howells <dhowells@redhat.com>
Reviewed-by: David Howells <dhowells@redhat.com>
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
net/sunrpc/svcsock.c