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.
Unified · Split
| @@ -245,7 +245,6 @@ nlmsvc_create_block(struct svc_rqst *rqstp, struct nlm_host *host, · 244 unmodified lines | ||
| 245 | 245 | block->b_daemon = rqstp->rq_server; |
| 246 | 246 | block->b_host = host; |
| 247 | 247 | block->b_file = file; |
| 248 | − block->b_fl = NULL; | |
| 249 | 248 | file->f_count++; |
| 250 | 249 | |
| 251 | 250 | /* Add to file's list of blocks */ |
| @@ -295,7 +294,6 @@ static void nlmsvc_free_block(struct kref *kref) · 43 unmodified lines | ||
| 295 | 294 | nlmsvc_freegrantargs(block->b_call); |
| 296 | 295 | nlmsvc_release_call(block->b_call); |
| 297 | 296 | nlm_release_file(block->b_file); |
| 298 | − kfree(block->b_fl); | |
| 299 | 297 | kfree(block); |
| 300 | 298 | } |
| 301 | 299 | |
| @@ -508,7 +506,6 @@ nlmsvc_testlock(struct svc_rqst *rqstp, struct nlm_file *file, · 206 unmodified lines | ||
| 508 | 506 | struct nlm_host *host, struct nlm_lock *lock, |
| 509 | 507 | struct nlm_lock *conflock, struct nlm_cookie *cookie) |
| 510 | 508 | { |
| 511 | − struct nlm_block *block = NULL; | |
| 512 | 509 | int error; |
| 513 | 510 | __be32 ret; |
| 514 | 511 | |
| @@ -519,63 +516,26 @@ nlmsvc_testlock(struct svc_rqst *rqstp, struct nlm_file *file, · 4 unmodified lines | ||
| 519 | 516 | (long long)lock->fl.fl_start, |
| 520 | 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 | 519 | if (locks_in_grace(SVC_NET(rqstp))) { |
| 561 | 520 | ret = nlm_lck_denied_grace_period; |
| 562 | 521 | goto out; |
| 563 | 522 | } |
| 523 | + | |
| 564 | 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 | 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 | 530 | ret = nlm_lck_denied_nolocks; |
| 571 | 531 | goto out; |
| 572 | 532 | } |
| 533 | + | |
| 573 | 534 | if (lock->fl.fl_type == F_UNLCK) { |
| 574 | 535 | ret = nlm_granted; |
| 575 | 536 | goto out; |
| 576 | 537 | } |
| 577 | 538 | |
| 578 | −conf_lock: | |
| 579 | 539 | dprintk("lockd: conflicting lock(ty=%d, %Ld-%Ld)\n", |
| 580 | 540 | lock->fl.fl_type, (long long)lock->fl.fl_start, |
| 581 | 541 | (long long)lock->fl.fl_end); |
| @@ -589,8 +549,6 @@ conf_lock: · 7 unmodified lines | ||
| 589 | 549 | locks_release_private(&lock->fl); |
| 590 | 550 | ret = nlm_lck_denied; |
| 591 | 551 | out: |
| 592 | − if (block) | |
| 593 | − nlmsvc_release_block(block); | |
| 594 | 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 · 64 unmodified lines | ||
| 661 | 619 | * This is a callback from the filesystem for VFS file lock requests. |
| 662 | 620 | * It will be used if lm_grant is defined and the filesystem can not |
| 663 | 621 | * respond to the request immediately. |
| 664 | − * For GETLK request it will copy the reply to the nlm_block. | |
| 665 | 622 | * For SETLK or SETLKW request it will get the local posix lock. |
| 666 | 623 | * In all cases it will move the block to the head of nlm_blocked q where |
| 667 | 624 | * nlmsvc_retry_blocked() can send back a reply for SETLKW or revisit the |
| @@ -178,7 +178,6 @@ struct nlm_block { · 177 unmodified lines | ||
| 178 | 178 | unsigned char b_granted; /* VFS granted lock */ |
| 179 | 179 | struct nlm_file * b_file; /* file in question */ |
| 180 | 180 | struct cache_req * b_cache_req; /* deferred request handling */ |
| 181 | − struct file_lock * b_fl; /* set for GETLK */ | |
| 182 | 181 | struct cache_deferred_req * b_deferred_req; |
| 183 | 182 | unsigned int b_flags; /* block flags */ |
| 184 | 183 | #define B_QUEUED 1 /* lock queued */ |