]> www.infradead.org Git - users/hch/misc.git/commitdiff
smb: client: let destroy_mr_list() remove locked from the list
authorStefan Metzmacher <metze@samba.org>
Sun, 12 Oct 2025 19:10:24 +0000 (21:10 +0200)
committerSteve French <stfrench@microsoft.com>
Mon, 13 Oct 2025 13:26:22 +0000 (08:26 -0500)
This should make sure get_mr() can't see the removed entries.

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>
fs/smb/client/smbdirect.c

index b7be67dacd098ea3fc3abdc315402ab2f3bfe776..b974ca4e0b2e0bb6669a6f2e34bfad23e6f9586d 100644 (file)
@@ -2355,9 +2355,16 @@ static void smbd_mr_recovery_work(struct work_struct *work)
 static void destroy_mr_list(struct smbdirect_socket *sc)
 {
        struct smbdirect_mr_io *mr, *tmp;
+       LIST_HEAD(all_list);
+       unsigned long flags;
 
        disable_work_sync(&sc->mr_io.recovery_work);
-       list_for_each_entry_safe(mr, tmp, &sc->mr_io.all.list, list) {
+
+       spin_lock_irqsave(&sc->mr_io.all.lock, flags);
+       list_splice_tail_init(&sc->mr_io.all.list, &all_list);
+       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);