[PATCH] filelock: add new locks_wake_up_waiter() helper

Jeff Layton posted 1 patch 8 months, 1 week ago
fs/locks.c               | 2 +-
include/linux/filelock.h | 7 ++++++-
2 files changed, 7 insertions(+), 2 deletions(-)
[PATCH] filelock: add new locks_wake_up_waiter() helper
Posted by Jeff Layton 8 months, 1 week ago
Currently the function that does this takes a struct file_lock, but
__locks_wake_up_blocks() deals with both locks and leases. Currently
this works because both file_lock and file_lease have the file_lock_core
at the beginning of the struct, but it's fragile to rely on that.

Add a new locks_wake_up_waiter() function and call that from
__locks_wake_up_blocks().

Signed-off-by: Jeff Layton <jlayton@kernel.org>
---
Christian, would you mind picking this up?
---
 fs/locks.c               | 2 +-
 include/linux/filelock.h | 7 ++++++-
 2 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/fs/locks.c b/fs/locks.c
index 1619cddfa7a4d799f0f84f0bc8f28458d8d280db..f96024feab176537b79be41e505e60ef92fb7d68 100644
--- a/fs/locks.c
+++ b/fs/locks.c
@@ -712,7 +712,7 @@ static void __locks_wake_up_blocks(struct file_lock_core *blocker)
 		    fl->fl_lmops && fl->fl_lmops->lm_notify)
 			fl->fl_lmops->lm_notify(fl);
 		else
-			locks_wake_up(fl);
+			locks_wake_up_waiter(waiter);
 
 		/*
 		 * The setting of flc_blocker to NULL marks the "done"
diff --git a/include/linux/filelock.h b/include/linux/filelock.h
index c412ded9171ed781ebe9e8d2e0426dcd10793292..c2ce8ba05d068b451ecf8f513b7e532819a29944 100644
--- a/include/linux/filelock.h
+++ b/include/linux/filelock.h
@@ -175,9 +175,14 @@ static inline bool lock_is_write(struct file_lock *fl)
 	return fl->c.flc_type == F_WRLCK;
 }
 
+static inline void locks_wake_up_waiter(struct file_lock_core *flc)
+{
+	wake_up(&flc->flc_wait);
+}
+
 static inline void locks_wake_up(struct file_lock *fl)
 {
-	wake_up(&fl->c.flc_wait);
+	locks_wake_up_waiter(&fl->c);
 }
 
 static inline bool locks_can_async_lock(const struct file_operations *fops)

---
base-commit: cd2e103d57e5615f9bb027d772f93b9efd567224
change-id: 20250602-filelock-6-16-b78bea7fc9ca

Best regards,
-- 
Jeff Layton <jlayton@kernel.org>
Re: [PATCH] filelock: add new locks_wake_up_waiter() helper
Posted by Benjamin Coddington 8 months, 1 week ago
On 2 Jun 2025, at 7:58, Jeff Layton wrote:

> Currently the function that does this takes a struct file_lock, but
> __locks_wake_up_blocks() deals with both locks and leases. Currently
> this works because both file_lock and file_lease have the file_lock_core
> at the beginning of the struct, but it's fragile to rely on that.
>
> Add a new locks_wake_up_waiter() function and call that from
> __locks_wake_up_blocks().
>
> Signed-off-by: Jeff Layton <jlayton@kernel.org>

Looks good,

Reviewed-by: Benjamin Coddington <bcodding@redhat.com>

Ben
Re: [PATCH] filelock: add new locks_wake_up_waiter() helper
Posted by Christian Brauner 8 months, 1 week ago
On Mon, 02 Jun 2025 07:58:54 -0400, Jeff Layton wrote:
> Currently the function that does this takes a struct file_lock, but
> __locks_wake_up_blocks() deals with both locks and leases. Currently
> this works because both file_lock and file_lease have the file_lock_core
> at the beginning of the struct, but it's fragile to rely on that.
> 
> Add a new locks_wake_up_waiter() function and call that from
> __locks_wake_up_blocks().
> 
> [...]

Applied to the vfs-6.17.misc branch of the vfs/vfs.git tree.
Patches in the vfs-6.17.misc branch should appear in linux-next soon.

Please report any outstanding bugs that were missed during review in a
new review to the original patch series allowing us to drop it.

It's encouraged to provide Acked-bys and Reviewed-bys even though the
patch has now been applied. If possible patch trailers will be updated.

Note that commit hashes shown below are subject to change due to rebase,
trailer updates or similar. If in doubt, please check the listed branch.

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/vfs/vfs.git
branch: vfs-6.17.misc

[1/1] filelock: add new locks_wake_up_waiter() helper
      https://git.kernel.org/vfs/vfs/c/cc69995fd8e9