Linux CIFS filesystem development
 help / color / mirror / Atom feed
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, samba-technical@lists.samba.org,
	ChenXiaoSong <chenxiaosong@kylinos.cn>
Subject: [PATCH v2 2/3] smb/server: introduce struct ksmbd_transport_write
Date: Wed,  8 Jul 2026 02:56:14 +0000	[thread overview]
Message-ID: <20260708025615.145390-3-chenxiaosong@chenxiaosong.com> (raw)
In-Reply-To: <20260708025615.145390-1-chenxiaosong@chenxiaosong.com>

From: ChenXiaoSong <chenxiaosong@kylinos.cn>

Put the arguments of ksmbd_transport_ops ->writev() into a struct. This makes the
function call shorter and easier to read.

Add __ksmbd_conn_write() for the common write code. A later patch will use
it for another write helper.

No functional change.

Signed-off-by: ChenXiaoSong <chenxiaosong@kylinos.cn>
---
 fs/smb/server/connection.c     | 22 ++++++++++++++++------
 fs/smb/server/connection.h     | 13 ++++++++++---
 fs/smb/server/transport_rdma.c |  9 +++++----
 fs/smb/server/transport_tcp.c  | 13 +++++++------
 4 files changed, 38 insertions(+), 19 deletions(-)

diff --git a/fs/smb/server/connection.c b/fs/smb/server/connection.c
index dee8e4aced99..d5b35087556e 100644
--- a/fs/smb/server/connection.c
+++ b/fs/smb/server/connection.c
@@ -350,7 +350,8 @@ int ksmbd_conn_wait_idle_sess_id(struct ksmbd_conn *curr_conn, u64 sess_id)
 	return 0;
 }
 
-int ksmbd_conn_write(struct ksmbd_work *work)
+static int __ksmbd_conn_write(struct ksmbd_work *work,
+			      struct ksmbd_transport_write *write)
 {
 	struct ksmbd_conn *conn = work->conn;
 	int sent;
@@ -366,12 +367,14 @@ int ksmbd_conn_write(struct ksmbd_work *work)
 	if (!work->iov_idx)
 		return -EINVAL;
 
+	write->iov = work->iov;
+	write->iov_cnt = work->iov_cnt;
+	write->size = get_rfc1002_len(work->iov[0].iov_base) + 4;
+	write->need_invalidate_rkey = work->need_invalidate_rkey;
+	write->remote_key = work->remote_key;
+
 	ksmbd_conn_lock(conn);
-	sent = conn->transport->ops->writev(conn->transport, work->iov,
-			work->iov_cnt,
-			get_rfc1002_len(work->iov[0].iov_base) + 4,
-			work->need_invalidate_rkey,
-			work->remote_key);
+	sent = conn->transport->ops->writev(conn->transport, write);
 	ksmbd_conn_unlock(conn);
 
 	if (sent < 0) {
@@ -382,6 +385,13 @@ int ksmbd_conn_write(struct ksmbd_work *work)
 	return 0;
 }
 
+int ksmbd_conn_write(struct ksmbd_work *work)
+{
+	struct ksmbd_transport_write write = {};
+
+	return __ksmbd_conn_write(work, &write);
+}
+
 int ksmbd_conn_rdma_read(struct ksmbd_conn *conn,
 			 void *buf, unsigned int buflen,
 			 struct smbdirect_buffer_descriptor_v1 *desc,
diff --git a/fs/smb/server/connection.h b/fs/smb/server/connection.h
index ec75633b7da0..62df151ca554 100644
--- a/fs/smb/server/connection.h
+++ b/fs/smb/server/connection.h
@@ -132,14 +132,21 @@ struct ksmbd_conn_ops {
 	int	(*terminate_fn)(struct ksmbd_conn *conn);
 };
 
+struct ksmbd_transport_write {
+	struct kvec	*iov;
+	int		iov_cnt;
+	int		size;
+	bool		need_invalidate_rkey;
+	unsigned int	remote_key;
+};
+
 struct ksmbd_transport_ops {
 	void (*disconnect)(struct ksmbd_transport *t);
 	void (*shutdown)(struct ksmbd_transport *t);
 	int (*read)(struct ksmbd_transport *t, char *buf,
 		    unsigned int size, int max_retries);
-	int (*writev)(struct ksmbd_transport *t, struct kvec *iovs, int niov,
-		      int size, bool need_invalidate_rkey,
-		      unsigned int remote_key);
+	int (*writev)(struct ksmbd_transport *t,
+		      const struct ksmbd_transport_write *write);
 	int (*rdma_read)(struct ksmbd_transport *t,
 			 void *buf, unsigned int len,
 			 struct smbdirect_buffer_descriptor_v1 *desc,
diff --git a/fs/smb/server/transport_rdma.c b/fs/smb/server/transport_rdma.c
index b6d63ff8a8a3..b2a882421823 100644
--- a/fs/smb/server/transport_rdma.c
+++ b/fs/smb/server/transport_rdma.c
@@ -239,17 +239,18 @@ static int smb_direct_read(struct ksmbd_transport *t, char *buf,
 }
 
 static int smb_direct_writev(struct ksmbd_transport *t,
-			     struct kvec *iov, int niovs, int buflen,
-			     bool need_invalidate, unsigned int remote_key)
+			     const struct ksmbd_transport_write *write)
 {
 	struct smb_direct_transport *st = SMBD_TRANS(t);
 	struct smbdirect_socket *sc = st->socket;
 	struct iov_iter iter;
 
-	iov_iter_kvec(&iter, ITER_SOURCE, iov, niovs, buflen);
+	iov_iter_kvec(&iter, ITER_SOURCE, write->iov, write->iov_cnt,
+		      write->size);
 
 	return smbdirect_connection_send_iter(sc, &iter, 0,
-					      need_invalidate, remote_key);
+					      write->need_invalidate_rkey,
+					      write->remote_key);
 }
 
 static int smb_direct_rdma_write(struct ksmbd_transport *t,
diff --git a/fs/smb/server/transport_tcp.c b/fs/smb/server/transport_tcp.c
index 13b711ea575d..448f24d44b6b 100644
--- a/fs/smb/server/transport_tcp.c
+++ b/fs/smb/server/transport_tcp.c
@@ -417,14 +417,15 @@ static int ksmbd_tcp_read(struct ksmbd_transport *t, char *buf,
 	return ksmbd_tcp_readv(TCP_TRANS(t), &iov, 1, to_read, max_retries);
 }
 
-static int ksmbd_tcp_writev(struct ksmbd_transport *t, struct kvec *iov,
-			    int nvecs, int size, bool need_invalidate,
-			    unsigned int remote_key)
-
+static int ksmbd_tcp_writev(struct ksmbd_transport *t,
+			    const struct ksmbd_transport_write *write)
 {
-	struct msghdr smb_msg = {.msg_flags = MSG_NOSIGNAL};
+	struct msghdr smb_msg = {
+		.msg_flags = MSG_NOSIGNAL,
+	};
 
-	return kernel_sendmsg(TCP_TRANS(t)->sock, &smb_msg, iov, nvecs, size);
+	return kernel_sendmsg(TCP_TRANS(t)->sock, &smb_msg, write->iov,
+			      write->iov_cnt, write->size);
 }
 
 static void ksmbd_tcp_disconnect(struct ksmbd_transport *t)
-- 
2.54.0


  parent reply	other threads:[~2026-07-08  2:56 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-08  2:56 [PATCH v2 0/3] smb/server: improve async interim response handling for compound requests ChenXiaoSong
2026-07-08  2:56 ` [PATCH v2 1/3] smb/server: send compound prefix before async pending response ChenXiaoSong
2026-07-08  2:56 ` ChenXiaoSong [this message]
2026-07-08  2:56 ` [PATCH v2 3/3] smb/server: use MSG_EOR for async interim response ChenXiaoSong
2026-07-08 10:33 ` [PATCH v2 0/3] smb/server: improve async interim response handling for compound requests Namjae Jeon

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=20260708025615.145390-3-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=samba-technical@lists.samba.org \
    --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