diff options
| author | Daniel Wagner <wagi@kernel.org> | 2025-05-07 14:22:58 +0200 |
|---|---|---|
| committer | Christoph Hellwig <hch@lst.de> | 2025-05-20 05:34:26 +0200 |
| commit | b999efc8cf41420f9d9f8b08c111ad80e49b274e (patch) | |
| tree | daa380a83a409033aadf07aca2c95624a9e57f13 | |
| parent | d6c40d87e7fed4b10f2fe93c90487145e2622ebf (diff) | |
| download | linux-b999efc8cf41420f9d9f8b08c111ad80e49b274e.tar.gz linux-b999efc8cf41420f9d9f8b08c111ad80e49b274e.zip | |
nvmet-fcloop: remove nport from list on last user
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>
| -rw-r--r-- | drivers/nvme/target/fcloop.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/drivers/nvme/target/fcloop.c b/drivers/nvme/target/fcloop.c index a0828626db07..7763b8bf098d 100644 --- a/drivers/nvme/target/fcloop.c +++ b/drivers/nvme/target/fcloop.c @@ -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; } |
