From: Youling Tang <youling.tang@linux.dev>
To: linkinjeon@kernel.org, pc@manguebit.org,
ronniesahlberg@gmail.com, sprasad@microsoft.com, tom@talpey.com,
bharathsm@microsoft.com, metze@samba.org,
chenxiaosong@chenxiaosong.com
Cc: linux-cifs@vger.kernel.org, Youling Tang <tangyouling@kylinos.cn>,
ChenXiaoSong <chenxiaosong@kylinos.cn>
Subject: [PATCH 1/3] smb/client: factor out smb2_release_io_mr()
Date: Fri, 4 Dec 2026 16:41:09 +0800 [thread overview]
Message-ID: <20261204084111.1483103-2-youling.tang@linux.dev> (raw)
In-Reply-To: <20261204084111.1483103-1-youling.tang@linux.dev>
From: Youling Tang <tangyouling@kylinos.cn>
Preparation for the next patch. It can also be folded into the next patch.
Signed-off-by: Youling Tang <tangyouling@kylinos.cn>
Reviewed-by: ChenXiaoSong <chenxiaosong@kylinos.cn>
---
fs/smb/client/smb2pdu.c | 37 +++++++++++++------------------------
1 file changed, 13 insertions(+), 24 deletions(-)
diff --git a/fs/smb/client/smb2pdu.c b/fs/smb/client/smb2pdu.c
index dc2d0915268f..74309e063403 100644
--- a/fs/smb/client/smb2pdu.c
+++ b/fs/smb/client/smb2pdu.c
@@ -4775,6 +4775,17 @@ int smb2_new_read_req(void **buf, unsigned int *total_len,
return rc;
}
+/* Return the MR to the pool before netfs can retry the subrequest. */
+static void smb2_release_io_mr(struct cifs_io_subrequest *subreq)
+{
+#ifdef CONFIG_CIFS_SMB_DIRECT
+ if (subreq->mr) {
+ smbd_deregister_mr(subreq->mr);
+ subreq->mr = NULL;
+ }
+#endif
+}
+
static void
smb2_readv_callback(struct TCP_Server_Info *server, struct mid_q_entry *mid)
{
@@ -4864,17 +4875,7 @@ smb2_readv_callback(struct TCP_Server_Info *server, struct mid_q_entry *mid)
mid->mid_state);
break;
}
-#ifdef CONFIG_CIFS_SMB_DIRECT
- /*
- * If this rdata has a memory registered, the MR can be freed
- * MR needs to be freed as soon as I/O finishes to prevent deadlock
- * because they have limited number and are used for future I/Os
- */
- if (rdata->mr) {
- smbd_deregister_mr(rdata->mr);
- rdata->mr = NULL;
- }
-#endif
+ smb2_release_io_mr(rdata);
if (rdata->result && rdata->result != -ENODATA) {
cifs_stats_fail_inc(tcon, SMB2_READ_HE);
trace_smb3_read_err(rdata->rreq->debug_id,
@@ -5221,19 +5222,7 @@ smb2_writev_callback(struct TCP_Server_Info *server, struct mid_q_entry *mid)
mid->mid_state);
break;
}
-#ifdef CONFIG_CIFS_SMB_DIRECT
- /*
- * If this wdata has a memory registered, the MR can be freed
- * The number of MRs available is limited, it's important to recover
- * used MR as soon as I/O is finished. Hold MR longer in the later
- * I/O process can possibly result in I/O deadlock due to lack of MR
- * to send request on I/O retry
- */
- if (wdata->mr) {
- smbd_deregister_mr(wdata->mr);
- wdata->mr = NULL;
- }
-#endif
+ smb2_release_io_mr(wdata);
if (result) {
wdata->result = result;
cifs_stats_fail_inc(tcon, SMB2_WRITE_HE);
--
2.55.0
next prev parent reply other threads:[~2026-12-04 8:42 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-04 8:41 [PATCH 0/3] fix refcount leak in smb2_async_readv() and smb2_async_writev() Youling Tang
2026-12-04 8:41 ` Youling Tang [this message]
2026-12-04 8:41 ` [PATCH 2/3] smb/client: " Youling Tang
2026-12-04 8:41 ` [PATCH 3/3] smb/client: remove redundant MR release from cifs_free_subrequest() Youling Tang
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=20261204084111.1483103-2-youling.tang@linux.dev \
--to=youling.tang@linux.dev \
--cc=bharathsm@microsoft.com \
--cc=chenxiaosong@chenxiaosong.com \
--cc=chenxiaosong@kylinos.cn \
--cc=linkinjeon@kernel.org \
--cc=linux-cifs@vger.kernel.org \
--cc=metze@samba.org \
--cc=pc@manguebit.org \
--cc=ronniesahlberg@gmail.com \
--cc=sprasad@microsoft.com \
--cc=tangyouling@kylinos.cn \
--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