]> git.hungrycats.org Git - linux/commitdiff
ksmbd: use clear_and_wake_up_bit() directly
authorDaijiamu <3058704216@qq.com>
Tue, 3 Nov 2026 17:03:25 +0000 (12:03 -0500)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 6 Nov 2026 17:10:53 +0000 (12:10 -0500)
[ Upstream commit 8852052e32df965a76daecbd8cda0ecf950b54df ]

clear_and_wake_up_bit() was introduced by commit 8236b0ae31c8 ("bdi:
wake up concurrent wb_shutdown() callers.") to replace the open-coded
clear_bit_unlock() + smp_mb__after_atomic() + wake_up_bit() sequence.

Replace the sequence and drop the now-trivial wake_up_oplock_break()
wrapper, calling the helper directly at each call site.

Suggested-by: ChenXiaoSong <chenxiaosong@chenxiaosong.com>
Signed-off-by: Daijiamu <3058704216@qq.com>
Reviewed-by: ChenXiaoSong <chenxiaosong@kylinos.cn>
Signed-off-by: Namjae Jeon <linkinjeon@kernel.org>
Stable-dep-of: f728cfee6929 ("ksmbd: fix app-instance non-durable supersede session UAF")
Signed-off-by: Sasha Levin <sashal@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
fs/smb/server/oplock.c

index 1b8c3482d1e4e8acaca52b7dbfa9740c4ae4d632..25ff8408f0ba28f75b8a23881d2299f14b4baefa 100644 (file)
@@ -763,14 +763,6 @@ static bool wait_for_break_ack(struct oplock_info *opinfo)
        return false;
 }
 
-static void wake_up_oplock_break(struct oplock_info *opinfo)
-{
-       clear_bit_unlock(0, &opinfo->pending_break);
-       /* memory barrier is needed for wake_up_bit() */
-       smp_mb__after_atomic();
-       wake_up_bit(&opinfo->pending_break, 0);
-}
-
 static bool oplock_break_set_ack_wait(struct oplock_info *opinfo)
 {
        bool ret = false;
@@ -826,13 +818,13 @@ static int oplock_break_pending(struct oplock_info *opinfo, int req_op_level)
 
        if (opinfo->level <= req_op_level) {
                if (opinfo->is_lease == false) {
-                       wake_up_oplock_break(opinfo);
+                       clear_and_wake_up_bit(0, &opinfo->pending_break);
                        return 1;
                }
                if (opinfo->o_lease->state !=
                    (SMB2_LEASE_HANDLE_CACHING_LE |
                     SMB2_LEASE_READ_CACHING_LE)) {
-                       wake_up_oplock_break(opinfo);
+                       clear_and_wake_up_bit(0, &opinfo->pending_break);
                        return 1;
                }
        }
@@ -1260,7 +1252,7 @@ again:
                                SMB2_LEASE_HANDLE_CACHING_LE)) {
                        if (!oplock_break_set_ack_wait(brk_opinfo)) {
                                atomic_dec_if_positive(&brk_opinfo->breaking_cnt);
-                               wake_up_oplock_break(brk_opinfo);
+                               clear_and_wake_up_bit(0, &brk_opinfo->pending_break);
                                return -ENOENT;
                        }
                } else
@@ -1309,7 +1301,7 @@ again:
                      lease->state != SMB2_LEASE_NONE_LE)))
                        goto again;
 
-               wake_up_oplock_break(brk_opinfo);
+               clear_and_wake_up_bit(0, &brk_opinfo->pending_break);
                return err;
        } else {
                err = oplock_break_pending(brk_opinfo, req_op_level);
@@ -1319,7 +1311,7 @@ again:
                if (brk_opinfo->level == SMB2_OPLOCK_LEVEL_BATCH ||
                    brk_opinfo->level == SMB2_OPLOCK_LEVEL_EXCLUSIVE) {
                        if (!oplock_break_set_ack_wait(brk_opinfo)) {
-                               wake_up_oplock_break(brk_opinfo);
+                               clear_and_wake_up_bit(0, &brk_opinfo->pending_break);
                                return -ENOENT;
                        }
                }
@@ -1342,7 +1334,7 @@ again:
        ksmbd_debug(OPLOCK, "oplock granted = %d\n", brk_opinfo->level);
        if (brk_opinfo->op_state == OPLOCK_CLOSING)
                err = -EAGAIN;
-       wake_up_oplock_break(brk_opinfo);
+       clear_and_wake_up_bit(0, &brk_opinfo->pending_break);
 
        return err;
 }