FAILED: patch "[PATCH] smb: client: close completed creates on compound wait errors" failed to apply to 6.6-stable tree
Subsystems (2)
[email protected]
maintainerThe patch below does not apply to the 6.6-stable tree.
If someone wants it applied there, or to any other stable or longterm tree, then please email the backport, including the original git commit id to <[email protected]>.
To reproduce the conflict and resubmit, you may use the following commands:
git fetch https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/ linux-6.6.y
git checkout FETCH_HEAD
git cherry-pick -x 6c5c547f037bc18f0b8d0b5db5a648f8f630ce85
# <resolve conflicts, build, test, etc.>
git commit -s
git send-email --to '<[email protected]>' --in-reply-to '2026092948-ethically-applause-6d04@gregkh' --subject-prefix 'PATCH 6.6.y' 'HEAD^..'
Possible dependencies:
thanks,
greg k-h
------------------ original commit in Linus's tree ------------------
From 6c5c547f037bc18f0b8d0b5db5a648f8f630ce85 Mon Sep 17 00:00:00 2001
From: Zihan Xi <[email protected]>
Date: Wed, 16 Sep 2026 15:29:28 +0000
Subject: [PATCH] smb: client: close completed creates on compound wait errors
compound_send_recv() waits for responses in order. If a later wait is interrupted, or if a later MID fails during response synchronization, an earlier CREATE may already have opened a remote handle. The earlier mid is then released without invoking handle_cancelled_mid(), leaving the remote handle open because no FID was copied to the caller.
Mark completed earlier mids as cancelled when a compound wait or MID synchronization aborts. Keep their response buffers attached while the MIDs are synchronized, and transfer them only after synchronization of the processed responses, so the release path can inspect successful CREATE responses and queue SMB2_close() after a later failure. Account for a remote open only after the close work is allocated and before it is queued, since the caller has not yet updated num_remote_opens. Mark the create+close compound used by smb2_unlink() so it is not closed again. Non-CREATE responses and compounds that already include a close keep their existing behavior.
fs/smb/client/smb2inode.c +1 -1
@@ -1121,7 +1121,7 @@ smb2_unlink(const unsigned int xid, struct cifs_tcon *tcon, const char *name,struct kvec close_iov;int resp_buftype[2 ];struct cifs_fid fid; -int flags =0 ; +int flags =CIFS_CP_CREATE_CLOSE_OP ;__u8 oplock;int rc;
fs/smb/client/smb2misc.c +6 -3
@@ -834,7 +834,8 @@ smb2_cancelled_close_fid(struct work_struct *work)*/ static int __smb2_handle_cancelled_cmd (struct cifs_tcon *tcon,__u16 cmd,__u64 mid, -__u64 persistent_fid,__u64 volatile_fid) +__u64 persistent_fid,__u64 volatile_fid, +bool account_remote_open) {struct close_cancelled_open *cancelled;
@@ -848,6 +849,8 @@ __smb2_handle_cancelled_cmd(struct cifs_tcon *tcon, __u16 cmd, __u64 mid, cancelled->cmd = cmd; cancelled->mid = mid;INIT_WORK (&cancelled->work, smb2_cancelled_close_fid); +if (account_remote_open) +atomic_inc (&tcon->num_remote_opens);WARN_ON (queue_work (cifsiod_wq, &cancelled->work) == false);return 0 ;
@@ -884,7 +887,7 @@ smb2_handle_cancelled_close(struct cifs_tcon *tcon, __u64 persistent_fid,spin_unlock (&tcon->tc_lock); rc =__smb2_handle_cancelled_cmd (tcon,SMB2_CLOSE_HE ,0 , - persistent_fid, volatile_fid); + persistent_fid, volatile_fid, false);if (rc)cifs_put_tcon (tcon, netfs_trace_tcon_ref_put_cancelled_close);
@@ -912,7 +915,7 @@ smb2_handle_cancelled_mid(struct mid_q_entry *mid, struct TCP_Server_Info *servele16_to_cpu (hdr->Command),le64_to_cpu (hdr->MessageId), rsp->PersistentFileId, - rsp->VolatileFileId); + rsp->VolatileFileId, true);if (rc)cifs_put_tcon (tcon, netfs_trace_tcon_ref_put_cancelled_mid);
fs/smb/client/transport.c +54 -13
112 lines not on this page · raw message
Sasha Levin
maintainerPATCH 1/1 smb: client: close completed creates on compound wait errors
From: Zihan Xi <[email protected]>
[ Upstream commit 6c5c547f037bc18f0b8d0b5db5a648f8f630ce85 ]
compound_send_recv() waits for responses in order. If a later wait is interrupted, or if a later MID fails during response synchronization, an earlier CREATE may already have opened a remote handle. The earlier mid is then released without invoking handle_cancelled_mid(), leaving the remote handle open because no FID was copied to the caller.
Mark completed earlier mids as cancelled when a compound wait or MID synchronization aborts. Keep their response buffers attached while the MIDs are synchronized, and transfer them only after synchronization of the processed responses, so the release path can inspect successful CREATE responses and queue SMB2_close() after a later failure. Account for a remote open only after the close work is allocated and before it is queued, since the caller has not yet updated num_remote_opens. Mark the create+close compound used by smb2_unlink() so it is not closed again. Non-CREATE responses and compounds that already include a close keep their existing behavior.
--- fs/smb/client/smb2misc.c | 9 +++-- fs/smb/client/transport.c | 69 ++++++++++++++++++++++++++++++--------- 2 files changed, 59 insertions(+), 19 deletions(-)
fs/smb/client/smb2misc.c +6 -3
@@ -818,7 +818,8 @@ smb2_cancelled_close_fid(struct work_struct *work)*/ static int __smb2_handle_cancelled_cmd (struct cifs_tcon *tcon,__u16 cmd,__u64 mid, -__u64 persistent_fid,__u64 volatile_fid) +__u64 persistent_fid,__u64 volatile_fid, +bool account_remote_open) {struct close_cancelled_open *cancelled;
@@ -832,6 +833,8 @@ __smb2_handle_cancelled_cmd(struct cifs_tcon *tcon, __u16 cmd, __u64 mid, cancelled->cmd = cmd; cancelled->mid = mid;INIT_WORK (&cancelled->work, smb2_cancelled_close_fid); +if (account_remote_open) +atomic_inc (&tcon->num_remote_opens);WARN_ON (queue_work (cifsiod_wq, &cancelled->work) == false);return 0 ;
@@ -868,7 +871,7 @@ smb2_handle_cancelled_close(struct cifs_tcon *tcon, __u64 persistent_fid,spin_unlock (&tcon->tc_lock); rc =__smb2_handle_cancelled_cmd (tcon,SMB2_CLOSE_HE ,0 , - persistent_fid, volatile_fid); + persistent_fid, volatile_fid, false);if (rc)cifs_put_tcon (tcon, netfs_trace_tcon_ref_put_cancelled_close);
@@ -896,7 +899,7 @@ smb2_handle_cancelled_mid(struct mid_q_entry *mid, struct TCP_Server_Info *servele16_to_cpu (hdr->Command),le64_to_cpu (hdr->MessageId), rsp->PersistentFileId, - rsp->VolatileFileId); + rsp->VolatileFileId, true);if (rc)cifs_put_tcon (tcon, netfs_trace_tcon_ref_put_cancelled_mid);
fs/smb/client/transport.c +53 -16
113 lines not on this page · raw message
Signature · 1 line
2.53.0