diff options
author | 2020-09-28 12:34:04 +0200 | |
---|---|---|
committer | 2020-10-07 07:56:18 +0200 | |
commit | fab72f5a046883ae5851c95b7c6e7a08f984e391 (patch) | |
tree | 29a4d6a5d5f47c4b70bdf084aa39f75f3fcfd028 | |
parent | nvme: lift the check for an unallocated namespace into nvme_identify_ns (diff) | |
download | linux-fab72f5a046883ae5851c95b7c6e7a08f984e391.tar.gz linux-fab72f5a046883ae5851c95b7c6e7a08f984e391.tar.bz2 linux-fab72f5a046883ae5851c95b7c6e7a08f984e391.zip |
nvme: call nvme_identify_ns as the first thing in nvme_alloc_ns_block
Check if the namespace actually exists as the very first thing and don't
bother with any extra work if not. This should speed up and simplify
the sequential scanning for NVMe 1.0 devices.
Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Keith Busch <kbusch@kernel.org>
Reviewed-by: Chaitanya Kulkarni <chaitanya.kulkarni@wdc.com>
Reviewed-by: Damien Le Moal <damien.lemoal@wdc.com>
-rw-r--r-- | drivers/nvme/host/core.c | 15 |
1 files changed, 7 insertions, 8 deletions
diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c index 7b1423c7e7fc..4a5c4d45755b 100644 --- a/drivers/nvme/host/core.c +++ b/drivers/nvme/host/core.c @@ -3887,9 +3887,12 @@ static void nvme_alloc_ns(struct nvme_ctrl *ctrl, unsigned nsid) char disk_name[DISK_NAME_LEN]; int node = ctrl->numa_node, flags = GENHD_FL_EXT_DEVT, ret; + if (nvme_identify_ns(ctrl, nsid, &id)) + return; + ns = kzalloc_node(sizeof(*ns), GFP_KERNEL, node); if (!ns) - return; + goto out_free_id; ns->queue = blk_mq_init_queue(ctrl->tagset); if (IS_ERR(ns->queue)) @@ -3911,13 +3914,9 @@ static void nvme_alloc_ns(struct nvme_ctrl *ctrl, unsigned nsid) blk_queue_logical_block_size(ns->queue, 1 << ns->lba_shift); nvme_set_queue_limits(ctrl, ns->queue); - ret = nvme_identify_ns(ctrl, nsid, &id); - if (ret) - goto out_free_queue; - ret = nvme_init_ns_head(ns, nsid, id); if (ret) - goto out_free_id; + goto out_free_queue; nvme_set_disk_name(disk_name, ns, ctrl, &flags); disk = alloc_disk_node(0, node); @@ -3968,12 +3967,12 @@ static void nvme_alloc_ns(struct nvme_ctrl *ctrl, unsigned nsid) list_del_init(&ns->head->entry); mutex_unlock(&ctrl->subsys->lock); nvme_put_ns_head(ns->head); - out_free_id: - kfree(id); out_free_queue: blk_cleanup_queue(ns->queue); out_free_ns: kfree(ns); + out_free_id: + kfree(id); } static void nvme_ns_remove(struct nvme_ns *ns) |