Skip to contentSkip to conversation

Does ib_dereg_mr require an additional IB_WR_LOCAL_INV?

DISCUSSION Stefan Metzmacher 2 participants 3 messages Sep 23, 2025 – Sep 25, 2025

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

Hi,

I'm trying to understand (and hopefully simplify) the code in fs/smb/client/smbdirect.c, related to 'struct ib_mr' cleanup on disconnect.

Assume we have the following sequence of calls:

...
ib_alloc_mr()
ib_dma_map_sg()
ib_map_mr_sg()
ib_post_send(IB_WR_REG_MR)

On cleanup we currently us something like this:

ib_drain_qp()
init_completion()
ib_post_send(IB_WR_LOCAL_INV)
wait_for_completion()...
ib_dereg_mr()
ib_drain_qp() // again
rdma_destroy_qp();
ib_destroy_cq(revc_cq)
ib_destroy_cq(send_cq)
ib_dealloc_pd()
rdma_destroy_id()

Now I'm wondering if the following is really required:
init_completion() ib_post_send(IB_WR_LOCAL_INV) wait_for_completion()...

It would make things much easier if not...

Thanks for any possible hint :-)
metze

#1 lore raw
Quoted 27 lines · Stefan Metzmacher

Hi,

I'm trying to understand (and hopefully simplify) the code in fs/smb/client/smbdirect.c, related to 'struct ib_mr' cleanup on disconnect.

Assume we have the following sequence of calls:

...
ib_alloc_mr()
ib_dma_map_sg()
ib_map_mr_sg()
ib_post_send(IB_WR_REG_MR)

On cleanup we currently us something like this:

ib_drain_qp()
init_completion()
ib_post_send(IB_WR_LOCAL_INV)
wait_for_completion()...
ib_dereg_mr()
ib_drain_qp() // again
rdma_destroy_qp();
ib_destroy_cq(revc_cq)
ib_destroy_cq(send_cq)
ib_dealloc_pd()
rdma_destroy_id()

Quoted 4 lines

Now I'm wondering if the following is really required:
init_completion() ib_post_send(IB_WR_LOCAL_INV) wait_for_completion()...

I would say IB_WR_LOCAL_INV is redundent with the ib_dereg_mr(). There is no need to invalidate something that will be de-registered in a few moments.

Jason

#2 lore raw

Am 24.09.25 um 17:10 schrieb Jason Gunthorpe:

Quoted 28 lines · Stefan Metzmacher
Quoted 27 lines

Hi,

I'm trying to understand (and hopefully simplify) the code in fs/smb/client/smbdirect.c, related to 'struct ib_mr' cleanup on disconnect.

Assume we have the following sequence of calls:

...
ib_alloc_mr()
ib_dma_map_sg()
ib_map_mr_sg()
ib_post_send(IB_WR_REG_MR)

On cleanup we currently us something like this:

ib_drain_qp()
init_completion()
ib_post_send(IB_WR_LOCAL_INV)
wait_for_completion()...
ib_dereg_mr()
ib_drain_qp() // again
rdma_destroy_qp();
ib_destroy_cq(revc_cq)
ib_destroy_cq(send_cq)
ib_dealloc_pd()
rdma_destroy_id()

Quoted 8 lines
Quoted 4 lines

Now I'm wondering if the following is really required:
init_completion() ib_post_send(IB_WR_LOCAL_INV) wait_for_completion()...

I would say IB_WR_LOCAL_INV is redundent with the ib_dereg_mr(). There is no need to invalidate something that will be de-registered in a few moments.

Thanks!