[PATCH v6 01/14] nvmet-fcloop: track ref counts for nports
Daniel Wagner
dwagner at suse.de
Thu May 8 03:06:46 PDT 2025
On Wed, May 07, 2025 at 03:50:30PM +0200, Hannes Reinecke wrote:
> > + spin_lock_irqsave(&fcloop_lock, flags);
> > + tport = __unlink_target_port(nport);
> > spin_unlock_irqrestore(&fcloop_lock, flags);
> > - if (!nport)
> > - return -ENOENT;
> > + if (!tport) {
> > + ret = -ENOENT;
> > + goto out_nport_put;
> > + }
> > ret = __targetport_unreg(nport, tport);
>
> The lock needs to extend across both lookup and unlink,
> ie don't drop the lock in between.
No, this wont wor. There will be a nested lock in
nvmet_fc_unregister_targetport. The lock only protects the list
insert/delete/iterate operations not anything else.
FWIW, this is hasn't changed the unregister step was already done uside
the lock.
BTW, I've played with turning the spin lock into a mutex as there
doesn't seem to be any necessity to use a spin lock then we could in
theory keep the lock over the whole section but this is something I
would leave for the future.
More information about the Linux-nvme
mailing list