diff options
author | Christoph Hellwig <hch@lst.de> | 2020-04-04 10:30:32 +0200 |
---|---|---|
committer | Jens Axboe <axboe@kernel.dk> | 2020-05-10 00:18:35 +0200 |
commit | 4450ba3bbb47d5fe852b730ab6773d2c18cfbfd6 (patch) | |
tree | 002fd6cee60f1d055ff05c620b6054400e70aa30 /drivers/nvme | |
parent | nvme: clean up nvme_scan_work (diff) | |
download | linux-4450ba3bbb47d5fe852b730ab6773d2c18cfbfd6.tar.xz linux-4450ba3bbb47d5fe852b730ab6773d2c18cfbfd6.zip |
nvme: factor out a nvme_ns_remove_by_nsid helper
Factor out a piece of deeply indented and logicaly separate code
from nvme_scan_ns_list into a new helper.
Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Keith Busch <kbusch@kernel.org>
Reviewed-by: Sagi Grimberg <sagi@grimberg.me>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Diffstat (limited to 'drivers/nvme')
-rw-r--r-- | drivers/nvme/host/core.c | 20 |
1 files changed, 12 insertions, 8 deletions
diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c index 025a8a6d81c7..42102b81d540 100644 --- a/drivers/nvme/host/core.c +++ b/drivers/nvme/host/core.c @@ -3699,6 +3699,16 @@ static void nvme_ns_remove(struct nvme_ns *ns) nvme_put_ns(ns); } +static void nvme_ns_remove_by_nsid(struct nvme_ctrl *ctrl, u32 nsid) +{ + struct nvme_ns *ns = nvme_find_get_ns(ctrl, nsid); + + if (ns) { + nvme_ns_remove(ns); + nvme_put_ns(ns); + } +} + static void nvme_validate_ns(struct nvme_ctrl *ctrl, unsigned nsid) { struct nvme_ns *ns; @@ -3732,7 +3742,6 @@ static void nvme_remove_invalid_namespaces(struct nvme_ctrl *ctrl, static int nvme_scan_ns_list(struct nvme_ctrl *ctrl, unsigned nn) { - struct nvme_ns *ns; __le32 *ns_list; unsigned i, j, nsid, prev = 0; unsigned num_lists = DIV_ROUND_UP_ULL((u64)nn, 1024); @@ -3757,13 +3766,8 @@ static int nvme_scan_ns_list(struct nvme_ctrl *ctrl, unsigned nn) nvme_validate_ns(ctrl, nsid); - while (++prev < nsid) { - ns = nvme_find_get_ns(ctrl, prev); - if (ns) { - nvme_ns_remove(ns); - nvme_put_ns(ns); - } - } + while (++prev < nsid) + nvme_ns_remove_by_nsid(ctrl, prev); } nn -= j; } |