diff options
author | NeilBrown <neilb@suse.com> | 2018-11-29 18:04:08 -0500 |
---|---|---|
committer | Jeff Layton <jlayton@kernel.org> | 2018-12-07 06:50:56 -0500 |
commit | cb03f94ffb070b13bc0fa58b4ef4fdb558418d27 (patch) | |
tree | 6472abe321bfeef600939937f24cb423453847ad | |
parent | fd7732e033e30b3a586923b57e338c859e17858a (diff) |
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>
-rw-r--r-- | fs/cifs/file.c | 2 | ||||
-rw-r--r-- | fs/lockd/svclock.c | 2 | ||||
-rw-r--r-- | fs/locks.c | 38 | ||||
-rw-r--r-- | fs/nfsd/nfs4state.c | 6 | ||||
-rw-r--r-- | include/linux/fs.h | 4 |
5 files changed, 21 insertions, 31 deletions
diff --git a/fs/cifs/file.c b/fs/cifs/file.c index d7ed895e05d1..94c3575e850c 100644 --- a/fs/cifs/file.c +++ b/fs/cifs/file.c | |||
@@ -1106,7 +1106,7 @@ try_again: | |||
1106 | rc = wait_event_interruptible(flock->fl_wait, !flock->fl_blocker); | 1106 | rc = wait_event_interruptible(flock->fl_wait, !flock->fl_blocker); |
1107 | if (!rc) | 1107 | if (!rc) |
1108 | goto try_again; | 1108 | goto try_again; |
1109 | posix_unblock_lock(flock); | 1109 | locks_delete_block(flock); |
1110 | } | 1110 | } |
1111 | return rc; | 1111 | return rc; |
1112 | } | 1112 | } |
diff --git a/fs/lockd/svclock.c b/fs/lockd/svclock.c index 74330daeab71..ea719cdd6a36 100644 --- a/fs/lockd/svclock.c +++ b/fs/lockd/svclock.c | |||
@@ -276,7 +276,7 @@ static int nlmsvc_unlink_block(struct nlm_block *block) | |||
276 | dprintk("lockd: unlinking block %p...\n", block); | 276 | dprintk("lockd: unlinking block %p...\n", block); |
277 | 277 | ||
278 | /* Remove block from list */ | 278 | /* 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); |
280 | nlmsvc_remove_block(block); | 280 | nlmsvc_remove_block(block); |
281 | return status; | 281 | return status; |
282 | } | 282 | } |
diff --git a/fs/locks.c b/fs/locks.c index 4d6a5a3f903a..75a03a9d666e 100644 --- a/fs/locks.c +++ b/fs/locks.c | |||
@@ -748,8 +748,16 @@ static void __locks_wake_up_blocks(struct file_lock *blocker) | |||
748 | } | 748 | } |
749 | } | 749 | } |
750 | 750 | ||
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) | ||
752 | { | 758 | { |
759 | int status = -ENOENT; | ||
760 | |||
753 | /* | 761 | /* |
754 | * If fl_blocker is NULL, it won't be set again as this thread | 762 | * If fl_blocker is NULL, it won't be set again as this thread |
755 | * "owns" the lock and is the only one that might try to claim | 763 | * "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) | |||
763 | */ | 771 | */ |
764 | if (waiter->fl_blocker == NULL && | 772 | if (waiter->fl_blocker == NULL && |
765 | list_empty(&waiter->fl_blocked_requests)) | 773 | list_empty(&waiter->fl_blocked_requests)) |
766 | return; | 774 | return status; |
767 | spin_lock(&blocked_lock_lock); | 775 | spin_lock(&blocked_lock_lock); |
776 | if (waiter->fl_blocker) | ||
777 | status = 0; | ||
768 | __locks_wake_up_blocks(waiter); | 778 | __locks_wake_up_blocks(waiter); |
769 | __locks_delete_block(waiter); | 779 | __locks_delete_block(waiter); |
770 | spin_unlock(&blocked_lock_lock); | 780 | spin_unlock(&blocked_lock_lock); |
781 | return status; | ||
771 | } | 782 | } |
783 | EXPORT_SYMBOL(locks_delete_block); | ||
772 | 784 | ||
773 | /* Insert waiter into blocker's block list. | 785 | /* Insert waiter into blocker's block list. |
774 | * We use a circular list so that processes can be easily woken up in | 786 | * We use a circular list so that processes can be easily woken up in |
@@ -2676,28 +2688,6 @@ void locks_remove_file(struct file *filp) | |||
2676 | } | 2688 | } |
2677 | 2689 | ||
2678 | /** | 2690 | /** |
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 | |||
2700 | /** | ||
2701 | * vfs_cancel_lock - file byte range unblock lock | 2691 | * vfs_cancel_lock - file byte range unblock lock |
2702 | * @filp: The file to apply the unblock to | 2692 | * @filp: The file to apply the unblock to |
2703 | * @fl: The lock to be unblocked | 2693 | * @fl: The lock to be unblocked |
diff --git a/fs/nfsd/nfs4state.c b/fs/nfsd/nfs4state.c index f093fbe47133..a334828723fa 100644 --- a/fs/nfsd/nfs4state.c +++ b/fs/nfsd/nfs4state.c | |||
@@ -238,7 +238,7 @@ find_blocked_lock(struct nfs4_lockowner *lo, struct knfsd_fh *fh, | |||
238 | } | 238 | } |
239 | spin_unlock(&nn->blocked_locks_lock); | 239 | spin_unlock(&nn->blocked_locks_lock); |
240 | if (found) | 240 | if (found) |
241 | posix_unblock_lock(&found->nbl_lock); | 241 | locks_delete_block(&found->nbl_lock); |
242 | return found; | 242 | return found; |
243 | } | 243 | } |
244 | 244 | ||
@@ -293,7 +293,7 @@ remove_blocked_locks(struct nfs4_lockowner *lo) | |||
293 | nbl = list_first_entry(&reaplist, struct nfsd4_blocked_lock, | 293 | nbl = list_first_entry(&reaplist, struct nfsd4_blocked_lock, |
294 | nbl_lru); | 294 | nbl_lru); |
295 | list_del_init(&nbl->nbl_lru); | 295 | list_del_init(&nbl->nbl_lru); |
296 | posix_unblock_lock(&nbl->nbl_lock); | 296 | locks_delete_block(&nbl->nbl_lock); |
297 | free_blocked_lock(nbl); | 297 | free_blocked_lock(nbl); |
298 | } | 298 | } |
299 | } | 299 | } |
@@ -4863,7 +4863,7 @@ nfs4_laundromat(struct nfsd_net *nn) | |||
4863 | nbl = list_first_entry(&reaplist, | 4863 | nbl = list_first_entry(&reaplist, |
4864 | struct nfsd4_blocked_lock, nbl_lru); | 4864 | struct nfsd4_blocked_lock, nbl_lru); |
4865 | list_del_init(&nbl->nbl_lru); | 4865 | list_del_init(&nbl->nbl_lru); |
4866 | posix_unblock_lock(&nbl->nbl_lock); | 4866 | locks_delete_block(&nbl->nbl_lock); |
4867 | free_blocked_lock(nbl); | 4867 | free_blocked_lock(nbl); |
4868 | } | 4868 | } |
4869 | out: | 4869 | out: |
diff --git a/include/linux/fs.h b/include/linux/fs.h index 16df3a7df378..26a8607b3c3c 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h | |||
@@ -1124,7 +1124,7 @@ extern void locks_remove_file(struct file *); | |||
1124 | extern void locks_release_private(struct file_lock *); | 1124 | extern void locks_release_private(struct file_lock *); |
1125 | extern void posix_test_lock(struct file *, struct file_lock *); | 1125 | extern void posix_test_lock(struct file *, struct file_lock *); |
1126 | extern int posix_lock_file(struct file *, struct file_lock *, struct file_lock *); | 1126 | 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 *); |
1128 | extern int vfs_test_lock(struct file *, struct file_lock *); | 1128 | extern int vfs_test_lock(struct file *, struct file_lock *); |
1129 | extern int vfs_lock_file(struct file *, unsigned int, struct file_lock *, struct file_lock *); | 1129 | extern int vfs_lock_file(struct file *, unsigned int, struct file_lock *, struct file_lock *); |
1130 | extern int vfs_cancel_lock(struct file *filp, struct file_lock *fl); | 1130 | 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, | |||
1214 | return -ENOLCK; | 1214 | return -ENOLCK; |
1215 | } | 1215 | } |
1216 | 1216 | ||
1217 | static inline int posix_unblock_lock(struct file_lock *waiter) | 1217 | static inline int locks_delete_block(struct file_lock *waiter) |
1218 | { | 1218 | { |
1219 | return -ENOENT; | 1219 | return -ENOENT; |
1220 | } | 1220 | } |