hw/block/nvme: error if drive less than a zone size
PATCH 1/1 hw/block/nvme: error if drive less than a zone size
If a user gives backing device file less than a single zone size, the namespace capacity will be reported to 0 and the kerenl will fail to allocate namespace silently.
This patch errors in case that num_zones are 0 which is backing device is less than a single zone size.
Signed-off-by Minwoo Im <[email protected]>
--- hw/block/nvme-ns.c | 7 +++++++ 1 file changed, 7 insertions(+)
hw/block/nvme-ns.c +7 -0
@@ -137,6 +137,13 @@ static int nvme_ns_zoned_check_calc_geometry(NvmeNamespace *ns, Error **errp) ns->num_zones = ns->size / lbasz / ns->zone_size;/* Do a few more sanity checks of ZNS properties */ +if (!ns->num_zones) { +error_setg (errp, +"num_zone is 0, drive must be larger than a zone %luB" , + zone_size); +return -1 ; + } +if (ns->params.max_open_zones > ns->num_zones) { error_setg(errp, "max_open_zones value %u exceeds the number of zones %u",
Signature · 1 line
2.17.1