OSDN Git Service

nvme: unlink head after removing last namespace
authorKeith Busch <kbusch@kernel.org>
Thu, 9 Apr 2020 16:08:59 +0000 (09:08 -0700)
committerJens Axboe <axboe@kernel.dk>
Sat, 9 May 2020 22:18:35 +0000 (16:18 -0600)
commitd567572906d986dedb78b37f111c44eba033f3ef
treea47aac514da6bebf108d485090baac5a9b44bc5b
parentaec459b484b8356d6abe862428787d98ffb1cbde
nvme: unlink head after removing last namespace

The driver had been unlinking the namespace head from the subsystem's
list only after the last reference was released, and outside of the
list's subsys->lock protection.

There is no reason to track an empty head, so unlink the entry from the
subsystem's list when the last namespace using that head is removed and
with the mutex lock protecting the list update. The next namespace to
attach reusing the previous NSID will allocate a new head rather than
find the old head with mismatched identifiers.

Signed-off-by: Keith Busch <kbusch@kernel.org>
Reviewed-by: Sagi Grimberg <sagi@grimberg.me>
Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
drivers/nvme/host/core.c