Skip to content

Commit e0c60d0

Browse files
kawasakiaxboe
authored andcommitted
block: Fix partition check for host-aware zoned block devices
Commit a33df75 ("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 a33df75, reimplement it to walk through entries in the xarray disk->part_tbl. Fixes: a33df75 ("block: use an xarray for disk->part_tbl") Signed-off-by: Shin'ichiro Kawasaki <[email protected]> Cc: [email protected] # v5.14+ Reviewed-by: Johannes Thumshirn <[email protected]> Reviewed-by: Christoph Hellwig <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jens Axboe <[email protected]>
1 parent 9586e67 commit e0c60d0

File tree

1 file changed

+19
-1
lines changed

1 file changed

+19
-1
lines changed

block/blk-settings.c

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -842,6 +842,24 @@ bool blk_queue_can_use_dma_map_merging(struct request_queue *q,
842842
}
843843
EXPORT_SYMBOL_GPL(blk_queue_can_use_dma_map_merging);
844844

845+
static bool disk_has_partitions(struct gendisk *disk)
846+
{
847+
unsigned long idx;
848+
struct block_device *part;
849+
bool ret = false;
850+
851+
rcu_read_lock();
852+
xa_for_each(&disk->part_tbl, idx, part) {
853+
if (bdev_is_partition(part)) {
854+
ret = true;
855+
break;
856+
}
857+
}
858+
rcu_read_unlock();
859+
860+
return ret;
861+
}
862+
845863
/**
846864
* blk_queue_set_zoned - configure a disk queue zoned model.
847865
* @disk: the gendisk of the queue to configure
@@ -876,7 +894,7 @@ void blk_queue_set_zoned(struct gendisk *disk, enum blk_zoned_model model)
876894
* we do nothing special as far as the block layer is concerned.
877895
*/
878896
if (!IS_ENABLED(CONFIG_BLK_DEV_ZONED) ||
879-
!xa_empty(&disk->part_tbl))
897+
disk_has_partitions(disk))
880898
model = BLK_ZONED_NONE;
881899
break;
882900
case BLK_ZONED_NONE:

0 commit comments

Comments
 (0)