summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStefan Metzmacher <metze@samba.org>2025-09-17 10:13:25 +0300
committerSteve French <stfrench@microsoft.com>2026-04-16 05:58:19 +0300
commitdd1960ab384e9188a3d1f7db4ac8276f3edec13e (patch)
tree69d397a77371ec259e721e6d6835a197dc4549aa
parent6073eb3e31756d569c4853fb22724525739d0e0c (diff)
downloadlinux-dd1960ab384e9188a3d1f7db4ac8276f3edec13e.tar.xz
smb: smbdirect: introduce smbdirect_connection_post_recv_io()
This is basically a copy of smbd_post_recv() in the client and smb_direct_post_recv() in the server. The only difference is that this returns early if the connection is already broken. Cc: Steve French <smfrench@gmail.com> Cc: Tom Talpey <tom@talpey.com> Cc: Long Li <longli@microsoft.com> Cc: Namjae Jeon <linkinjeon@kernel.org> Cc: linux-cifs@vger.kernel.org Cc: samba-technical@lists.samba.org Signed-off-by: Stefan Metzmacher <metze@samba.org> Acked-by: Namjae Jeon <linkinjeon@kernel.org> Signed-off-by: Steve French <stfrench@microsoft.com>
-rw-r--r--fs/smb/common/smbdirect/smbdirect_connection.c42
1 files changed, 42 insertions, 0 deletions
diff --git a/fs/smb/common/smbdirect/smbdirect_connection.c b/fs/smb/common/smbdirect/smbdirect_connection.c
index 3b0cbbece44c..81b42eaec8b1 100644
--- a/fs/smb/common/smbdirect/smbdirect_connection.c
+++ b/fs/smb/common/smbdirect/smbdirect_connection.c
@@ -652,6 +652,48 @@ skip_free:
wake_up(&sc->send_io.pending.dec_wait_queue);
}
+__maybe_unused /* this is temporary while this file is included in others */
+static int smbdirect_connection_post_recv_io(struct smbdirect_recv_io *msg)
+{
+ struct smbdirect_socket *sc = msg->socket;
+ const struct smbdirect_socket_parameters *sp = &sc->parameters;
+ struct ib_recv_wr recv_wr = {
+ .wr_cqe = &msg->cqe,
+ .sg_list = &msg->sge,
+ .num_sge = 1,
+ };
+ int ret;
+
+ if (unlikely(sc->first_error))
+ return sc->first_error;
+
+ msg->sge.addr = ib_dma_map_single(sc->ib.dev,
+ msg->packet,
+ sp->max_recv_size,
+ DMA_FROM_DEVICE);
+ ret = ib_dma_mapping_error(sc->ib.dev, msg->sge.addr);
+ if (ret)
+ return ret;
+
+ msg->sge.length = sp->max_recv_size;
+ msg->sge.lkey = sc->ib.pd->local_dma_lkey;
+
+ ret = ib_post_recv(sc->ib.qp, &recv_wr, NULL);
+ if (ret) {
+ smbdirect_log_rdma_recv(sc, SMBDIRECT_LOG_ERR,
+ "ib_post_recv failed ret=%d (%1pe)\n",
+ ret, SMBDIRECT_DEBUG_ERR_PTR(ret));
+ ib_dma_unmap_single(sc->ib.dev,
+ msg->sge.addr,
+ msg->sge.length,
+ DMA_FROM_DEVICE);
+ msg->sge.length = 0;
+ smbdirect_socket_schedule_cleanup(sc, ret);
+ }
+
+ return ret;
+}
+
static bool smbdirect_map_sges_single_page(struct smbdirect_map_sges *state,
struct page *page, size_t off, size_t len)
{