From: ChenXiaoSong <chenxiaosong@chenxiaosong.com>
To: smfrench@gmail.com, linkinjeon@kernel.org, pc@manguebit.org,
ronniesahlberg@gmail.com, sprasad@microsoft.com, tom@talpey.com,
bharathsm@microsoft.com, senozhatsky@chromium.org,
dhowells@redhat.com, metze@samba.org
Cc: linux-cifs@vger.kernel.org, ChenXiaoSong <chenxiaosong@kylinos.cn>
Subject: [PATCH 6/9] smb/client: add helpers for sending cancel requests
Date: Wed, 1 Jul 2026 08:25:04 +0000 [thread overview]
Message-ID: <20260701082507.786487-7-chenxiaosong@chenxiaosong.com> (raw)
In-Reply-To: <20260701082507.786487-1-chenxiaosong@chenxiaosong.com>
From: ChenXiaoSong <chenxiaosong@kylinos.cn>
SMB cancel requests are sent after the waiter has already been interrupted,
so they need to get onto the wire even when the current task has a pending
signal.
Split the low-level send path so normal requests keep the existing blocking
and signal checks, while cancel requests can ignore the pre-send fatal
signal check and force non-blocking socket sends.
Signed-off-by: ChenXiaoSong <chenxiaosong@kylinos.cn>
---
fs/smb/client/cifsproto.h | 2 ++
fs/smb/client/transport.c | 49 +++++++++++++++++++++++++++++----------
2 files changed, 39 insertions(+), 12 deletions(-)
diff --git a/fs/smb/client/cifsproto.h b/fs/smb/client/cifsproto.h
index dfbad6bc0a9b..4afe2163ef67 100644
--- a/fs/smb/client/cifsproto.h
+++ b/fs/smb/client/cifsproto.h
@@ -109,6 +109,8 @@ int cifs_sync_mid_result(struct mid_q_entry *mid,
struct TCP_Server_Info *server);
int __smb_send_rqst(struct TCP_Server_Info *server, int num_rqst,
struct smb_rqst *rqst);
+int __smb_send_cancel_rqst(struct TCP_Server_Info *server, int num_rqst,
+ struct smb_rqst *rqst);
int wait_for_free_request(struct TCP_Server_Info *server, const int flags,
unsigned int *instance);
int cifs_wait_mtu_credits(struct TCP_Server_Info *server, size_t size,
diff --git a/fs/smb/client/transport.c b/fs/smb/client/transport.c
index fdf4e50c27ce..652e1e5711ad 100644
--- a/fs/smb/client/transport.c
+++ b/fs/smb/client/transport.c
@@ -130,17 +130,18 @@ delete_mid(struct TCP_Server_Info *server, struct mid_q_entry *mid)
}
/*
- * smb_send_kvec - send an array of kvecs to the server
+ * smb_send_kvec_flags - send an array of kvecs to the server
* @server: Server to send the data to
* @smb_msg: Message to send
* @sent: amount of data sent on socket is stored here
+ * @force_nonblock: force non-blocking socket sends
*
- * Our basic "send data to server" function. Should be called with srv_mutex
+ * Our basic "send data to server" helper. Should be called with srv_mutex
* held. The caller is responsible for handling the results.
*/
-int
-smb_send_kvec(struct TCP_Server_Info *server, struct msghdr *smb_msg,
- size_t *sent)
+static int
+smb_send_kvec_flags(struct TCP_Server_Info *server, struct msghdr *smb_msg,
+ size_t *sent, bool force_nonblock)
{
int rc = 0;
int retries = 0;
@@ -148,7 +149,7 @@ smb_send_kvec(struct TCP_Server_Info *server, struct msghdr *smb_msg,
*sent = 0;
- if (server->noblocksnd)
+ if (server->noblocksnd || force_nonblock)
smb_msg->msg_flags = MSG_DONTWAIT + MSG_NOSIGNAL;
else
smb_msg->msg_flags = MSG_NOSIGNAL;
@@ -210,6 +211,13 @@ smb_send_kvec(struct TCP_Server_Info *server, struct msghdr *smb_msg,
return 0;
}
+int
+smb_send_kvec(struct TCP_Server_Info *server, struct msghdr *smb_msg,
+ size_t *sent)
+{
+ return smb_send_kvec_flags(server, smb_msg, sent, false);
+}
+
unsigned long
smb_rqst_len(struct TCP_Server_Info *server, struct smb_rqst *rqst)
{
@@ -235,8 +243,10 @@ smb_rqst_len(struct TCP_Server_Info *server, struct smb_rqst *rqst)
return buflen;
}
-int __smb_send_rqst(struct TCP_Server_Info *server, int num_rqst,
- struct smb_rqst *rqst)
+static int
+__smb_send_rqst_common(struct TCP_Server_Info *server, int num_rqst,
+ struct smb_rqst *rqst, bool ignore_signal,
+ bool force_nonblock)
{
int rc;
struct kvec *iov;
@@ -263,7 +273,7 @@ int __smb_send_rqst(struct TCP_Server_Info *server, int num_rqst,
goto out;
rc = -ERESTARTSYS;
- if (fatal_signal_pending(current)) {
+ if (!ignore_signal && fatal_signal_pending(current)) {
cifs_dbg(FYI, "signal pending before send request\n");
goto out;
}
@@ -293,7 +303,8 @@ int __smb_send_rqst(struct TCP_Server_Info *server, int num_rqst,
.iov_len = 4
};
iov_iter_kvec(&smb_msg.msg_iter, ITER_SOURCE, &hiov, 1, 4);
- rc = smb_send_kvec(server, &smb_msg, &sent);
+ rc = smb_send_kvec_flags(server, &smb_msg, &sent,
+ force_nonblock);
if (rc < 0)
goto unmask;
@@ -315,7 +326,8 @@ int __smb_send_rqst(struct TCP_Server_Info *server, int num_rqst,
iov_iter_kvec(&smb_msg.msg_iter, ITER_SOURCE, iov, n_vec, size);
- rc = smb_send_kvec(server, &smb_msg, &sent);
+ rc = smb_send_kvec_flags(server, &smb_msg, &sent,
+ force_nonblock);
if (rc < 0)
goto unmask;
@@ -323,7 +335,8 @@ int __smb_send_rqst(struct TCP_Server_Info *server, int num_rqst,
if (iov_iter_count(&rqst[j].rq_iter) > 0) {
smb_msg.msg_iter = rqst[j].rq_iter;
- rc = smb_send_kvec(server, &smb_msg, &sent);
+ rc = smb_send_kvec_flags(server, &smb_msg,
+ &sent, force_nonblock);
if (rc < 0)
break;
total_len += sent;
@@ -382,6 +395,18 @@ int __smb_send_rqst(struct TCP_Server_Info *server, int num_rqst,
return rc;
}
+int __smb_send_rqst(struct TCP_Server_Info *server, int num_rqst,
+ struct smb_rqst *rqst)
+{
+ return __smb_send_rqst_common(server, num_rqst, rqst, false, false);
+}
+
+int __smb_send_cancel_rqst(struct TCP_Server_Info *server, int num_rqst,
+ struct smb_rqst *rqst)
+{
+ return __smb_send_rqst_common(server, num_rqst, rqst, true, true);
+}
+
static int
smb_send_rqst(struct TCP_Server_Info *server, int num_rqst,
struct smb_rqst *rqst, int flags)
--
2.54.0
next prev parent reply other threads:[~2026-07-01 8:26 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-01 8:24 [PATCH 0/9] smb/client: improve change notify support ChenXiaoSong
2026-07-01 8:24 ` [PATCH 1/9] smb/client: factor out cifs_new_dir_fileinfo() ChenXiaoSong
2026-07-01 8:25 ` [PATCH 2/9] smb/client: close cached notify handles on closedir ChenXiaoSong
2026-07-01 8:25 ` [PATCH 3/9] smb/client: prepare notify ioctl per-open state ChenXiaoSong
2026-07-01 8:25 ` [PATCH 4/9] smb/client: cache SMB3 change notify handles ChenXiaoSong
2026-07-01 8:25 ` [PATCH 5/9] smb/client: retry change notify after invalid cached handle ChenXiaoSong
2026-07-01 8:25 ` ChenXiaoSong [this message]
2026-07-01 8:25 ` [PATCH 7/9] smb/client: remember async ids from SMB2 pending responses ChenXiaoSong
2026-07-01 8:25 ` [PATCH 8/9] smb/client: send SMB2 cancel requests ChenXiaoSong
2026-07-01 8:25 ` [PATCH 9/9] smb/client: make SMB2 change notify interruptible ChenXiaoSong
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260701082507.786487-7-chenxiaosong@chenxiaosong.com \
--to=chenxiaosong@chenxiaosong.com \
--cc=bharathsm@microsoft.com \
--cc=chenxiaosong@kylinos.cn \
--cc=dhowells@redhat.com \
--cc=linkinjeon@kernel.org \
--cc=linux-cifs@vger.kernel.org \
--cc=metze@samba.org \
--cc=pc@manguebit.org \
--cc=ronniesahlberg@gmail.com \
--cc=senozhatsky@chromium.org \
--cc=smfrench@gmail.com \
--cc=sprasad@microsoft.com \
--cc=tom@talpey.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox