]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
filelock: add new locks_wake_up_waiter() helper
authorJeff Layton <jlayton@kernel.org>
Mon, 2 Jun 2025 11:58:54 +0000 (07:58 -0400)
committerChristian Brauner <brauner@kernel.org>
Tue, 10 Jun 2025 11:16:19 +0000 (13:16 +0200)
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>
Link: https://lore.kernel.org/20250602-filelock-6-16-v1-1-7da5b2c930fd@kernel.org
Signed-off-by: Christian Brauner <brauner@kernel.org>
fs/locks.c
include/linux/filelock.h

index 1619cddfa7a4d799f0f84f0bc8f28458d8d280db..f96024feab176537b79be41e505e60ef92fb7d68 100644 (file)
@@ -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"
index c412ded9171ed781ebe9e8d2e0426dcd10793292..c2ce8ba05d068b451ecf8f513b7e532819a29944 100644 (file)
@@ -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)