aboutsummaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
authorJeff Layton <jlayton@primarydata.com>2014-08-22 10:18:44 -0400
committerJeff Layton <jlayton@primarydata.com>2014-09-09 16:01:09 -0400
commit09802fd2a8caea2a2147fca8d7975697c5de573d (patch)
tree99f87c52a0921d3eaa9796a349784bf676bc3b3c /fs
parentaef9583b234a4ecdbcaf2c3024f29d4244b18e83 (diff)
lockd: rip out deferred lock handling from testlock codepath
As Kinglong points out, the nlm_block->b_fl field is no longer used at all. Also, vfs_test_lock in the generic locking code will only return FILE_LOCK_DEFERRED if FL_SLEEP is set, and it isn't here. The only other place that returns that value is the DLM lock code, but it only does that in dlm_posix_lock, never in dlm_posix_get. Remove all of the deferred locking code from the testlock codepath since it doesn't appear to ever be used anyway. I do have a small concern that this might cause a behavior change in the case where you have a block already sitting on the list when the testlock request comes in, but that looks like it doesn't really work properly anyway. I think it's best to just pass that down to vfs_test_lock and let the filesystem report that instead of trying to infer what's going on with the lock by looking at an existing block. Cc: cluster-devel@redhat.com Signed-off-by: Jeff Layton <jlayton@primarydata.com> Reviewed-by: Kinglong Mee <kinglongmee@gmail.com>
Diffstat (limited to 'fs')
-rw-r--r--fs/lockd/svclock.c55
1 files changed, 6 insertions, 49 deletions
diff --git a/fs/lockd/svclock.c b/fs/lockd/svclock.c
index acfa94d5b489..13db95f54176 100644
--- a/fs/lockd/svclock.c
+++ b/fs/lockd/svclock.c
@@ -245,7 +245,6 @@ nlmsvc_create_block(struct svc_rqst *rqstp, struct nlm_host *host,
245 block->b_daemon = rqstp->rq_server; 245 block->b_daemon = rqstp->rq_server;
246 block->b_host = host; 246 block->b_host = host;
247 block->b_file = file; 247 block->b_file = file;
248 block->b_fl = NULL;
249 file->f_count++; 248 file->f_count++;
250 249
251 /* Add to file's list of blocks */ 250 /* Add to file's list of blocks */
@@ -295,7 +294,6 @@ static void nlmsvc_free_block(struct kref *kref)
295 nlmsvc_freegrantargs(block->b_call); 294 nlmsvc_freegrantargs(block->b_call);
296 nlmsvc_release_call(block->b_call); 295 nlmsvc_release_call(block->b_call);
297 nlm_release_file(block->b_file); 296 nlm_release_file(block->b_file);
298 kfree(block->b_fl);
299 kfree(block); 297 kfree(block);
300} 298}
301 299
@@ -508,7 +506,6 @@ nlmsvc_testlock(struct svc_rqst *rqstp, struct nlm_file *file,
508 struct nlm_host *host, struct nlm_lock *lock, 506 struct nlm_host *host, struct nlm_lock *lock,
509 struct nlm_lock *conflock, struct nlm_cookie *cookie) 507 struct nlm_lock *conflock, struct nlm_cookie *cookie)
510{ 508{
511 struct nlm_block *block = NULL;
512 int error; 509 int error;
513 __be32 ret; 510 __be32 ret;
514 511
@@ -519,63 +516,26 @@ nlmsvc_testlock(struct svc_rqst *rqstp, struct nlm_file *file,
519 (long long)lock->fl.fl_start, 516 (long long)lock->fl.fl_start,
520 (long long)lock->fl.fl_end); 517 (long long)lock->fl.fl_end);
521 518
522 /* Get existing block (in case client is busy-waiting) */
523 block = nlmsvc_lookup_block(file, lock);
524
525 if (block == NULL) {
526 struct file_lock *conf = kzalloc(sizeof(*conf), GFP_KERNEL);
527
528 if (conf == NULL)
529 return nlm_granted;
530 block = nlmsvc_create_block(rqstp, host, file, lock, cookie);
531 if (block == NULL) {
532 kfree(conf);
533 return nlm_granted;
534 }
535 block->b_fl = conf;
536 }
537 if (block->b_flags & B_QUEUED) {
538 dprintk("lockd: nlmsvc_testlock deferred block %p flags %d fl %p\n",
539 block, block->b_flags, block->b_fl);
540 if (block->b_flags & B_TIMED_OUT) {
541 nlmsvc_unlink_block(block);
542 ret = nlm_lck_denied;
543 goto out;
544 }
545 if (block->b_flags & B_GOT_CALLBACK) {
546 nlmsvc_unlink_block(block);
547 if (block->b_fl != NULL
548 && block->b_fl->fl_type != F_UNLCK) {
549 lock->fl = *block->b_fl;
550 goto conf_lock;
551 } else {
552 ret = nlm_granted;
553 goto out;
554 }
555 }
556 ret = nlm_drop_reply;
557 goto out;
558 }
559
560 if (locks_in_grace(SVC_NET(rqstp))) { 519 if (locks_in_grace(SVC_NET(rqstp))) {
561 ret = nlm_lck_denied_grace_period; 520 ret = nlm_lck_denied_grace_period;
562 goto out; 521 goto out;
563 } 522 }
523
564 error = vfs_test_lock(file->f_file, &lock->fl); 524 error = vfs_test_lock(file->f_file, &lock->fl);
565 if (error == FILE_LOCK_DEFERRED) {
566 ret = nlmsvc_defer_lock_rqst(rqstp, block);
567 goto out;
568 }
569 if (error) { 525 if (error) {
526 /* We can't currently deal with deferred test requests */
527 if (error == FILE_LOCK_DEFERRED)
528 WARN_ON_ONCE(1);
529
570 ret = nlm_lck_denied_nolocks; 530 ret = nlm_lck_denied_nolocks;
571 goto out; 531 goto out;
572 } 532 }
533
573 if (lock->fl.fl_type == F_UNLCK) { 534 if (lock->fl.fl_type == F_UNLCK) {
574 ret = nlm_granted; 535 ret = nlm_granted;
575 goto out; 536 goto out;
576 } 537 }
577 538
578conf_lock:
579 dprintk("lockd: conflicting lock(ty=%d, %Ld-%Ld)\n", 539 dprintk("lockd: conflicting lock(ty=%d, %Ld-%Ld)\n",
580 lock->fl.fl_type, (long long)lock->fl.fl_start, 540 lock->fl.fl_type, (long long)lock->fl.fl_start,
581 (long long)lock->fl.fl_end); 541 (long long)lock->fl.fl_end);
@@ -589,8 +549,6 @@ conf_lock:
589 locks_release_private(&lock->fl); 549 locks_release_private(&lock->fl);
590 ret = nlm_lck_denied; 550 ret = nlm_lck_denied;
591out: 551out:
592 if (block)
593 nlmsvc_release_block(block);
594 return ret; 552 return ret;
595} 553}
596 554
@@ -661,7 +619,6 @@ nlmsvc_cancel_blocked(struct net *net, struct nlm_file *file, struct nlm_lock *l
661 * This is a callback from the filesystem for VFS file lock requests. 619 * This is a callback from the filesystem for VFS file lock requests.
662 * It will be used if lm_grant is defined and the filesystem can not 620 * It will be used if lm_grant is defined and the filesystem can not
663 * respond to the request immediately. 621 * respond to the request immediately.
664 * For GETLK request it will copy the reply to the nlm_block.
665 * For SETLK or SETLKW request it will get the local posix lock. 622 * For SETLK or SETLKW request it will get the local posix lock.
666 * In all cases it will move the block to the head of nlm_blocked q where 623 * In all cases it will move the block to the head of nlm_blocked q where
667 * nlmsvc_retry_blocked() can send back a reply for SETLKW or revisit the 624 * nlmsvc_retry_blocked() can send back a reply for SETLKW or revisit the