[PATCH 01/11] nvmet-fcloop: remove nport from list on last user

Daniel Wagner posted 11 patches 11 months, 2 weeks ago
There is a newer version of this series
[PATCH 01/11] nvmet-fcloop: remove nport from list on last user
Posted by Daniel Wagner 11 months, 2 weeks ago
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>
---
 drivers/nvme/target/fcloop.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/drivers/nvme/target/fcloop.c b/drivers/nvme/target/fcloop.c
index e1abb27927ff74c9c55ddefd9581aab18bf3b00f..5493677a948d34391c7c08055dfefd91cc3ff33f 100644
--- a/drivers/nvme/target/fcloop.c
+++ b/drivers/nvme/target/fcloop.c
@@ -1005,6 +1005,11 @@ fcloop_nport_free(struct kref *ref)
 {
 	struct fcloop_nport *nport =
 		container_of(ref, struct fcloop_nport, ref);
+	unsigned long flags;
+
+	spin_lock_irqsave(&fcloop_lock, flags);
+	list_del(&nport->nport_list);
+	spin_unlock_irqrestore(&fcloop_lock, flags);
 
 	kfree(nport);
 }
@@ -1363,8 +1368,6 @@ __unlink_remote_port(struct fcloop_nport *nport)
 		nport->tport->remoteport = NULL;
 	nport->rport = NULL;
 
-	list_del(&nport->nport_list);
-
 	return rport;
 }
 

-- 
2.48.1
Re: [PATCH 01/11] nvmet-fcloop: remove nport from list on last user
Posted by Christoph Hellwig 11 months, 1 week ago
Looks good:

Reviewed-by: Christoph Hellwig <hch@lst.de>
Re: [PATCH 01/11] nvmet-fcloop: remove nport from list on last user
Posted by Hannes Reinecke 11 months, 2 weeks ago
On 2/26/25 19:45, Daniel Wagner wrote:
> 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>
> ---
>   drivers/nvme/target/fcloop.c | 7 +++++--
>   1 file changed, 5 insertions(+), 2 deletions(-)
> 
Reviewed-by: Hannes Reinecke <hare@suse.de>

Cheers,

Hannes
-- 
Dr. Hannes Reinecke                  Kernel Storage Architect
hare@suse.de                                +49 911 74053 688
SUSE Software Solutions GmbH, Frankenstr. 146, 90461 Nürnberg
HRB 36809 (AG Nürnberg), GF: I. Totev, A. McDonald, W. Knoblich