aboutsummaryrefslogtreecommitdiffstats
path: root/fs/lockd/svclock.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/lockd/svclock.c')
-rw-r--r--fs/lockd/svclock.c40
1 files changed, 16 insertions, 24 deletions
diff --git a/fs/lockd/svclock.c b/fs/lockd/svclock.c
index 81aca859bfde..821b9acdfb66 100644
--- a/fs/lockd/svclock.c
+++ b/fs/lockd/svclock.c
@@ -129,9 +129,9 @@ nlmsvc_lookup_block(struct nlm_file *file, struct nlm_lock *lock)
129 129
130static inline int nlm_cookie_match(struct nlm_cookie *a, struct nlm_cookie *b) 130static inline int nlm_cookie_match(struct nlm_cookie *a, struct nlm_cookie *b)
131{ 131{
132 if(a->len != b->len) 132 if (a->len != b->len)
133 return 0; 133 return 0;
134 if(memcmp(a->data,b->data,a->len)) 134 if (memcmp(a->data, b->data, a->len))
135 return 0; 135 return 0;
136 return 1; 136 return 1;
137} 137}
@@ -180,6 +180,7 @@ nlmsvc_create_block(struct svc_rqst *rqstp, struct nlm_host *host,
180 struct nlm_block *block; 180 struct nlm_block *block;
181 struct nlm_rqst *call = NULL; 181 struct nlm_rqst *call = NULL;
182 182
183 nlm_get_host(host);
183 call = nlm_alloc_call(host); 184 call = nlm_alloc_call(host);
184 if (call == NULL) 185 if (call == NULL)
185 return NULL; 186 return NULL;
@@ -358,10 +359,10 @@ nlmsvc_defer_lock_rqst(struct svc_rqst *rqstp, struct nlm_block *block)
358 */ 359 */
359__be32 360__be32
360nlmsvc_lock(struct svc_rqst *rqstp, struct nlm_file *file, 361nlmsvc_lock(struct svc_rqst *rqstp, struct nlm_file *file,
361 struct nlm_lock *lock, int wait, struct nlm_cookie *cookie) 362 struct nlm_host *host, struct nlm_lock *lock, int wait,
363 struct nlm_cookie *cookie)
362{ 364{
363 struct nlm_block *block = NULL; 365 struct nlm_block *block = NULL;
364 struct nlm_host *host;
365 int error; 366 int error;
366 __be32 ret; 367 __be32 ret;
367 368
@@ -373,11 +374,6 @@ nlmsvc_lock(struct svc_rqst *rqstp, struct nlm_file *file,
373 (long long)lock->fl.fl_end, 374 (long long)lock->fl.fl_end,
374 wait); 375 wait);
375 376
376 /* Create host handle for callback */
377 host = nlmsvc_lookup_host(rqstp, lock->caller, lock->len);
378 if (host == NULL)
379 return nlm_lck_denied_nolocks;
380
381 /* Lock file against concurrent access */ 377 /* Lock file against concurrent access */
382 mutex_lock(&file->f_mutex); 378 mutex_lock(&file->f_mutex);
383 /* Get existing block (in case client is busy-waiting) 379 /* Get existing block (in case client is busy-waiting)
@@ -385,8 +381,7 @@ nlmsvc_lock(struct svc_rqst *rqstp, struct nlm_file *file,
385 */ 381 */
386 block = nlmsvc_lookup_block(file, lock); 382 block = nlmsvc_lookup_block(file, lock);
387 if (block == NULL) { 383 if (block == NULL) {
388 block = nlmsvc_create_block(rqstp, nlm_get_host(host), file, 384 block = nlmsvc_create_block(rqstp, host, file, lock, cookie);
389 lock, cookie);
390 ret = nlm_lck_denied_nolocks; 385 ret = nlm_lck_denied_nolocks;
391 if (block == NULL) 386 if (block == NULL)
392 goto out; 387 goto out;
@@ -417,7 +412,7 @@ nlmsvc_lock(struct svc_rqst *rqstp, struct nlm_file *file,
417 lock->fl.fl_flags &= ~FL_SLEEP; 412 lock->fl.fl_flags &= ~FL_SLEEP;
418 413
419 dprintk("lockd: vfs_lock_file returned %d\n", error); 414 dprintk("lockd: vfs_lock_file returned %d\n", error);
420 switch(error) { 415 switch (error) {
421 case 0: 416 case 0:
422 ret = nlm_granted; 417 ret = nlm_granted;
423 goto out; 418 goto out;
@@ -450,7 +445,6 @@ nlmsvc_lock(struct svc_rqst *rqstp, struct nlm_file *file,
450out: 445out:
451 mutex_unlock(&file->f_mutex); 446 mutex_unlock(&file->f_mutex);
452 nlmsvc_release_block(block); 447 nlmsvc_release_block(block);
453 nlm_release_host(host);
454 dprintk("lockd: nlmsvc_lock returned %u\n", ret); 448 dprintk("lockd: nlmsvc_lock returned %u\n", ret);
455 return ret; 449 return ret;
456} 450}
@@ -460,8 +454,8 @@ out:
460 */ 454 */
461__be32 455__be32
462nlmsvc_testlock(struct svc_rqst *rqstp, struct nlm_file *file, 456nlmsvc_testlock(struct svc_rqst *rqstp, struct nlm_file *file,
463 struct nlm_lock *lock, struct nlm_lock *conflock, 457 struct nlm_host *host, struct nlm_lock *lock,
464 struct nlm_cookie *cookie) 458 struct nlm_lock *conflock, struct nlm_cookie *cookie)
465{ 459{
466 struct nlm_block *block = NULL; 460 struct nlm_block *block = NULL;
467 int error; 461 int error;
@@ -479,16 +473,9 @@ nlmsvc_testlock(struct svc_rqst *rqstp, struct nlm_file *file,
479 473
480 if (block == NULL) { 474 if (block == NULL) {
481 struct file_lock *conf = kzalloc(sizeof(*conf), GFP_KERNEL); 475 struct file_lock *conf = kzalloc(sizeof(*conf), GFP_KERNEL);
482 struct nlm_host *host;
483 476
484 if (conf == NULL) 477 if (conf == NULL)
485 return nlm_granted; 478 return nlm_granted;
486 /* Create host handle for callback */
487 host = nlmsvc_lookup_host(rqstp, lock->caller, lock->len);
488 if (host == NULL) {
489 kfree(conf);
490 return nlm_lck_denied_nolocks;
491 }
492 block = nlmsvc_create_block(rqstp, host, file, lock, cookie); 479 block = nlmsvc_create_block(rqstp, host, file, lock, cookie);
493 if (block == NULL) { 480 if (block == NULL) {
494 kfree(conf); 481 kfree(conf);
@@ -795,6 +782,7 @@ static void nlmsvc_grant_callback(struct rpc_task *task, void *data)
795 782
796 dprintk("lockd: GRANT_MSG RPC callback\n"); 783 dprintk("lockd: GRANT_MSG RPC callback\n");
797 784
785 lock_kernel();
798 /* if the block is not on a list at this point then it has 786 /* if the block is not on a list at this point then it has
799 * been invalidated. Don't try to requeue it. 787 * been invalidated. Don't try to requeue it.
800 * 788 *
@@ -804,7 +792,7 @@ static void nlmsvc_grant_callback(struct rpc_task *task, void *data)
804 * for nlm_blocked? 792 * for nlm_blocked?
805 */ 793 */
806 if (list_empty(&block->b_list)) 794 if (list_empty(&block->b_list))
807 return; 795 goto out;
808 796
809 /* Technically, we should down the file semaphore here. Since we 797 /* Technically, we should down the file semaphore here. Since we
810 * move the block towards the head of the queue only, no harm 798 * move the block towards the head of the queue only, no harm
@@ -818,13 +806,17 @@ static void nlmsvc_grant_callback(struct rpc_task *task, void *data)
818 } 806 }
819 nlmsvc_insert_block(block, timeout); 807 nlmsvc_insert_block(block, timeout);
820 svc_wake_up(block->b_daemon); 808 svc_wake_up(block->b_daemon);
809out:
810 unlock_kernel();
821} 811}
822 812
823static void nlmsvc_grant_release(void *data) 813static void nlmsvc_grant_release(void *data)
824{ 814{
825 struct nlm_rqst *call = data; 815 struct nlm_rqst *call = data;
826 816
817 lock_kernel();
827 nlmsvc_release_block(call->a_block); 818 nlmsvc_release_block(call->a_block);
819 unlock_kernel();
828} 820}
829 821
830static const struct rpc_call_ops nlmsvc_grant_ops = { 822static const struct rpc_call_ops nlmsvc_grant_ops = {
@@ -892,7 +884,7 @@ nlmsvc_retry_blocked(void)
892 884
893 if (block->b_when == NLM_NEVER) 885 if (block->b_when == NLM_NEVER)
894 break; 886 break;
895 if (time_after(block->b_when,jiffies)) { 887 if (time_after(block->b_when, jiffies)) {
896 timeout = block->b_when - jiffies; 888 timeout = block->b_when - jiffies;
897 break; 889 break;
898 } 890 }