]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
ksmbd: chain pending lease breaks before waking waiters
authorNamjae Jeon <linkinjeon@kernel.org>
Mon, 22 Jun 2026 23:28:55 +0000 (08:28 +0900)
committerSteve French <stfrench@microsoft.com>
Tue, 23 Jun 2026 01:15:04 +0000 (20:15 -0500)
commit7efb3f2458a8d260ce6ab37807f4b2a926483f76
treec31ab7ebd08864d17afc57206a91f12b507e0fe3
parent890825ed5c427fcb542ae1a0fd7495e551dcacaf
ksmbd: chain pending lease breaks before waking waiters

A pending open can require more than one lease break before the existing
lease becomes compatible with the operation that triggered the break.
smb2.lease.breaking3 expects the server to hold the pending normal open
through RWH->RH and RH->R, while a later overwrite waiter must not
collapse that second break directly to RH->NONE.

Keep pending_break held for lease breaks until the current triggering
operation is compatible with the lease state. Snapshot the truncate request
per oplock_break() call so another waiter cannot overwrite the state of
the active break.

Use the requested oplock level when deciding whether to chain another
break. A second lease open only needs RWH->RH, while a normal none-oplock
open can continue down to R and then NONE.

For non-truncating metadata operations, break leases only down to read
caching. Operations such as delete-on-close need to drop handle caching,
but should not send a second R->NONE break after the client acknowledges
RH->R.

Also send STATUS_PENDING for levelII/read-lease break waiters. An async
SMB2 create becomes cancelable only after the server sends
an NT_STATUS_PENDING interim response. A waiter that blocks behind an
already active lease break must receive the interim response before
sleeping on pending_break, otherwise the client can process a later lease
break while the create request is still not marked pending.

Avoid duplicate interim responses when an overwrite first breaks a write
oplock and then scans levelII/read leases.

Signed-off-by: Namjae Jeon <linkinjeon@kernel.org>
Signed-off-by: Steve French <stfrench@microsoft.com>
fs/smb/server/oplock.c