mirror of
https://github.com/hardkernel/linux.git
synced 2026-04-02 03:03:00 +09:00
BACKPORT: FROMLIST: block: allow blk-zoned devices to have non-power-of-2 zone size
Checking if a given sector is aligned to a zone is a common operation that is performed for zoned devices. Add bdev_is_zone_start helper to check for this instead of opencoding it everywhere. Convert the calculations on zone size to be generic instead of relying on power-of-2(po2) based arithmetic in the block layer using the helpers wherever possible. The only hot path affected by this change for zoned devices with po2 zone size is in blk_check_zone_append() but bdev_is_zone_start() helper is used to optimize the calculation for po2 zone sizes. Finally, allow zoned devices with non po2 zone sizes provided that their zone capacity and zone size are equal. The main motivation to allow zoned devices with non po2 zone size is to remove the unmapped LBA between zone capcity and zone size for devices that cannot have a po2 zone capacity. Reviewed-by: Luis Chamberlain <mcgrof@kernel.org> Reviewed-by: Hannes Reinecke <hare@suse.de> Reviewed-by: Bart Van Assche <bvanassche@acm.org> Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com> Signed-off-by: Pankaj Raghav <p.raghav@samsung.com> Bug: 197782466 Bug: 269471019 Link: https://lore.kernel.org/linux-block/20220923173618.6899-4-p.raghav@samsung.com/ Change-Id: I2ecc186d7b14f5508b6abfe9821526d39a21d7e4 Signed-off-by: Bart Van Assche <bvanassche@google.com>
This commit is contained in:
committed by
Treehugger Robot
parent
39ae1728d8
commit
b37ecc177c
@@ -771,7 +771,7 @@ static inline blk_status_t blk_check_zone_append(struct request_queue *q,
|
||||
return BLK_STS_NOTSUPP;
|
||||
|
||||
/* The bio sector must point to the start of a sequential zone */
|
||||
if (pos & (blk_queue_zone_sectors(q) - 1) ||
|
||||
if (!bdev_is_zone_start(bio->bi_bdev, pos) ||
|
||||
!blk_queue_zone_is_seq(q, pos))
|
||||
return BLK_STS_IOERR;
|
||||
|
||||
|
||||
@@ -483,14 +483,26 @@ static int blk_revalidate_zone_cb(struct blk_zone *zone, unsigned int idx,
|
||||
* smaller last zone.
|
||||
*/
|
||||
if (zone->start == 0) {
|
||||
if (zone->len == 0 || !is_power_of_2(zone->len)) {
|
||||
pr_warn("%s: Invalid zoned device with non power of two zone size (%llu)\n",
|
||||
disk->disk_name, zone->len);
|
||||
if (zone->len == 0) {
|
||||
pr_warn("%s: Invalid zero zone size", disk->disk_name);
|
||||
return -ENODEV;
|
||||
}
|
||||
|
||||
/*
|
||||
* Non power-of-2 zone size support was added to remove the
|
||||
* gap between zone capacity and zone size. Though it is technically
|
||||
* possible to have gaps in a non power-of-2 device, Linux requires
|
||||
* the zone size to be equal to zone capacity for non power-of-2
|
||||
* zoned devices.
|
||||
*/
|
||||
if (!is_power_of_2(zone->len) && zone->capacity < zone->len) {
|
||||
pr_err("%s: Invalid zone capacity %lld with non power-of-2 zone size %lld",
|
||||
disk->disk_name, zone->capacity, zone->len);
|
||||
return -ENODEV;
|
||||
}
|
||||
|
||||
args->zone_sectors = zone->len;
|
||||
args->nr_zones = (capacity + zone->len - 1) >> ilog2(zone->len);
|
||||
args->nr_zones = div64_u64(capacity + zone->len - 1, zone->len);
|
||||
} else if (zone->start + args->zone_sectors < capacity) {
|
||||
if (zone->len != args->zone_sectors) {
|
||||
pr_warn("%s: Invalid zoned device with non constant zone size\n",
|
||||
|
||||
Reference in New Issue
Block a user