lockd: Remove BKL from the client

This patch removes all calls to lock_kernel() from the client.  This patch
should be applied after the "fs/lock.c prepare for BKL removal" patch submitted
by Arnd Bergmann on September 18.

Signed-off-by: Bryan Schumaker <bjschuma@netapp.com>
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
This commit is contained in:
Bryan Schumaker 2010-09-22 09:50:35 -04:00 committed by Trond Myklebust
parent b4687da7fc
commit 63185942c5
2 changed files with 14 additions and 14 deletions

View file

@ -42,6 +42,7 @@ struct nlm_wait {
}; };
static LIST_HEAD(nlm_blocked); static LIST_HEAD(nlm_blocked);
static DEFINE_SPINLOCK(nlm_blocked_lock);
/** /**
* nlmclnt_init - Set up per-NFS mount point lockd data structures * nlmclnt_init - Set up per-NFS mount point lockd data structures
@ -97,7 +98,10 @@ struct nlm_wait *nlmclnt_prepare_block(struct nlm_host *host, struct file_lock *
block->b_lock = fl; block->b_lock = fl;
init_waitqueue_head(&block->b_wait); init_waitqueue_head(&block->b_wait);
block->b_status = nlm_lck_blocked; block->b_status = nlm_lck_blocked;
spin_lock(&nlm_blocked_lock);
list_add(&block->b_list, &nlm_blocked); list_add(&block->b_list, &nlm_blocked);
spin_unlock(&nlm_blocked_lock);
} }
return block; return block;
} }
@ -106,7 +110,9 @@ void nlmclnt_finish_block(struct nlm_wait *block)
{ {
if (block == NULL) if (block == NULL)
return; return;
spin_lock(&nlm_blocked_lock);
list_del(&block->b_list); list_del(&block->b_list);
spin_unlock(&nlm_blocked_lock);
kfree(block); kfree(block);
} }
@ -154,6 +160,7 @@ __be32 nlmclnt_grant(const struct sockaddr *addr, const struct nlm_lock *lock)
* Look up blocked request based on arguments. * Look up blocked request based on arguments.
* Warning: must not use cookie to match it! * Warning: must not use cookie to match it!
*/ */
spin_lock(&nlm_blocked_lock);
list_for_each_entry(block, &nlm_blocked, b_list) { list_for_each_entry(block, &nlm_blocked, b_list) {
struct file_lock *fl_blocked = block->b_lock; struct file_lock *fl_blocked = block->b_lock;
@ -178,6 +185,7 @@ __be32 nlmclnt_grant(const struct sockaddr *addr, const struct nlm_lock *lock)
wake_up(&block->b_wait); wake_up(&block->b_wait);
res = nlm_granted; res = nlm_granted;
} }
spin_unlock(&nlm_blocked_lock);
return res; return res;
} }
@ -216,10 +224,6 @@ reclaimer(void *ptr)
allow_signal(SIGKILL); allow_signal(SIGKILL);
down_write(&host->h_rwsem); down_write(&host->h_rwsem);
/* This one ensures that our parent doesn't terminate while the
* reclaim is in progress */
lock_kernel();
lockd_up(); /* note: this cannot fail as lockd is already running */ lockd_up(); /* note: this cannot fail as lockd is already running */
dprintk("lockd: reclaiming locks for host %s\n", host->h_name); dprintk("lockd: reclaiming locks for host %s\n", host->h_name);
@ -260,16 +264,17 @@ restart:
dprintk("NLM: done reclaiming locks for host %s\n", host->h_name); dprintk("NLM: done reclaiming locks for host %s\n", host->h_name);
/* Now, wake up all processes that sleep on a blocked lock */ /* Now, wake up all processes that sleep on a blocked lock */
spin_lock(&nlm_blocked_lock);
list_for_each_entry(block, &nlm_blocked, b_list) { list_for_each_entry(block, &nlm_blocked, b_list) {
if (block->b_host == host) { if (block->b_host == host) {
block->b_status = nlm_lck_denied_grace_period; block->b_status = nlm_lck_denied_grace_period;
wake_up(&block->b_wait); wake_up(&block->b_wait);
} }
} }
spin_unlock(&nlm_blocked_lock);
/* Release host handle after use */ /* Release host handle after use */
nlm_release_host(host); nlm_release_host(host);
lockd_down(); lockd_down();
unlock_kernel();
return 0; return 0;
} }

View file

@ -166,7 +166,6 @@ int nlmclnt_proc(struct nlm_host *host, int cmd, struct file_lock *fl)
/* Set up the argument struct */ /* Set up the argument struct */
nlmclnt_setlockargs(call, fl); nlmclnt_setlockargs(call, fl);
lock_kernel();
if (IS_SETLK(cmd) || IS_SETLKW(cmd)) { if (IS_SETLK(cmd) || IS_SETLKW(cmd)) {
if (fl->fl_type != F_UNLCK) { if (fl->fl_type != F_UNLCK) {
call->a_args.block = IS_SETLKW(cmd) ? 1 : 0; call->a_args.block = IS_SETLKW(cmd) ? 1 : 0;
@ -177,10 +176,8 @@ int nlmclnt_proc(struct nlm_host *host, int cmd, struct file_lock *fl)
status = nlmclnt_test(call, fl); status = nlmclnt_test(call, fl);
else else
status = -EINVAL; status = -EINVAL;
fl->fl_ops->fl_release_private(fl); fl->fl_ops->fl_release_private(fl);
fl->fl_ops = NULL; fl->fl_ops = NULL;
unlock_kernel();
dprintk("lockd: clnt proc returns %d\n", status); dprintk("lockd: clnt proc returns %d\n", status);
return status; return status;
@ -226,9 +223,7 @@ void nlm_release_call(struct nlm_rqst *call)
static void nlmclnt_rpc_release(void *data) static void nlmclnt_rpc_release(void *data)
{ {
lock_kernel();
nlm_release_call(data); nlm_release_call(data);
unlock_kernel();
} }
static int nlm_wait_on_grace(wait_queue_head_t *queue) static int nlm_wait_on_grace(wait_queue_head_t *queue)
@ -448,14 +443,18 @@ out:
static void nlmclnt_locks_copy_lock(struct file_lock *new, struct file_lock *fl) static void nlmclnt_locks_copy_lock(struct file_lock *new, struct file_lock *fl)
{ {
spin_lock(&fl->fl_u.nfs_fl.owner->host->h_lock);
new->fl_u.nfs_fl.state = fl->fl_u.nfs_fl.state; new->fl_u.nfs_fl.state = fl->fl_u.nfs_fl.state;
new->fl_u.nfs_fl.owner = nlm_get_lockowner(fl->fl_u.nfs_fl.owner); new->fl_u.nfs_fl.owner = nlm_get_lockowner(fl->fl_u.nfs_fl.owner);
list_add_tail(&new->fl_u.nfs_fl.list, &fl->fl_u.nfs_fl.owner->host->h_granted); list_add_tail(&new->fl_u.nfs_fl.list, &fl->fl_u.nfs_fl.owner->host->h_granted);
spin_unlock(&fl->fl_u.nfs_fl.owner->host->h_lock);
} }
static void nlmclnt_locks_release_private(struct file_lock *fl) static void nlmclnt_locks_release_private(struct file_lock *fl)
{ {
spin_lock(&fl->fl_u.nfs_fl.owner->host->h_lock);
list_del(&fl->fl_u.nfs_fl.list); list_del(&fl->fl_u.nfs_fl.list);
spin_unlock(&fl->fl_u.nfs_fl.owner->host->h_lock);
nlm_put_lockowner(fl->fl_u.nfs_fl.owner); nlm_put_lockowner(fl->fl_u.nfs_fl.owner);
} }
@ -721,9 +720,7 @@ static void nlmclnt_unlock_callback(struct rpc_task *task, void *data)
die: die:
return; return;
retry_rebind: retry_rebind:
lock_kernel();
nlm_rebind_host(req->a_host); nlm_rebind_host(req->a_host);
unlock_kernel();
retry_unlock: retry_unlock:
rpc_restart_call(task); rpc_restart_call(task);
} }
@ -801,9 +798,7 @@ retry_cancel:
/* Don't ever retry more than 3 times */ /* Don't ever retry more than 3 times */
if (req->a_retries++ >= NLMCLNT_MAX_RETRIES) if (req->a_retries++ >= NLMCLNT_MAX_RETRIES)
goto die; goto die;
lock_kernel();
nlm_rebind_host(req->a_host); nlm_rebind_host(req->a_host);
unlock_kernel();
rpc_restart_call(task); rpc_restart_call(task);
rpc_delay(task, 30 * HZ); rpc_delay(task, 30 * HZ);
} }