* [PATCH for stable] smb: client/smbdirect: fix MR registration for coalesced SG lists
@ 2026-05-08 8:15 Stefan Metzmacher
2026-05-09 12:47 ` Sasha Levin
0 siblings, 1 reply; 3+ messages in thread
From: Stefan Metzmacher @ 2026-05-08 8:15 UTC (permalink / raw)
To: stable
Cc: metze, linux-cifs, samba-technical, Yi Kuo, Namjae Jeon,
Steve French
From: Yi Kuo <yi@yikuo.dev>
commit 9900b9fee5a0e0f72d7c744b37c7c851d5785ac6 upstream.
The stable backport to < 7.1 a different file gets the
fix. Also the Fixes tag below is adjusted for the old code path.
ib_dma_map_sg() modifies the provided scatterlist and returns the
number of mapped entries, which can be fewer than the requested
mr->sgt.nents if the DMA controller coalesces contiguous memory
segments. Passing the original, uncoalesced count to ib_map_mr_sg()
causes memory registration failures if coalescing actually occurs.
Capture the actual mapped count returned by ib_dma_map_sg() and pass it
to ib_map_mr_sg() to ensure correct MR registration.
Also update the ib_dma_map_sg() error logging to drop the error
pointer formatting, since the return value is an integer count
rather than an error code.
Ensure a proper error code (-EIO) is assigned when DMA mapping or
MR registration fails.
Fixes: c7398583340a ("CIFS: SMBD: Implement RDMA memory registration")
Closes: https://bugzilla.kernel.org/show_bug.cgi?id=221408
Reviewed-by: Stefan Metzmacher <metze@samba.org>
Acked-by: Namjae Jeon <linkinjeon@kernel.org>
Signed-off-by: Yi Kuo <yi@yikuo.dev>
Signed-off-by: Steve French <stfrench@microsoft.com>
Cc: stable@vger.kernel.org
Signed-off-by: Stefan Metzmacher <metze@samba.org>
---
fs/smb/client/smbdirect.c | 21 ++++++++++++---------
1 file changed, 12 insertions(+), 9 deletions(-)
diff --git a/fs/smb/client/smbdirect.c b/fs/smb/client/smbdirect.c
index 461658105013..d0fcc7779415 100644
--- a/fs/smb/client/smbdirect.c
+++ b/fs/smb/client/smbdirect.c
@@ -2920,7 +2920,7 @@ struct smbdirect_mr_io *smbd_register_mr(struct smbd_connection *info,
struct smbdirect_socket *sc = &info->socket;
struct smbdirect_socket_parameters *sp = &sc->parameters;
struct smbdirect_mr_io *mr;
- int rc, num_pages;
+ int rc, num_pages, num_mapped;
struct ib_reg_wr *reg_wr;
num_pages = iov_iter_npages(iter, sp->max_frmr_depth + 1);
@@ -2948,18 +2948,21 @@ struct smbdirect_mr_io *smbd_register_mr(struct smbd_connection *info,
num_pages, iov_iter_count(iter), sp->max_frmr_depth);
smbd_iter_to_mr(iter, &mr->sgt, sp->max_frmr_depth);
- rc = ib_dma_map_sg(sc->ib.dev, mr->sgt.sgl, mr->sgt.nents, mr->dir);
- if (!rc) {
- log_rdma_mr(ERR, "ib_dma_map_sg num_pages=%x dir=%x rc=%x\n",
- num_pages, mr->dir, rc);
+ num_mapped = ib_dma_map_sg(sc->ib.dev, mr->sgt.sgl, mr->sgt.nents, mr->dir);
+ if (!num_mapped) {
+ log_rdma_mr(ERR, "ib_dma_map_sg num_pages=%x dir=%x num_mapped=%x\n",
+ num_pages, mr->dir, num_mapped);
+ rc = -EIO;
goto dma_map_error;
}
- rc = ib_map_mr_sg(mr->mr, mr->sgt.sgl, mr->sgt.nents, NULL, PAGE_SIZE);
- if (rc != mr->sgt.nents) {
+ rc = ib_map_mr_sg(mr->mr, mr->sgt.sgl, num_mapped, NULL, PAGE_SIZE);
+ if (rc != num_mapped) {
log_rdma_mr(ERR,
- "ib_map_mr_sg failed rc = %d nents = %x\n",
- rc, mr->sgt.nents);
+ "ib_map_mr_sg failed rc = %d num_mapped = %x\n",
+ rc, num_mapped);
+ if (rc >= 0)
+ rc = -EIO;
goto map_mr_error;
}
--
2.43.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH for stable] smb: client/smbdirect: fix MR registration for coalesced SG lists
2026-05-08 8:15 [PATCH for stable] smb: client/smbdirect: fix MR registration for coalesced SG lists Stefan Metzmacher
@ 2026-05-09 12:47 ` Sasha Levin
2026-05-10 11:05 ` Stefan Metzmacher
0 siblings, 1 reply; 3+ messages in thread
From: Sasha Levin @ 2026-05-09 12:47 UTC (permalink / raw)
To: stable
Cc: Sasha Levin, metze, linux-cifs, samba-technical, Yi Kuo,
Namjae Jeon, Steve French
> [PATCH for stable] smb: client/smbdirect: fix MR registration for coalesced SG lists
Queued for 7.0.y and 6.18.y, thanks.
The Fixes commit c7398583340a is also present on 6.12/6.6/6.1, but the
patch you sent uses the post-rename mr->sgt/.../mr-> field names that
match 7.0/6.18; on 6.12/6.6 the same code uses smbdirect_mr->... and
6.1 has yet another older variant. Could you send adapted backports
for 6.12.y, 6.6.y and 6.1.y (or let me know if you'd like me to skip
those branches)?
--
Sasha
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH for stable] smb: client/smbdirect: fix MR registration for coalesced SG lists
2026-05-09 12:47 ` Sasha Levin
@ 2026-05-10 11:05 ` Stefan Metzmacher
0 siblings, 0 replies; 3+ messages in thread
From: Stefan Metzmacher @ 2026-05-10 11:05 UTC (permalink / raw)
To: Sasha Levin, stable
Cc: linux-cifs, samba-technical, Yi Kuo, Namjae Jeon, Steve French
Am 09.05.26 um 14:47 schrieb Sasha Levin:
>> [PATCH for stable] smb: client/smbdirect: fix MR registration for coalesced SG lists
>
> Queued for 7.0.y and 6.18.y, thanks.
>
> The Fixes commit c7398583340a is also present on 6.12/6.6/6.1, but the
> patch you sent uses the post-rename mr->sgt/.../mr-> field names that
> match 7.0/6.18; on 6.12/6.6 the same code uses smbdirect_mr->... and
> 6.1 has yet another older variant. Could you send adapted backports
> for 6.12.y, 6.6.y and 6.1.y (or let me know if you'd like me to skip
> those branches)?
https://bugzilla.kernel.org/show_bug.cgi?id=221408 talks
about 6.17, so I guess we can skip older branches.
Thanks!
metze
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-05-10 11:05 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-05-08 8:15 [PATCH for stable] smb: client/smbdirect: fix MR registration for coalesced SG lists Stefan Metzmacher
2026-05-09 12:47 ` Sasha Levin
2026-05-10 11:05 ` Stefan Metzmacher
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox