[PATCH linux-next v2] SUNRPC: Change list definition method

Chenguang Zhao posted 1 patch 1 week, 4 days ago
net/sunrpc/backchannel_rqst.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
[PATCH linux-next v2] SUNRPC: Change list definition method
Posted by Chenguang Zhao 1 week, 4 days ago
The LIST_HEAD macro can both define a linked list and initialize
it in one step. To simplify code, we replace the separate operations
of linked list definition and manual initialization with the LIST_HEAD
macro.

Signed-off-by: Chenguang Zhao <zhaochenguang@kylinos.cn>
---
v2:
 - Modify the commit message according to Chuck's suggestion
 
 net/sunrpc/backchannel_rqst.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/net/sunrpc/backchannel_rqst.c b/net/sunrpc/backchannel_rqst.c
index caa94cf57123..949022c5574c 100644
--- a/net/sunrpc/backchannel_rqst.c
+++ b/net/sunrpc/backchannel_rqst.c
@@ -131,7 +131,7 @@ EXPORT_SYMBOL_GPL(xprt_setup_backchannel);
 int xprt_setup_bc(struct rpc_xprt *xprt, unsigned int min_reqs)
 {
 	struct rpc_rqst *req;
-	struct list_head tmp_list;
+	LIST_HEAD(tmp_list);
 	int i;
 
 	dprintk("RPC:       setup backchannel transport\n");
@@ -147,7 +147,6 @@ int xprt_setup_bc(struct rpc_xprt *xprt, unsigned int min_reqs)
 	 * lock is held on the rpc_xprt struct.  It also makes cleanup
 	 * easier in case of memory allocation errors.
 	 */
-	INIT_LIST_HEAD(&tmp_list);
 	for (i = 0; i < min_reqs; i++) {
 		/* Pre-allocate one backchannel rpc_rqst */
 		req = xprt_alloc_bc_req(xprt);
-- 
2.25.1
Re: [PATCH linux-next v2] SUNRPC: Change list definition method
Posted by Chuck Lever 1 week, 1 day ago

On Mon, Dec 8, 2025, at 3:53 AM, Chenguang Zhao wrote:
> The LIST_HEAD macro can both define a linked list and initialize
> it in one step. To simplify code, we replace the separate operations
> of linked list definition and manual initialization with the LIST_HEAD
> macro.
>
> Signed-off-by: Chenguang Zhao <zhaochenguang@kylinos.cn>
> ---
> v2:
>  - Modify the commit message according to Chuck's suggestion
> 
>  net/sunrpc/backchannel_rqst.c | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
>
> diff --git a/net/sunrpc/backchannel_rqst.c b/net/sunrpc/backchannel_rqst.c
> index caa94cf57123..949022c5574c 100644
> --- a/net/sunrpc/backchannel_rqst.c
> +++ b/net/sunrpc/backchannel_rqst.c
> @@ -131,7 +131,7 @@ EXPORT_SYMBOL_GPL(xprt_setup_backchannel);
>  int xprt_setup_bc(struct rpc_xprt *xprt, unsigned int min_reqs)
>  {
>  	struct rpc_rqst *req;
> -	struct list_head tmp_list;
> +	LIST_HEAD(tmp_list);
>  	int i;
> 
>  	dprintk("RPC:       setup backchannel transport\n");
> @@ -147,7 +147,6 @@ int xprt_setup_bc(struct rpc_xprt *xprt, unsigned 
> int min_reqs)
>  	 * lock is held on the rpc_xprt struct.  It also makes cleanup
>  	 * easier in case of memory allocation errors.
>  	 */
> -	INIT_LIST_HEAD(&tmp_list);
>  	for (i = 0; i < min_reqs; i++) {
>  		/* Pre-allocate one backchannel rpc_rqst */
>  		req = xprt_alloc_bc_req(xprt);
> -- 
> 2.25.1

backchannel_rqst.c looks like a client-side file, so I defer to my
colleagues who maintain the Linux NFS client.

Reviewed-by: Chuck Lever <chuck.lever@oracle.com>


-- 
Chuck Lever
Re: [PATCH linux-next v2] SUNRPC: Change list definition method
Posted by Jeff Layton 1 week, 4 days ago
On Mon, 2025-12-08 at 16:53 +0800, Chenguang Zhao wrote:
> The LIST_HEAD macro can both define a linked list and initialize
> it in one step. To simplify code, we replace the separate operations
> of linked list definition and manual initialization with the LIST_HEAD
> macro.
> 
> Signed-off-by: Chenguang Zhao <zhaochenguang@kylinos.cn>
> ---
> v2:
>  - Modify the commit message according to Chuck's suggestion
>  
>  net/sunrpc/backchannel_rqst.c | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
> 
> diff --git a/net/sunrpc/backchannel_rqst.c b/net/sunrpc/backchannel_rqst.c
> index caa94cf57123..949022c5574c 100644
> --- a/net/sunrpc/backchannel_rqst.c
> +++ b/net/sunrpc/backchannel_rqst.c
> @@ -131,7 +131,7 @@ EXPORT_SYMBOL_GPL(xprt_setup_backchannel);
>  int xprt_setup_bc(struct rpc_xprt *xprt, unsigned int min_reqs)
>  {
>  	struct rpc_rqst *req;
> -	struct list_head tmp_list;
> +	LIST_HEAD(tmp_list);
>  	int i;
>  
>  	dprintk("RPC:       setup backchannel transport\n");
> @@ -147,7 +147,6 @@ int xprt_setup_bc(struct rpc_xprt *xprt, unsigned int min_reqs)
>  	 * lock is held on the rpc_xprt struct.  It also makes cleanup
>  	 * easier in case of memory allocation errors.
>  	 */
> -	INIT_LIST_HEAD(&tmp_list);
>  	for (i = 0; i < min_reqs; i++) {
>  		/* Pre-allocate one backchannel rpc_rqst */
>  		req = xprt_alloc_bc_req(xprt);

Thought I'd already sent this, but...

Reviewed-by: Jeff Layton <jlayton@kernel.org>