All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] NFSD: Make use of the helper macro kthread_run()
@ 2021-10-21  8:42 Cai Huoqing
  2021-10-21 13:27 ` Trond Myklebust
  0 siblings, 1 reply; 2+ messages in thread
From: Cai Huoqing @ 2021-10-21  8:42 UTC (permalink / raw)
  To: caihuoqing; +Cc: J. Bruce Fields, Chuck Lever, linux-nfs, linux-kernel

Repalce kthread_create/wake_up_process() with kthread_run()
to simplify the code.

Signed-off-by: Cai Huoqing <caihuoqing@baidu.com>
---
 fs/nfsd/nfs4proc.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/fs/nfsd/nfs4proc.c b/fs/nfsd/nfs4proc.c
index a36261f89bdf..69428cb31a55 100644
--- a/fs/nfsd/nfs4proc.c
+++ b/fs/nfsd/nfs4proc.c
@@ -1685,15 +1685,15 @@ nfsd4_copy(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate,
 		memcpy(&copy->cp_res.cb_stateid, &copy->cp_stateid.stid,
 			sizeof(copy->cp_res.cb_stateid));
 		dup_copy_fields(copy, async_copy);
-		async_copy->copy_task = kthread_create(nfsd4_do_async_copy,
-				async_copy, "%s", "copy thread");
+		async_copy->copy_task = kthread_run(nfsd4_do_async_copy,
+						    async_copy, "%s",
+						    "copy thread");
 		if (IS_ERR(async_copy->copy_task))
 			goto out_err;
 		spin_lock(&async_copy->cp_clp->async_lock);
 		list_add(&async_copy->copies,
 				&async_copy->cp_clp->async_copies);
 		spin_unlock(&async_copy->cp_clp->async_lock);
-		wake_up_process(async_copy->copy_task);
 		status = nfs_ok;
 	} else {
 		status = nfsd4_do_copy(copy, 1);
-- 
2.25.1


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

* Re: [PATCH] NFSD: Make use of the helper macro kthread_run()
  2021-10-21  8:42 [PATCH] NFSD: Make use of the helper macro kthread_run() Cai Huoqing
@ 2021-10-21 13:27 ` Trond Myklebust
  0 siblings, 0 replies; 2+ messages in thread
From: Trond Myklebust @ 2021-10-21 13:27 UTC (permalink / raw)
  To: caihuoqing; +Cc: bfields, linux-nfs, linux-kernel, chuck.lever

On Thu, 2021-10-21 at 16:42 +0800, Cai Huoqing wrote:
> [You don't often get email from caihuoqing@baidu.com. Learn why this
> is important at http://aka.ms/LearnAboutSenderIdentification.]
> 
> Repalce kthread_create/wake_up_process() with kthread_run()
> to simplify the code.
> 
> Signed-off-by: Cai Huoqing <caihuoqing@baidu.com>
> ---
>  fs/nfsd/nfs4proc.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/fs/nfsd/nfs4proc.c b/fs/nfsd/nfs4proc.c
> index a36261f89bdf..69428cb31a55 100644
> --- a/fs/nfsd/nfs4proc.c
> +++ b/fs/nfsd/nfs4proc.c
> @@ -1685,15 +1685,15 @@ nfsd4_copy(struct svc_rqst *rqstp, struct
> nfsd4_compound_state *cstate,
>                 memcpy(&copy->cp_res.cb_stateid, &copy-
> >cp_stateid.stid,
>                         sizeof(copy->cp_res.cb_stateid));
>                 dup_copy_fields(copy, async_copy);
> -               async_copy->copy_task =
> kthread_create(nfsd4_do_async_copy,
> -                               async_copy, "%s", "copy thread");
> +               async_copy->copy_task =
> kthread_run(nfsd4_do_async_copy,
> +                                                   async_copy, "%s",
> +                                                   "copy thread");
>                 if (IS_ERR(async_copy->copy_task))
>                         goto out_err;
>                 spin_lock(&async_copy->cp_clp->async_lock);
>                 list_add(&async_copy->copies,
>                                 &async_copy->cp_clp->async_copies);
>                 spin_unlock(&async_copy->cp_clp->async_lock);
> -               wake_up_process(async_copy->copy_task);
>                 status = nfs_ok;
>         } else {
>                 status = nfsd4_do_copy(copy, 1);
> --
> 2.25.1
> 

Ditto. This too would cause the thread to start running before
async_copy has been fully initialised.

-- 
Trond Myklebust
Linux NFS client maintainer, Hammerspace
trond.myklebust@hammerspace.com



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

end of thread, other threads:[~2021-10-21 13:27 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-10-21  8:42 [PATCH] NFSD: Make use of the helper macro kthread_run() Cai Huoqing
2021-10-21 13:27 ` Trond Myklebust

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.