[PATCH 2/2] nvme: do not detach nshead when a namespace is removed

Sagi Grimberg sagi at grimberg.me
Thu Apr 1 00:49:32 BST 2021


> 'struct nshead' and 'struct ns' have different lifetimes; the nshead
> can (and occasionally will) stay around even if no namespaces are
> connected, as it will only be finally removed once the last
> reference is gone.
> But while it is in this state we should still be able to access
> it during lookup; a nshead with no controllers is perfectly valid
> (at least for fabrics), and the namespace has no business with
> removing the nshead from the subsystem lists.
> 
> This patch fixes the situation by only removing the nshead from the
> subsystem list once it's being finally removed.

Hannes, please explain what is the bug you are solving here.

I actually think that the nshead should be removed from the
list as soon as the last the head->list is empty.

What if for example a new ns is allocated on the subsystem
and the nsid (which was already deleted) is reused, it will now
be rejected when we match against existing nsheads which will
contain this stale nshead that happens to have an open reference.



More information about the Linux-nvme mailing list