mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH v2] ksmbd: use clear_and_wake_up_bit() directly
       [not found] <20260930183758.32342-1-3058704216@qq.com>
@ 2026-10-01 15:06 ` Daijiamu
  2026-10-02  1:56   ` ChenXiaoSong
  2026-10-02 13:07   ` Namjae Jeon
  0 siblings, 2 replies; 3+ messages in thread
From: Daijiamu @ 2026-10-01 15:06 UTC (permalink / raw)
  To: linkinjeon, sergey.senozhatsky, tom
  Cc: chenxiaosong, linux-cifs, linux-kernel, Daijiamu

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>
---
Changes in v2:
- Call clear_and_wake_up_bit() directly and remove wake_up_oplock_break(),
  as suggested by ChenXiaoSong.
Link: https://lore.kernel.org/linux-cifs/20260930183758.32342-1-3058704216@qq.com/
---
 fs/smb/server/oplock.c | 20 ++++++--------------
 1 file changed, 6 insertions(+), 14 deletions(-)

diff --git a/fs/smb/server/oplock.c b/fs/smb/server/oplock.c
index 1b8c3482d1e4..25ff8408f0ba 100644
--- a/fs/smb/server/oplock.c
+++ b/fs/smb/server/oplock.c
@@ -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 @@ static int oplock_break(struct oplock_info *brk_opinfo, struct ksmbd_inode *ci,
 				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 @@ static int oplock_break(struct oplock_info *brk_opinfo, struct ksmbd_inode *ci,
 		      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 @@ static int oplock_break(struct oplock_info *brk_opinfo, struct ksmbd_inode *ci,
 		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 @@ static int oplock_break(struct oplock_info *brk_opinfo, struct ksmbd_inode *ci,
 	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;
 }
-- 
2.55.0


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH v2] ksmbd: use clear_and_wake_up_bit() directly
  2026-10-01 15:06 ` [PATCH v2] ksmbd: use clear_and_wake_up_bit() directly Daijiamu
@ 2026-10-02  1:56   ` ChenXiaoSong
  2026-10-02 13:07   ` Namjae Jeon
  1 sibling, 0 replies; 3+ messages in thread
From: ChenXiaoSong @ 2026-10-02  1:56 UTC (permalink / raw)
  To: Daijiamu, linkinjeon, sergey.senozhatsky, tom; +Cc: linux-cifs, linux-kernel

Reviewed-by: ChenXiaoSong <chenxiaosong@kylinos.cn>

On 10/1/26 23:06, Daijiamu wrote:
> 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>

-- 
ChenXiaoSong <chenxiaosong@chenxiaosong.com>
Chinese Homepage: https://chenxiaosong.com
English Homepage: https://chenxiaosong.com/en


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH v2] ksmbd: use clear_and_wake_up_bit() directly
  2026-10-01 15:06 ` [PATCH v2] ksmbd: use clear_and_wake_up_bit() directly Daijiamu
  2026-10-02  1:56   ` ChenXiaoSong
@ 2026-10-02 13:07   ` Namjae Jeon
  1 sibling, 0 replies; 3+ messages in thread
From: Namjae Jeon @ 2026-10-02 13:07 UTC (permalink / raw)
  To: Daijiamu; +Cc: sergey.senozhatsky, tom, chenxiaosong, linux-cifs, linux-kernel

On Fri, Oct 2, 2026 at 12:06 AM Daijiamu <3058704216@qq.com> wrote:
>
> 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>
Applied it to #ksmbd-for-next.
Thanks!

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-10-02 13:07 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <20260930183758.32342-1-3058704216@qq.com>
2026-10-01 15:06 ` [PATCH v2] ksmbd: use clear_and_wake_up_bit() directly Daijiamu
2026-10-02  1:56   ` ChenXiaoSong
2026-10-02 13:07   ` Namjae Jeon

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®