mirror of
https://github.com/torvalds/linux.git
synced 2026-05-23 06:31:58 +02:00
smb: client: call ib_dma_unmap_sg if mr->sgt.nents is not 0
This seems to be the more reliable way to check if we need to
call ib_dma_unmap_sg().
Fixes: c739858334 ("CIFS: SMBD: Implement RDMA memory registration")
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>
Signed-off-by: Steve French <stfrench@microsoft.com>
This commit is contained in:
parent
56c817e31a
commit
b9c0becc2f
|
|
@ -2365,9 +2365,8 @@ static void destroy_mr_list(struct smbdirect_socket *sc)
|
|||
spin_unlock_irqrestore(&sc->mr_io.all.lock, flags);
|
||||
|
||||
list_for_each_entry_safe(mr, tmp, &all_list, list) {
|
||||
if (mr->state == SMBDIRECT_MR_INVALIDATED)
|
||||
ib_dma_unmap_sg(sc->ib.dev, mr->sgt.sgl,
|
||||
mr->sgt.nents, mr->dir);
|
||||
if (mr->sgt.nents)
|
||||
ib_dma_unmap_sg(sc->ib.dev, mr->sgt.sgl, mr->sgt.nents, mr->dir);
|
||||
ib_dereg_mr(mr->mr);
|
||||
kfree(mr->sgt.sgl);
|
||||
list_del(&mr->list);
|
||||
|
|
@ -2589,6 +2588,7 @@ struct smbdirect_mr_io *smbd_register_mr(struct smbd_connection *info,
|
|||
ib_dma_unmap_sg(sc->ib.dev, mr->sgt.sgl, mr->sgt.nents, mr->dir);
|
||||
|
||||
dma_map_error:
|
||||
mr->sgt.nents = 0;
|
||||
mr->state = SMBDIRECT_MR_ERROR;
|
||||
if (atomic_dec_and_test(&sc->mr_io.used.count))
|
||||
wake_up(&sc->mr_io.cleanup.wait_queue);
|
||||
|
|
@ -2651,8 +2651,12 @@ void smbd_deregister_mr(struct smbdirect_mr_io *mr)
|
|||
*/
|
||||
mr->state = SMBDIRECT_MR_INVALIDATED;
|
||||
|
||||
if (mr->state == SMBDIRECT_MR_INVALIDATED) {
|
||||
if (mr->sgt.nents) {
|
||||
ib_dma_unmap_sg(sc->ib.dev, mr->sgt.sgl, mr->sgt.nents, mr->dir);
|
||||
mr->sgt.nents = 0;
|
||||
}
|
||||
|
||||
if (mr->state == SMBDIRECT_MR_INVALIDATED) {
|
||||
mr->state = SMBDIRECT_MR_READY;
|
||||
if (atomic_inc_return(&sc->mr_io.ready.count) == 1)
|
||||
wake_up(&sc->mr_io.ready.wait_queue);
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user