All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] NFS: hold BKL when clearing nfs_callback_info.task
@ 2008-04-07 13:38 Jeff Layton
  2008-04-07 13:38 ` [PATCH] NLM: hold BKL when clearing global lockd task and serv vars Jeff Layton
  0 siblings, 1 reply; 14+ messages in thread
From: Jeff Layton @ 2008-04-07 13:38 UTC (permalink / raw)
  To: trond.myklebust, bfields; +Cc: nfsv4, linux-nfs

The global task pointers for the nfs4 callback thread is normally
protected by the nfs_callback_mutex. The exception is when the thread
exits abnormally. When this occurs, this variable is cleared without any
locking.

Make sure that this variable is cleared while still holding the BKL.

Also, there's no reason that nfs_callback_up and nfs_callback_down need
to hold the BKL while trying to lock nfs_callback_mutex. Reverse the
lock order as a micro-optimization.

Signed-off-by: Jeff Layton <jlayton@redhat.com>
---
 fs/nfs/callback.c |   10 +++++-----
 1 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/fs/nfs/callback.c b/fs/nfs/callback.c
index 2e5de77..2646724 100644
--- a/fs/nfs/callback.c
+++ b/fs/nfs/callback.c
@@ -84,8 +84,8 @@ nfs_callback_svc(void *vrqstp)
 		}
 		svc_process(rqstp);
 	}
-	unlock_kernel();
 	nfs_callback_info.task = NULL;
+	unlock_kernel();
 	svc_exit_thread(rqstp);
 	return 0;
 }
@@ -99,8 +99,8 @@ int nfs_callback_up(void)
 	struct svc_rqst *rqstp;
 	int ret = 0;
 
-	lock_kernel();
 	mutex_lock(&nfs_callback_mutex);
+	lock_kernel();
 	if (nfs_callback_info.users++ || nfs_callback_info.task != NULL)
 		goto out;
 	serv = svc_create(&nfs4_callback_program, NFS4_CALLBACK_BUFSIZE, NULL);
@@ -142,8 +142,8 @@ out:
 	 */
 	if (serv)
 		svc_destroy(serv);
-	mutex_unlock(&nfs_callback_mutex);
 	unlock_kernel();
+	mutex_unlock(&nfs_callback_mutex);
 	return ret;
 out_err:
 	dprintk("Couldn't create callback socket or server thread; err = %d\n",
@@ -157,13 +157,13 @@ out_err:
  */
 void nfs_callback_down(void)
 {
-	lock_kernel();
 	mutex_lock(&nfs_callback_mutex);
+	lock_kernel();
 	nfs_callback_info.users--;
 	if (nfs_callback_info.users == 0 && nfs_callback_info.task != NULL)
 		kthread_stop(nfs_callback_info.task);
-	mutex_unlock(&nfs_callback_mutex);
 	unlock_kernel();
+	mutex_unlock(&nfs_callback_mutex);
 }
 
 static int nfs_callback_authenticate(struct svc_rqst *rqstp)
-- 
1.5.4.1

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

end of thread, other threads:[~2008-04-08 20:20 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-04-07 13:38 [PATCH] NFS: hold BKL when clearing nfs_callback_info.task Jeff Layton
2008-04-07 13:38 ` [PATCH] NLM: hold BKL when clearing global lockd task and serv vars Jeff Layton
2008-04-07 16:45   ` Christoph Hellwig
2008-04-07 17:40     ` Jeff Layton
2008-04-07 17:56     ` J. Bruce Fields
2008-04-07 19:08       ` Tom Tucker
2008-04-07 20:22       ` Jeff Layton
2008-04-07 20:50         ` J. Bruce Fields
2008-04-08 13:21           ` Jeff Layton
2008-04-08 16:28             ` J. Bruce Fields
2008-04-08 17:02               ` Jeff Layton
2008-04-08 19:16               ` Jeff Layton
2008-04-08 20:08               ` Chuck Lever
2008-04-08 20:20                 ` Jeff Layton

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.