Skip to content

Commit cb03f94

Browse files
NeilBrownjtlayton
authored andcommitted
fs/locks: merge posix_unblock_lock() and locks_delete_block()
posix_unblock_lock() is not specific to posix locks, and behaves nearly identically to locks_delete_block() - the former returning a status while the later doesn't. So discard posix_unblock_lock() and use locks_delete_block() instead, after giving that function an appropriate return value. Signed-off-by: NeilBrown <neilb@suse.com> Reviewed-by: J. Bruce Fields <bfields@redhat.com> Signed-off-by: Jeff Layton <jlayton@kernel.org>
1 parent fd7732e commit cb03f94

5 files changed

Lines changed: 21 additions & 31 deletions

File tree

‎fs/cifs/file.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1106,7 +1106,7 @@ cifs_posix_lock_set(struct file *file, struct file_lock *flock)
11061106
rc = wait_event_interruptible(flock->fl_wait, !flock->fl_blocker);
11071107
if (!rc)
11081108
goto try_again;
1109-
posix_unblock_lock(flock);
1109+
locks_delete_block(flock);
11101110
}
11111111
return rc;
11121112
}

‎fs/lockd/svclock.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,7 @@ static int nlmsvc_unlink_block(struct nlm_block *block)
276276
dprintk("lockd: unlinking block %p...\n", block);
277277

278278
/* Remove block from list */
279-
status = posix_unblock_lock(&block->b_call->a_args.lock.fl);
279+
status = locks_delete_block(&block->b_call->a_args.lock.fl);
280280
nlmsvc_remove_block(block);
281281
return status;
282282
}

‎fs/locks.c‎

Lines changed: 14 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -748,8 +748,16 @@ static void __locks_wake_up_blocks(struct file_lock *blocker)
748748
}
749749
}
750750

751-
static void locks_delete_block(struct file_lock *waiter)
751+
/**
752+
* locks_delete_lock - stop waiting for a file lock
753+
* @waiter: the lock which was waiting
754+
*
755+
* lockd/nfsd need to disconnect the lock while working on it.
756+
*/
757+
int locks_delete_block(struct file_lock *waiter)
752758
{
759+
int status = -ENOENT;
760+
753761
/*
754762
* If fl_blocker is NULL, it won't be set again as this thread
755763
* "owns" the lock and is the only one that might try to claim
@@ -763,12 +771,16 @@ static void locks_delete_block(struct file_lock *waiter)
763771
*/
764772
if (waiter->fl_blocker == NULL &&
765773
list_empty(&waiter->fl_blocked_requests))
766-
return;
774+
return status;
767775
spin_lock(&blocked_lock_lock);
776+
if (waiter->fl_blocker)
777+
status = 0;
768778
__locks_wake_up_blocks(waiter);
769779
__locks_delete_block(waiter);
770780
spin_unlock(&blocked_lock_lock);
781+
return status;
771782
}
783+
EXPORT_SYMBOL(locks_delete_block);
772784

773785
/* Insert waiter into blocker's block list.
774786
* We use a circular list so that processes can be easily woken up in
@@ -2675,28 +2687,6 @@ void locks_remove_file(struct file *filp)
26752687
spin_unlock(&ctx->flc_lock);
26762688
}
26772689

2678-
/**
2679-
* posix_unblock_lock - stop waiting for a file lock
2680-
* @waiter: the lock which was waiting
2681-
*
2682-
* lockd needs to block waiting for locks.
2683-
*/
2684-
int
2685-
posix_unblock_lock(struct file_lock *waiter)
2686-
{
2687-
int status = -ENOENT;
2688-
2689-
spin_lock(&blocked_lock_lock);
2690-
if (waiter->fl_blocker) {
2691-
__locks_wake_up_blocks(waiter);
2692-
__locks_delete_block(waiter);
2693-
status = 0;
2694-
}
2695-
spin_unlock(&blocked_lock_lock);
2696-
return status;
2697-
}
2698-
EXPORT_SYMBOL(posix_unblock_lock);
2699-
27002690
/**
27012691
* vfs_cancel_lock - file byte range unblock lock
27022692
* @filp: The file to apply the unblock to

‎fs/nfsd/nfs4state.c‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,7 @@ find_blocked_lock(struct nfs4_lockowner *lo, struct knfsd_fh *fh,
238238
}
239239
spin_unlock(&nn->blocked_locks_lock);
240240
if (found)
241-
posix_unblock_lock(&found->nbl_lock);
241+
locks_delete_block(&found->nbl_lock);
242242
return found;
243243
}
244244

@@ -293,7 +293,7 @@ remove_blocked_locks(struct nfs4_lockowner *lo)
293293
nbl = list_first_entry(&reaplist, struct nfsd4_blocked_lock,
294294
nbl_lru);
295295
list_del_init(&nbl->nbl_lru);
296-
posix_unblock_lock(&nbl->nbl_lock);
296+
locks_delete_block(&nbl->nbl_lock);
297297
free_blocked_lock(nbl);
298298
}
299299
}
@@ -4863,7 +4863,7 @@ nfs4_laundromat(struct nfsd_net *nn)
48634863
nbl = list_first_entry(&reaplist,
48644864
struct nfsd4_blocked_lock, nbl_lru);
48654865
list_del_init(&nbl->nbl_lru);
4866-
posix_unblock_lock(&nbl->nbl_lock);
4866+
locks_delete_block(&nbl->nbl_lock);
48674867
free_blocked_lock(nbl);
48684868
}
48694869
out:

‎include/linux/fs.h‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1124,7 +1124,7 @@ extern void locks_remove_file(struct file *);
11241124
extern void locks_release_private(struct file_lock *);
11251125
extern void posix_test_lock(struct file *, struct file_lock *);
11261126
extern int posix_lock_file(struct file *, struct file_lock *, struct file_lock *);
1127-
extern int posix_unblock_lock(struct file_lock *);
1127+
extern int locks_delete_block(struct file_lock *);
11281128
extern int vfs_test_lock(struct file *, struct file_lock *);
11291129
extern int vfs_lock_file(struct file *, unsigned int, struct file_lock *, struct file_lock *);
11301130
extern int vfs_cancel_lock(struct file *filp, struct file_lock *fl);
@@ -1214,7 +1214,7 @@ static inline int posix_lock_file(struct file *filp, struct file_lock *fl,
12141214
return -ENOLCK;
12151215
}
12161216

1217-
static inline int posix_unblock_lock(struct file_lock *waiter)
1217+
static inline int locks_delete_block(struct file_lock *waiter)
12181218
{
12191219
return -ENOENT;
12201220
}

0 commit comments

Comments
 (0)