>> + >> + if (is_power_of_2(zone_size)) >> + DMWARN("%pg: underlying device has a power-of-2 number of sectors per zone", >> + dmh->dev->bdev); >> + >> + dmh->zone_size = zone_size; >> + dmh->zone_size_po2 = 1 << get_count_order_long(zone_size); >> + dmh->zone_size_po2_shift = ilog2(dmh->zone_size_po2); >> + dmh->zone_size_diff = dmh->zone_size_po2 - dmh->zone_size; >> + ti->private = dmh; >> + ti->max_io_len = dmh->zone_size_po2; >> + dmh->nr_zones = npo2_zone_no(dmh, ti->len); >> + ti->len = dmh->zone_size_po2 * dmh->nr_zones; >> + >> + return 0; >> +} > > The above error paths need to unwind the references or any other > resources acquired before failing. Please see other targets for how > they handle sequencing of the needed operations (e.g. dm_put_device) > in the error path by using gotos, etc. > Ok. That makes sense, and it should be pretty straight forward to do that. >> + >> +static void dm_po2z_io_hints(struct dm_target *ti, struct queue_limits *limits) >> +{ >> + struct dm_po2z_target *dmh = ti->private; >> + >> + limits->chunk_sectors = dmh->zone_size_po2; >> +} > > Are you certain you shouldn't at least be exposing a different > logical_block_size to upper layers? > To be honest, I tested my patches in QEMU with 4k Logical block size and on a device with 4k LBA size. I did a quick test with 512B LBA size in QEMU, and I didn't see any failures when I ran my normal test suite. Do you see any problem with exposing the same LBA as the underlying device? >> + >> +static void dm_po2z_status(struct dm_target *ti, status_type_t type, >> + unsigned int status_flags, char *result, >> + unsigned int maxlen) >> +{ >> + struct dm_po2z_target *dmh = ti->private; >> + size_t sz = 0; >> + >> + switch (type) { >> + case STATUSTYPE_INFO: >> + DMEMIT("%s %lld", dmh->dev->name, >> + (unsigned long long)dmh->zone_size_po2); >> + break; > > Wouldn't it be worthwhile to expose the zone sectors (native npo2 vs > simulated po2?) You merely roundup but never expose what you're using > (unless I'm missing something about generic "zoned" device > capabilities). > BLKREPORTZONE ioctl is typically used to get the zone information from a zoned block device, which should expose the npo2 zone sectors(zone capacity) in this case. But I do see the value of exposing the dmh->zone_size instead of dmh->zone_size_po2 as the latter can be easily calculated from the former or it can be retrieved by reading the chunk_sectors. I will fix that up. > Mike >