]> git.baikalelectronics.ru Git - kernel.git/commit
block: Fix partition check for host-aware zoned block devices
authorShin'ichiro Kawasaki <shinichiro.kawasaki@wdc.com>
Tue, 26 Oct 2021 06:01:15 +0000 (15:01 +0900)
committerJens Axboe <axboe@kernel.dk>
Wed, 27 Oct 2021 12:58:01 +0000 (06:58 -0600)
commite5ba781b18e6c6dd3f1af5bb3ec000cffc1f3b88
tree20169ac36d604764187c59d95df01bdae42ac55a
parent2991bd513c69c9137f26499a5e0045f6349bb448
block: Fix partition check for host-aware zoned block devices

Commit 8c683b42e7c4 ("block: use an xarray for disk->part_tbl") modified
the method to check partition existence in host-aware zoned block
devices from disk_has_partitions() helper function call to empty check
of xarray disk->part_tbl. However, disk->part_tbl always has single
entry for disk->part0 and never becomes empty. This resulted in the
host-aware zoned devices always judged to have partitions, and it made
the sysfs queue/zoned attribute to be "none" instead of "host-aware"
regardless of partition existence in the devices.

This also caused DEBUG_LOCKS_WARN_ON(lock->magic != lock) for
sdkp->rev_mutex in scsi layer when the kernel detects host-aware zoned
device. Since block layer handled the host-aware zoned devices as non-
zoned devices, scsi layer did not have chance to initialize the mutex
for zone revalidation. Therefore, the warning was triggered.

To fix the issues, call the helper function disk_has_partitions() in
place of disk->part_tbl empty check. Since the function was removed with
the commit 8c683b42e7c4, reimplement it to walk through entries in the
xarray disk->part_tbl.

Fixes: 8c683b42e7c4 ("block: use an xarray for disk->part_tbl")
Signed-off-by: Shin'ichiro Kawasaki <shinichiro.kawasaki@wdc.com>
Cc: stable@vger.kernel.org # v5.14+
Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Link: https://lore.kernel.org/r/20211026060115.753746-1-shinichiro.kawasaki@wdc.com
Signed-off-by: Jens Axboe <axboe@kernel.dk>
block/blk-settings.c