On 2022-03-09 04:44, Damien Le Moal wrote: > On 3/9/22 01:53, Pankaj Raghav wrote: >> >> ns->zsze = nvme_lba_to_sect(ns, le64_to_cpu(id->lbafe[lbaf].zsze)); >> - if (!is_power_of_2(ns->zsze)) { >> - dev_warn(ns->ctrl->device, >> - "invalid zone size:%llu for namespace:%u\n", >> - ns->zsze, ns->head->ns_id); >> - status = -ENODEV; >> - goto free_data; >> - } > > Doing this will allow a non power of 2 zone sized device to be seen by > the block layer. This will break functions such as blkdev_nr_zones() but > this patch is not changing this functions, and other using bit shift > calculations. > The goal of this patchset was to emulate a po2 zone size for a npo2 device to the block layer. If you see the `npo2_zone_setup` callback in the NVMe driver (patch 4/6), we do the following: ``` + ns->zsze_po2 = 1 << get_count_order_long(ns->zsze); + capacity = nr_zones * ns->zsze_po2; + set_capacity_and_notify(ns->disk, capacity); ``` So we adapt the capacity of the disk based on the po2 zone size. The chunk sectors are also set to this new po2 zone size. Therefore, all the block layer functions will continue to work as the block layer sees the zone size of the device to be ns->zsze_po2 and not the actual device zone size which is ns->zsze. Changing the functions such blkdev_nr_zones that uses po2 calculation will/should be dealt separately if decide to relax the po2 constraint in the block layer. -- Regards, Pankaj