]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/commit - block/partition-generic.c
block: Check partition alignment on zoned block devices
authorDamien Le Moal <damien.lemoal@wdc.com>
Thu, 1 Dec 2016 07:00:25 +0000 (16:00 +0900)
committerJens Axboe <axboe@fb.com>
Thu, 1 Dec 2016 14:56:53 +0000 (07:56 -0700)
commitb02d8aaea12463f573c5ef485c638ab12628dc5e
treef9f27e54550b528a091cd6df50d87badc6de19b8
parent333ba053d145d6f9152f6b0311a345b876f0fed1
block: Check partition alignment on zoned block devices

Both blkdev_report_zones and blkdev_reset_zones can operate on a partition of
a zoned block device. However, the first and last zones reported for a
partition make sense only if the partition start sector and size are aligned
on the device zone size. The same applies for zone reset. Resetting the first
or the last zone of a partition straddling zones may impact neighboring
partitions. Finally, if a partition start sector is not at the beginning of a
sequential zone, it will be impossible to write to the first sectors of the
partition on a host-managed device.
Avoid all these problems and incoherencies by ignoring partitions that are not
zone aligned.

Note: Even with CONFIG_BLK_DEV_ZONED disabled, bdev_is_zoned() will report the
correct disk zoning type (host-aware, host-managed or none) but
bdev_zone_size() will always return 0 for zoned block devices (i.e. the zone
size is unknown). So test this as a way to ensure that a zoned block device is
being handled as such. As a result, for a host-aware devices, unaligned zone
partitions will be accepted with CONFIG_BLK_DEV_ZONED disabled. That is, the
disk will be treated as a regular block device (as it should). If zoned block
device support is enabled, only aligned partitions will be accepted.

Signed-off-by: Damien Le Moal <damien.lemoal@wdc.com>
Reviewed-by: Hannes Reinecke <hare@suse.com>
Signed-off-by: Jens Axboe <axboe@fb.com>
block/partition-generic.c