Commit d8ca66e8 authored by Christoph Hellwig's avatar Christoph Hellwig

nvme: move the CSI sanity check into nvme_ns_report_zones

Move the CSI check into nvme_ns_report_zones to clean up the code
a little bit and prepare for further refactoring.
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>
parent 85b790a7
...@@ -180,6 +180,9 @@ static int nvme_ns_report_zones(struct nvme_ns *ns, sector_t sector, ...@@ -180,6 +180,9 @@ static int nvme_ns_report_zones(struct nvme_ns *ns, sector_t sector,
unsigned int nz, i; unsigned int nz, i;
size_t buflen; size_t buflen;
if (ns->head->ids.csi != NVME_CSI_ZNS)
return -EINVAL;
report = nvme_zns_alloc_report_buffer(ns, nr_zones, &buflen); report = nvme_zns_alloc_report_buffer(ns, nr_zones, &buflen);
if (!report) if (!report)
return -ENOMEM; return -ENOMEM;
...@@ -237,11 +240,7 @@ int nvme_report_zones(struct gendisk *disk, sector_t sector, ...@@ -237,11 +240,7 @@ int nvme_report_zones(struct gendisk *disk, sector_t sector,
ns = nvme_get_ns_from_disk(disk, &head, &srcu_idx); ns = nvme_get_ns_from_disk(disk, &head, &srcu_idx);
if (unlikely(!ns)) if (unlikely(!ns))
return -EWOULDBLOCK; return -EWOULDBLOCK;
ret = nvme_ns_report_zones(ns, sector, nr_zones, cb, data);
if (ns->head->ids.csi == NVME_CSI_ZNS)
ret = nvme_ns_report_zones(ns, sector, nr_zones, cb, data);
else
ret = -EINVAL;
nvme_put_ns_from_disk(head, srcu_idx); nvme_put_ns_from_disk(head, srcu_idx);
return ret; return ret;
......
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