Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Bryan Schumaker and committed by
Trond Myklebust
63185942 b4687da7

+14 -14
+10 -5
fs/lockd/clntlock.c
··· 42 42 }; 43 43 44 44 static LIST_HEAD(nlm_blocked); 45 + static DEFINE_SPINLOCK(nlm_blocked_lock); 45 46 46 47 /** 47 48 * nlmclnt_init - Set up per-NFS mount point lockd data structures ··· 98 97 block->b_lock = fl; 99 98 init_waitqueue_head(&block->b_wait); 100 99 block->b_status = nlm_lck_blocked; 100 + 101 + spin_lock(&nlm_blocked_lock); 101 102 list_add(&block->b_list, &nlm_blocked); 103 + spin_unlock(&nlm_blocked_lock); 102 104 } 103 105 return block; 104 106 } ··· 110 106 { 111 107 if (block == NULL) 112 108 return; 109 + spin_lock(&nlm_blocked_lock); 113 110 list_del(&block->b_list); 111 + spin_unlock(&nlm_blocked_lock); 114 112 kfree(block); 115 113 } 116 114 ··· 160 154 * Look up blocked request based on arguments. 161 155 * Warning: must not use cookie to match it! 162 156 */ 157 + spin_lock(&nlm_blocked_lock); 163 158 list_for_each_entry(block, &nlm_blocked, b_list) { 164 159 struct file_lock *fl_blocked = block->b_lock; 165 160 ··· 185 178 wake_up(&block->b_wait); 186 179 res = nlm_granted; 187 180 } 181 + spin_unlock(&nlm_blocked_lock); 188 182 return res; 189 183 } 190 184 ··· 224 216 allow_signal(SIGKILL); 225 217 226 218 down_write(&host->h_rwsem); 227 - 228 - /* This one ensures that our parent doesn't terminate while the 229 - * reclaim is in progress */ 230 - lock_kernel(); 231 219 lockd_up(); /* note: this cannot fail as lockd is already running */ 232 220 233 221 dprintk("lockd: reclaiming locks for host %s\n", host->h_name); ··· 264 260 dprintk("NLM: done reclaiming locks for host %s\n", host->h_name); 265 261 266 262 /* Now, wake up all processes that sleep on a blocked lock */ 263 + spin_lock(&nlm_blocked_lock); 267 264 list_for_each_entry(block, &nlm_blocked, b_list) { 268 265 if (block->b_host == host) { 269 266 block->b_status = nlm_lck_denied_grace_period; 270 267 wake_up(&block->b_wait); 271 268 } 272 269 } 270 + spin_unlock(&nlm_blocked_lock); 273 271 274 272 /* Release host handle after use */ 275 273 nlm_release_host(host); 276 274 lockd_down(); 277 - unlock_kernel(); 278 275 return 0; 279 276 }
+4 -9
fs/lockd/clntproc.c
··· 166 166 /* Set up the argument struct */ 167 167 nlmclnt_setlockargs(call, fl); 168 168 169 - lock_kernel(); 170 169 if (IS_SETLK(cmd) || IS_SETLKW(cmd)) { 171 170 if (fl->fl_type != F_UNLCK) { 172 171 call->a_args.block = IS_SETLKW(cmd) ? 1 : 0; ··· 176 177 status = nlmclnt_test(call, fl); 177 178 else 178 179 status = -EINVAL; 179 - 180 180 fl->fl_ops->fl_release_private(fl); 181 181 fl->fl_ops = NULL; 182 - unlock_kernel(); 183 182 184 183 dprintk("lockd: clnt proc returns %d\n", status); 185 184 return status; ··· 223 226 224 227 static void nlmclnt_rpc_release(void *data) 225 228 { 226 - lock_kernel(); 227 229 nlm_release_call(data); 228 - unlock_kernel(); 229 230 } 230 231 231 232 static int nlm_wait_on_grace(wait_queue_head_t *queue) ··· 443 448 444 449 static void nlmclnt_locks_copy_lock(struct file_lock *new, struct file_lock *fl) 445 450 { 451 + spin_lock(&fl->fl_u.nfs_fl.owner->host->h_lock); 446 452 new->fl_u.nfs_fl.state = fl->fl_u.nfs_fl.state; 447 453 new->fl_u.nfs_fl.owner = nlm_get_lockowner(fl->fl_u.nfs_fl.owner); 448 454 list_add_tail(&new->fl_u.nfs_fl.list, &fl->fl_u.nfs_fl.owner->host->h_granted); 455 + spin_unlock(&fl->fl_u.nfs_fl.owner->host->h_lock); 449 456 } 450 457 451 458 static void nlmclnt_locks_release_private(struct file_lock *fl) 452 459 { 460 + spin_lock(&fl->fl_u.nfs_fl.owner->host->h_lock); 453 461 list_del(&fl->fl_u.nfs_fl.list); 462 + spin_unlock(&fl->fl_u.nfs_fl.owner->host->h_lock); 454 463 nlm_put_lockowner(fl->fl_u.nfs_fl.owner); 455 464 } 456 465 ··· 720 721 die: 721 722 return; 722 723 retry_rebind: 723 - lock_kernel(); 724 724 nlm_rebind_host(req->a_host); 725 - unlock_kernel(); 726 725 retry_unlock: 727 726 rpc_restart_call(task); 728 727 } ··· 798 801 /* Don't ever retry more than 3 times */ 799 802 if (req->a_retries++ >= NLMCLNT_MAX_RETRIES) 800 803 goto die; 801 - lock_kernel(); 802 804 nlm_rebind_host(req->a_host); 803 - unlock_kernel(); 804 805 rpc_restart_call(task); 805 806 rpc_delay(task, 30 * HZ); 806 807 }