]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
nvmet-fcloop: remove nport from list on last user
authorDaniel Wagner <wagi@kernel.org>
Wed, 7 May 2025 12:22:58 +0000 (14:22 +0200)
committerChristoph Hellwig <hch@lst.de>
Tue, 20 May 2025 03:34:26 +0000 (05:34 +0200)
The nport object has an association with the rport and lport object,
that means we can only remove an nport object from the global nport_list
after the last user of an rport or lport is gone.

Signed-off-by: Daniel Wagner <wagi@kernel.org>
Reviewed-by: Hannes Reinecke <hare@suse.de>
Signed-off-by: Christoph Hellwig <hch@lst.de>
drivers/nvme/target/fcloop.c

index a0828626db072b2474e5653cc07674839dc34da3..7763b8bf098deedb822d703375e63b125cf83103 100644 (file)
@@ -1019,9 +1019,15 @@ fcloop_lport_get(struct fcloop_lport *lport)
 static void
 fcloop_nport_put(struct fcloop_nport *nport)
 {
+       unsigned long flags;
+
        if (!refcount_dec_and_test(&nport->ref))
                return;
 
+       spin_lock_irqsave(&fcloop_lock, flags);
+       list_del(&nport->nport_list);
+       spin_unlock_irqrestore(&fcloop_lock, flags);
+
        kfree(nport);
 }
 
@@ -1414,8 +1420,6 @@ __unlink_remote_port(struct fcloop_nport *nport)
                nport->tport->remoteport = NULL;
        nport->rport = NULL;
 
-       list_del(&nport->nport_list);
-
        return rport;
 }