Commit 4450ba3b authored by Christoph Hellwig's avatar Christoph Hellwig Committed by Jens Axboe

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: default avatarChristoph Hellwig <hch@lst.de>
Reviewed-by: default avatarKeith Busch <kbusch@kernel.org>
Reviewed-by: default avatarSagi Grimberg <sagi@grimberg.me>
Signed-off-by: default avatarJens Axboe <axboe@kernel.dk>
parent 25dcaa92
...@@ -3699,6 +3699,16 @@ static void nvme_ns_remove(struct nvme_ns *ns) ...@@ -3699,6 +3699,16 @@ static void nvme_ns_remove(struct nvme_ns *ns)
nvme_put_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) static void nvme_validate_ns(struct nvme_ctrl *ctrl, unsigned nsid)
{ {
struct nvme_ns *ns; struct nvme_ns *ns;
...@@ -3732,7 +3742,6 @@ static void nvme_remove_invalid_namespaces(struct nvme_ctrl *ctrl, ...@@ -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) static int nvme_scan_ns_list(struct nvme_ctrl *ctrl, unsigned nn)
{ {
struct nvme_ns *ns;
__le32 *ns_list; __le32 *ns_list;
unsigned i, j, nsid, prev = 0; unsigned i, j, nsid, prev = 0;
unsigned num_lists = DIV_ROUND_UP_ULL((u64)nn, 1024); 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) ...@@ -3757,13 +3766,8 @@ static int nvme_scan_ns_list(struct nvme_ctrl *ctrl, unsigned nn)
nvme_validate_ns(ctrl, nsid); nvme_validate_ns(ctrl, nsid);
while (++prev < nsid) { while (++prev < nsid)
ns = nvme_find_get_ns(ctrl, prev); nvme_ns_remove_by_nsid(ctrl, prev);
if (ns) {
nvme_ns_remove(ns);
nvme_put_ns(ns);
}
}
} }
nn -= j; nn -= j;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment