nvmet-fcloop: refactor fcloop_nport_alloc and track lport
authorDaniel Wagner <wagi@kernel.org>
Wed, 7 May 2025 12:22:59 +0000 (14:22 +0200)
committerChristoph Hellwig <hch@lst.de>
Tue, 20 May 2025 03:34:26 +0000 (05:34 +0200)
commitd54a9d7f6d74ee385d496f0efd282ce9d4fbfcbc
treec9b647ea84a2c30e95347a8fdd81737c898eedb5
parentb999efc8cf41420f9d9f8b08c111ad80e49b274e
nvmet-fcloop: refactor fcloop_nport_alloc and track lport

The checks for a valid input values are mixed with the logic to insert a
newly allocated nport. Refactor the function so that first the checks
are done.

This allows to untangle the setup steps into a more linear form which
reduces the complexity of the functions.

Also start tracking lport when a lport is assigned to a nport. This
ensures, that the lport is not going away as long it is still referenced
by a nport.

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