This is a note to let you know that I've just added the patch titled ksmbd: don't increment epoch if current state and request state are same to the 6.1-stable tree which can be found at: http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary The filename of the patch is: ksmbd-don-t-increment-epoch-if-current-state-and-request-state-are-same.patch and it can be found in the queue-6.1 subdirectory. If you, or anyone else, feels it should not be added to the stable tree, please let <stable@xxxxxxxxxxxxxxx> know about it. >From stable+bounces-15501-greg=kroah.com@xxxxxxxxxxxxxxx Tue Jan 23 03:39:55 2024 From: Namjae Jeon <linkinjeon@xxxxxxxxxx> Date: Tue, 23 Jan 2024 20:38:52 +0900 Subject: ksmbd: don't increment epoch if current state and request state are same To: gregkh@xxxxxxxxxxxxxxxxxxx, sashal@xxxxxxxxxx Cc: stable@xxxxxxxxxxxxxxx, Namjae Jeon <linkinjeon@xxxxxxxxxx>, Steve French <stfrench@xxxxxxxxxxxxx> Message-ID: <20240123113854.194887-4-linkinjeon@xxxxxxxxxx> From: Namjae Jeon <linkinjeon@xxxxxxxxxx> [ Upstream commit b6e9a44e99603fe10e1d78901fdd97681a539612 ] If existing lease state and request state are same, don't increment epoch in create context. Signed-off-by: Namjae Jeon <linkinjeon@xxxxxxxxxx> Signed-off-by: Steve French <stfrench@xxxxxxxxxxxxx> Signed-off-by: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx> --- fs/smb/server/oplock.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) --- a/fs/smb/server/oplock.c +++ b/fs/smb/server/oplock.c @@ -105,7 +105,7 @@ static int alloc_lease(struct oplock_inf lease->is_dir = lctx->is_dir; memcpy(lease->parent_lease_key, lctx->parent_lease_key, SMB2_LEASE_KEY_SIZE); lease->version = lctx->version; - lease->epoch = le16_to_cpu(lctx->epoch); + lease->epoch = le16_to_cpu(lctx->epoch) + 1; INIT_LIST_HEAD(&opinfo->lease_entry); opinfo->o_lease = lease; @@ -541,6 +541,9 @@ static struct oplock_info *same_client_h continue; } + if (lctx->req_state != lease->state) + lease->epoch++; + /* upgrading lease */ if ((atomic_read(&ci->op_count) + atomic_read(&ci->sop_count)) == 1) { @@ -1035,7 +1038,7 @@ static void copy_lease(struct oplock_inf SMB2_LEASE_KEY_SIZE); lease2->duration = lease1->duration; lease2->flags = lease1->flags; - lease2->epoch = lease1->epoch++; + lease2->epoch = lease1->epoch; lease2->version = lease1->version; } @@ -1454,7 +1457,7 @@ void create_lease_buf(u8 *rbuf, struct l memcpy(buf->lcontext.LeaseKey, lease->lease_key, SMB2_LEASE_KEY_SIZE); buf->lcontext.LeaseFlags = lease->flags; - buf->lcontext.Epoch = cpu_to_le16(++lease->epoch); + buf->lcontext.Epoch = cpu_to_le16(lease->epoch); buf->lcontext.LeaseState = lease->state; memcpy(buf->lcontext.ParentLeaseKey, lease->parent_lease_key, SMB2_LEASE_KEY_SIZE); Patches currently in stable-queue which might be from kroah.com@xxxxxxxxxxxxxxx are queue-6.1/ksmbd-send-lease-break-notification-on-file_rename_information.patch queue-6.1/ksmbd-fix-potential-circular-locking-issue-in-smb2_set_ea.patch queue-6.1/ksmbd-add-missing-set_freezable-for-freezable-kthread.patch queue-6.1/ksmbd-set-v2-lease-version-on-lease-upgrade.patch queue-6.1/ksmbd-don-t-increment-epoch-if-current-state-and-request-state-are-same.patch