lockd: Do not start the lockd thread before we've set nlmsvc_rqst->rq_task
Subsystems (2)
PATCH 1/2 lockd: Do not start the lockd thread before we've set nlmsvc_rqst->rq_task
This fixes an Oopsable race when starting lockd.
--- fs/lockd/svc.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
fs/lockd/svc.c +2 -1
@@ -306,7 +306,7 @@ static int lockd_start_svc(struct svc_serv *serv)svc_sock_update_bufs (serv); serv->sv_maxconn = nlm_max_connections; - nlmsvc_task =kthread_run (lockd, nlmsvc_rqst,"%s" , serv->sv_name); + nlmsvc_task =kthread_create (lockd, nlmsvc_rqst,"%s" , serv->sv_name);if (IS_ERR (nlmsvc_task)) { error =PTR_ERR (nlmsvc_task); printk(KERN_WARNING
@@ -314,6 +314,7 @@ static int lockd_start_svc(struct svc_serv *serv) goto out_task; } nlmsvc_rqst->rq_task = nlmsvc_task; +wake_up_process (nlmsvc_task);dprintk ("lockd_up: service started\n" );return 0 ;
Signature · 1 line
1.9.3
PATCH 2/2 nfs: do not start the callback thread until we set rqstp->rq_task
This fixes an Oopsable race when starting up the callback server.
--- fs/nfs/callback.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
fs/nfs/callback.c +2 -1
@@ -235,7 +235,7 @@ static int nfs_callback_start_svc(int minorversion, struct rpc_xprt *xprt, cb_info->serv = serv; cb_info->rqst = rqstp; - cb_info->task =kthread_run (callback_svc, cb_info->rqst, + cb_info->task =kthread_create (callback_svc, cb_info->rqst,"nfsv4.%u-svc" , minorversion);if (IS_ERR (cb_info->task)) { ret =PTR_ERR (cb_info->task);
@@ -245,6 +245,7 @@ static int nfs_callback_start_svc(int minorversion, struct rpc_xprt *xprt,return ret; } rqstp->rq_task = cb_info->task; +wake_up_process (cb_info->task);dprintk ("nfs_callback_up: service started\n" );return 0 ; }
Signature · 1 line
1.9.3
Re: [PATCH 2/2] nfs: do not start the callback thread until we set rqstp->rq_task
Quoted 21 lines · On Tue, 2 Sep 2014 13:58:58 -0400 Trond Myklebust…
This fixes an Oopsable race when starting up the callback server.
Signed-off-by Trond Myklebust <[email protected]>--- fs/nfs/callback.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)fs/nfs/callback.c +1
-1@@ -235,7 +235,7 @@ static int nfs_callback_start_svc(int minorversion, struct rpc_xprt *xprt, cb_info->serv = serv; cb_info->rqst = rqstp; - cb_info->task =kthread_run (callback_svc, cb_info->rqst, + cb_info->task =kthread_create (callback_svc, cb_info->rqst,"nfsv4.%u-svc" , minorversion);if (IS_ERR (cb_info->task)) { ret =PTR_ERR (cb_info->task);
fs/nfs/callback.c static int nfs_callback_start_svc(int minorversion, struct rpc_xprt *xprt, · line 251
Quoted 7 lines
fs/nfs/callback.c +1
-0@@ -245,6 +245,7 @@ static int nfs_callback_start_svc(int minorversion, struct rpc_xprt *xprt,return ret; } rqstp->rq_task = cb_info->task; +wake_up_process (cb_info->task);dprintk ("nfs_callback_up: service started\n" );return 0 ; }
Re: [PATCH 2/2] nfs: do not start the callback thread until we set rqstp->rq_task
In reply to Trond MyklebustQuoted 21 lines · Trond Myklebust
This fixes an Oopsable race when starting up the callback server.
Signed-off-by Trond Myklebust <[email protected]>--- fs/nfs/callback.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)fs/nfs/callback.c +1
-1@@ -235,7 +235,7 @@ static int nfs_callback_start_svc(int minorversion, struct rpc_xprt *xprt, cb_info->serv = serv; cb_info->rqst = rqstp; - cb_info->task =kthread_run (callback_svc, cb_info->rqst, + cb_info->task =kthread_create (callback_svc, cb_info->rqst,"nfsv4.%u-svc" , minorversion);if (IS_ERR (cb_info->task)) { ret =PTR_ERR (cb_info->task);
fs/nfs/callback.c static int nfs_callback_start_svc(int minorversion, struct rpc_xprt *xprt, · line 248
Quoted 4 lines
fs/nfs/callback.c +1
-0@@ -245,6 +245,7 @@ static int nfs_callback_start_svc(int minorversion, struct rpc_xprt *xprt,return ret; } rqstp->rq_task = cb_info->task; +wake_up_process (cb_info->task);
Wouldn't it be cleaner to do something like:
- cb_info->task = kthread_run(callback_svc, cb_info->rqst,
+ cb_info->task = rqstp->rq_run =
+ kthread_create(callback_svc, cb_info->rqst,
or am I missing something subtile that the changelog didn't mention?
Re: [PATCH 2/2] nfs: do not start the callback thread until we set rqstp->rq_task
Quoted 33 lines · Christoph Hellwig
Quoted 21 lines · Trond Myklebust
This fixes an Oopsable race when starting up the callback server.
Signed-off-by Trond Myklebust <[email protected]>--- fs/nfs/callback.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)fs/nfs/callback.c +1
-1@@ -235,7 +235,7 @@ static int nfs_callback_start_svc(int minorversion, struct rpc_xprt *xprt, cb_info->serv = serv; cb_info->rqst = rqstp; - cb_info->task =kthread_run (callback_svc, cb_info->rqst, + cb_info->task =kthread_create (callback_svc, cb_info->rqst,"nfsv4.%u-svc" , minorversion);if (IS_ERR (cb_info->task)) { ret =PTR_ERR (cb_info->task);fs/nfs/callback.c static int nfs_callback_start_svc(int minorversion, struct rpc_xprt *xprt, · line 248
Quoted 4 lines
fs/nfs/callback.c +1
-0@@ -245,6 +245,7 @@ static int nfs_callback_start_svc(int minorversion, struct rpc_xprt *xprt,return ret; } rqstp->rq_task = cb_info->task; +wake_up_process (cb_info->task);Wouldn't it be cleaner to do something like:
(quoted diff) +2
-1- cb_info->task = kthread_run(callback_svc, cb_info->rqst, + cb_info->task = rqstp->rq_run = + kthread_create(callback_svc, cb_info->rqst,
Quoted 1 line
or am I missing something subtile that the changelog didn't mention?
The above is fine if you call kthread_create(), but if you stick with kthread_run(), then there is still the same atomicity issue that the thread can be started before we've initialised cb_info->task and rqstp->rq_run.
Internal testing has shown that this can lead to an oops when starting lockd. I'm therefore assuming that the same thing can happen with the NFS client callback channel.
Signature · 5 lines
Trond Myklebust Linux NFS client maintainer, PrimaryData [email protected]
Re: [PATCH 2/2] nfs: do not start the callback thread until we set rqstp->rq_task
Quoted 36 lines · Trond Myklebust
Quoted 33 lines · Christoph Hellwig
Quoted 21 lines · Trond Myklebust
This fixes an Oopsable race when starting up the callback server.
Signed-off-by Trond Myklebust <[email protected]>--- fs/nfs/callback.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)fs/nfs/callback.c +1
-1@@ -235,7 +235,7 @@ static int nfs_callback_start_svc(int minorversion, struct rpc_xprt *xprt, cb_info->serv = serv; cb_info->rqst = rqstp; - cb_info->task =kthread_run (callback_svc, cb_info->rqst, + cb_info->task =kthread_create (callback_svc, cb_info->rqst,"nfsv4.%u-svc" , minorversion);if (IS_ERR (cb_info->task)) { ret =PTR_ERR (cb_info->task);fs/nfs/callback.c static int nfs_callback_start_svc(int minorversion, struct rpc_xprt *xprt, · line 248
Quoted 4 lines
fs/nfs/callback.c +1
-0@@ -245,6 +245,7 @@ static int nfs_callback_start_svc(int minorversion, struct rpc_xprt *xprt,return ret; } rqstp->rq_task = cb_info->task; +wake_up_process (cb_info->task);Wouldn't it be cleaner to do something like:
(quoted diff) +2
-1- cb_info->task = kthread_run(callback_svc, cb_info->rqst, + cb_info->task = rqstp->rq_run = + kthread_create(callback_svc, cb_info->rqst,Quoted 1 line
or am I missing something subtile that the changelog didn't mention?
Quoted 7 lines
The above is fine if you call
kthread_create(), but if you stick withkthread_run(), then there is still the same atomicity issue that the thread can be started before we've initialisedcb_info->taskandrqstp->rq_run.Internal testing has shown that this can lead to an oops when starting lockd.
The oops seen in practice were probably after applying 983c684466e0 "SUNRPC: get rid of the request wait queue"?
Though it was a bug before then too, of course.
--b.
Quoted 9 lines
I'm therefore assuming that the same thing can happen with the NFS client callback channel.
Signature · 5 lines
Trond Myklebust Linux NFS client maintainer, PrimaryData [email protected]
Re: [PATCH 2/2] nfs: do not start the callback thread until we set rqstp->rq_task
Quoted 42 lines · J. Bruce Fields
Quoted 41 lines · Trond Myklebust
Quoted 33 lines · Christoph Hellwig
Quoted 21 lines · Trond Myklebust
This fixes an Oopsable race when starting up the callback server.
Signed-off-by Trond Myklebust <[email protected]>--- fs/nfs/callback.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)fs/nfs/callback.c +1
-1@@ -235,7 +235,7 @@ static int nfs_callback_start_svc(int minorversion, struct rpc_xprt *xprt, cb_info->serv = serv; cb_info->rqst = rqstp; - cb_info->task =kthread_run (callback_svc, cb_info->rqst, + cb_info->task =kthread_create (callback_svc, cb_info->rqst,"nfsv4.%u-svc" , minorversion);if (IS_ERR (cb_info->task)) { ret =PTR_ERR (cb_info->task);fs/nfs/callback.c static int nfs_callback_start_svc(int minorversion, struct rpc_xprt *xprt, · line 248
Quoted 4 lines
fs/nfs/callback.c +1
-0@@ -245,6 +245,7 @@ static int nfs_callback_start_svc(int minorversion, struct rpc_xprt *xprt,return ret; } rqstp->rq_task = cb_info->task; +wake_up_process (cb_info->task);Wouldn't it be cleaner to do something like:
(quoted diff) +2
-1- cb_info->task = kthread_run(callback_svc, cb_info->rqst, + cb_info->task = rqstp->rq_run = + kthread_create(callback_svc, cb_info->rqst,Quoted 1 line
or am I missing something subtile that the changelog didn't mention?
The above is fine if you call
kthread_create(), but if you stick withkthread_run(), then there is still the same atomicity issue that the thread can be started before we've initialisedcb_info->taskandrqstp->rq_run.
Quoted 8 lines
Quoted 2 lines
Internal testing has shown that this can lead to an oops when starting lockd.
The oops seen in practice were probably after applying
983c684466e0"SUNRPC: get rid of the request wait queue"?Though it was a bug before then too, of course.
Right. This is not needed until you merge the new sunrpc server scalability stuff (which I'm assuming will be 3.18).
Signature · 5 lines
Trond Myklebust Linux NFS client maintainer, PrimaryData [email protected]
Re: [PATCH 2/2] nfs: do not start the callback thread until we set rqstp->rq_task
Quoted 46 lines · Trond Myklebust
Quoted 45 lines · J. Bruce Fields
Quoted 43 lines · Trond Myklebust
Quoted 33 lines · Christoph Hellwig
Quoted 21 lines · Trond Myklebust
This fixes an Oopsable race when starting up the callback server.
Signed-off-by Trond Myklebust <[email protected]>--- fs/nfs/callback.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)fs/nfs/callback.c +1
-1@@ -235,7 +235,7 @@ static int nfs_callback_start_svc(int minorversion, struct rpc_xprt *xprt, cb_info->serv = serv; cb_info->rqst = rqstp; - cb_info->task =kthread_run (callback_svc, cb_info->rqst, + cb_info->task =kthread_create (callback_svc, cb_info->rqst,"nfsv4.%u-svc" , minorversion);if (IS_ERR (cb_info->task)) { ret =PTR_ERR (cb_info->task);fs/nfs/callback.c static int nfs_callback_start_svc(int minorversion, struct rpc_xprt *xprt, · line 248
Quoted 4 lines
fs/nfs/callback.c +1
-0@@ -245,6 +245,7 @@ static int nfs_callback_start_svc(int minorversion, struct rpc_xprt *xprt,return ret; } rqstp->rq_task = cb_info->task; +wake_up_process (cb_info->task);Wouldn't it be cleaner to do something like:
(quoted diff) +2
-1- cb_info->task = kthread_run(callback_svc, cb_info->rqst, + cb_info->task = rqstp->rq_run = + kthread_create(callback_svc, cb_info->rqst,Quoted 1 line
or am I missing something subtile that the changelog didn't mention?
The above is fine if you call
kthread_create(), but if you stick withkthread_run(), then there is still the same atomicity issue that the thread can be started before we've initialisedcb_info->taskandrqstp->rq_run.Internal testing has shown that this can lead to an oops when starting lockd.
Quoted 8 lines
Quoted 5 lines
The oops seen in practice were probably after applying
983c684466e0"SUNRPC: get rid of the request wait queue"?Though it was a bug before then too, of course.
Right. This is not needed until you merge the new sunrpc server scalability stuff (which I'm assuming will be 3.18).
Got it. Well there's also an rq_task use in net/sunrpc/svc.c:choose_victim(), but I'm guessing it would take a pretty strange case to hit, so I'll plan to take these for 3.18 without a stable cc.
--b.
Quoted 21 lines · On Tue, 2 Sep 2014 13:58:57 -0400 Trond Myklebust…
This fixes an Oopsable race when starting lockd.
Signed-off-by Trond Myklebust <[email protected]>--- fs/lockd/svc.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)fs/lockd/svc.c +1
-1@@ -306,7 +306,7 @@ static int lockd_start_svc(struct svc_serv *serv)svc_sock_update_bufs (serv); serv->sv_maxconn = nlm_max_connections; - nlmsvc_task =kthread_run (lockd, nlmsvc_rqst,"%s" , serv->sv_name); + nlmsvc_task =kthread_create (lockd, nlmsvc_rqst,"%s" , serv->sv_name);if (IS_ERR (nlmsvc_task)) { error =PTR_ERR (nlmsvc_task); printk(KERN_WARNING
fs/lockd/svc.c static int lockd_start_svc(struct svc_serv *serv) · line 320
Quoted 7 lines
fs/lockd/svc.c +1
-0@@ -314,6 +314,7 @@ static int lockd_start_svc(struct svc_serv *serv) goto out_task; } nlmsvc_rqst->rq_task = nlmsvc_task; +wake_up_process (nlmsvc_task);dprintk ("lockd_up: service started\n" );return 0 ;