Skip to content

Commit 09802fd

Browse files
author
Jeff Layton
committed
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: [email protected] Signed-off-by: Jeff Layton <[email protected]> Reviewed-by: Kinglong Mee <[email protected]>
1 parent aef9583 commit 09802fd

File tree

2 files changed

+6
-50
lines changed

2 files changed

+6
-50
lines changed

fs/lockd/svclock.c

Lines changed: 6 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,6 @@ nlmsvc_create_block(struct svc_rqst *rqstp, struct nlm_host *host,
245245
block->b_daemon = rqstp->rq_server;
246246
block->b_host = host;
247247
block->b_file = file;
248-
block->b_fl = NULL;
249248
file->f_count++;
250249

251250
/* Add to file's list of blocks */
@@ -295,7 +294,6 @@ static void nlmsvc_free_block(struct kref *kref)
295294
nlmsvc_freegrantargs(block->b_call);
296295
nlmsvc_release_call(block->b_call);
297296
nlm_release_file(block->b_file);
298-
kfree(block->b_fl);
299297
kfree(block);
300298
}
301299

@@ -508,7 +506,6 @@ nlmsvc_testlock(struct svc_rqst *rqstp, struct nlm_file *file,
508506
struct nlm_host *host, struct nlm_lock *lock,
509507
struct nlm_lock *conflock, struct nlm_cookie *cookie)
510508
{
511-
struct nlm_block *block = NULL;
512509
int error;
513510
__be32 ret;
514511

@@ -519,63 +516,26 @@ nlmsvc_testlock(struct svc_rqst *rqstp, struct nlm_file *file,
519516
(long long)lock->fl.fl_start,
520517
(long long)lock->fl.fl_end);
521518

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-
560519
if (locks_in_grace(SVC_NET(rqstp))) {
561520
ret = nlm_lck_denied_grace_period;
562521
goto out;
563522
}
523+
564524
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-
}
569525
if (error) {
526+
/* We can't currently deal with deferred test requests */
527+
if (error == FILE_LOCK_DEFERRED)
528+
WARN_ON_ONCE(1);
529+
570530
ret = nlm_lck_denied_nolocks;
571531
goto out;
572532
}
533+
573534
if (lock->fl.fl_type == F_UNLCK) {
574535
ret = nlm_granted;
575536
goto out;
576537
}
577538

578-
conf_lock:
579539
dprintk("lockd: conflicting lock(ty=%d, %Ld-%Ld)\n",
580540
lock->fl.fl_type, (long long)lock->fl.fl_start,
581541
(long long)lock->fl.fl_end);
@@ -589,8 +549,6 @@ nlmsvc_testlock(struct svc_rqst *rqstp, struct nlm_file *file,
589549
locks_release_private(&lock->fl);
590550
ret = nlm_lck_denied;
591551
out:
592-
if (block)
593-
nlmsvc_release_block(block);
594552
return ret;
595553
}
596554

@@ -661,7 +619,6 @@ nlmsvc_cancel_blocked(struct net *net, struct nlm_file *file, struct nlm_lock *l
661619
* This is a callback from the filesystem for VFS file lock requests.
662620
* It will be used if lm_grant is defined and the filesystem can not
663621
* respond to the request immediately.
664-
* For GETLK request it will copy the reply to the nlm_block.
665622
* For SETLK or SETLKW request it will get the local posix lock.
666623
* In all cases it will move the block to the head of nlm_blocked q where
667624
* nlmsvc_retry_blocked() can send back a reply for SETLKW or revisit the

include/linux/lockd/lockd.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,6 @@ struct nlm_block {
178178
unsigned char b_granted; /* VFS granted lock */
179179
struct nlm_file * b_file; /* file in question */
180180
struct cache_req * b_cache_req; /* deferred request handling */
181-
struct file_lock * b_fl; /* set for GETLK */
182181
struct cache_deferred_req * b_deferred_req;
183182
unsigned int b_flags; /* block flags */
184183
#define B_QUEUED 1 /* lock queued */

0 commit comments

Comments
 (0)