From b183b7b9b51fc37cc8e1fbad3c0d84e0cb605266 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Tue, 21 Oct 2025 17:52:05 +0200 Subject: [PATCH] smb: smbdirect: introduce smbdirect_mr_io_fill_buffer_descriptor() This will be used by the client instead of dereferencing struct smbdirect_mr_io internals. Cc: Steve French Cc: Tom Talpey Cc: Long Li Cc: Namjae Jeon Cc: linux-cifs@vger.kernel.org Cc: samba-technical@lists.samba.org Signed-off-by: Stefan Metzmacher Acked-by: Namjae Jeon Signed-off-by: Steve French --- fs/smb/common/smbdirect/smbdirect_mr.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/fs/smb/common/smbdirect/smbdirect_mr.c b/fs/smb/common/smbdirect/smbdirect_mr.c index 249719c916a8..d5bf8531e237 100644 --- a/fs/smb/common/smbdirect/smbdirect_mr.c +++ b/fs/smb/common/smbdirect/smbdirect_mr.c @@ -452,6 +452,24 @@ smbdirect_connection_register_mr_io(struct smbdirect_socket *sc, mutex_unlock(&mr->mutex); return NULL; } + +__maybe_unused /* this is temporary while this file is included in others */ +static void smbdirect_mr_io_fill_buffer_descriptor(struct smbdirect_mr_io *mr, + struct smbdirect_buffer_descriptor_v1 *v1) +{ + mutex_lock(&mr->mutex); + if (mr->state == SMBDIRECT_MR_REGISTERED) { + v1->offset = cpu_to_le64(mr->mr->iova); + v1->token = cpu_to_le32(mr->mr->rkey); + v1->length = cpu_to_le32(mr->mr->length); + } else { + v1->offset = cpu_to_le64(U64_MAX); + v1->token = cpu_to_le32(U32_MAX); + v1->length = cpu_to_le32(U32_MAX); + } + mutex_unlock(&mr->mutex); +} + /* * Deregister a MR after I/O is done * This function may wait if remote invalidation is not used