mirror of
https://github.com/torvalds/linux.git
synced 2024-12-19 09:32:32 +00:00
nvme: clean up nvme_scan_work
Move the check for the supported CNS value into nvme_scan_ns_list, and limit the life time of the identify controller allocation. 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>
This commit is contained in:
parent
b9a5c3d4c3
commit
25dcaa9292
@ -3738,6 +3738,9 @@ static int nvme_scan_ns_list(struct nvme_ctrl *ctrl, unsigned nn)
|
|||||||
unsigned num_lists = DIV_ROUND_UP_ULL((u64)nn, 1024);
|
unsigned num_lists = DIV_ROUND_UP_ULL((u64)nn, 1024);
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
|
|
||||||
|
if (nvme_ctrl_limited_cns(ctrl))
|
||||||
|
return -EOPNOTSUPP;
|
||||||
|
|
||||||
ns_list = kzalloc(NVME_IDENTIFY_DATA_SIZE, GFP_KERNEL);
|
ns_list = kzalloc(NVME_IDENTIFY_DATA_SIZE, GFP_KERNEL);
|
||||||
if (!ns_list)
|
if (!ns_list)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
@ -3824,17 +3827,14 @@ static void nvme_scan_work(struct work_struct *work)
|
|||||||
|
|
||||||
if (nvme_identify_ctrl(ctrl, &id))
|
if (nvme_identify_ctrl(ctrl, &id))
|
||||||
return;
|
return;
|
||||||
|
nn = le32_to_cpu(id->nn);
|
||||||
|
kfree(id);
|
||||||
|
|
||||||
mutex_lock(&ctrl->scan_lock);
|
mutex_lock(&ctrl->scan_lock);
|
||||||
nn = le32_to_cpu(id->nn);
|
if (nvme_scan_ns_list(ctrl, nn) != 0)
|
||||||
if (!nvme_ctrl_limited_cns(ctrl)) {
|
|
||||||
if (!nvme_scan_ns_list(ctrl, nn))
|
|
||||||
goto out_free_id;
|
|
||||||
}
|
|
||||||
nvme_scan_ns_sequential(ctrl, nn);
|
nvme_scan_ns_sequential(ctrl, nn);
|
||||||
out_free_id:
|
|
||||||
mutex_unlock(&ctrl->scan_lock);
|
mutex_unlock(&ctrl->scan_lock);
|
||||||
kfree(id);
|
|
||||||
down_write(&ctrl->namespaces_rwsem);
|
down_write(&ctrl->namespaces_rwsem);
|
||||||
list_sort(NULL, &ctrl->namespaces, ns_cmp);
|
list_sort(NULL, &ctrl->namespaces, ns_cmp);
|
||||||
up_write(&ctrl->namespaces_rwsem);
|
up_write(&ctrl->namespaces_rwsem);
|
||||||
|
Loading…
Reference in New Issue
Block a user