Skip to content

Commit

Permalink
block: fix revalidate performance regression
Browse files Browse the repository at this point in the history
The scsi driver function sd_read_block_characteristics() always calls
disk_set_zoned() to a disk zoned model correctly, in case the device
model changed. This is done even for regular disks to set the zoned
model to BLK_ZONED_NONE and free any zone related resources if the drive
previously was zoned.

This behavior significantly impact the time it takes to revalidate disks
on a large system as the call to disk_clear_zone_settings() done from
disk_set_zoned() for the BLK_ZONED_NONE case results in the device
request queued to be frozen, even if there are no zone resources to
free.

Avoid this overhead for non-zoned devices by not calling
disk_clear_zone_settings() in disk_set_zoned() if the device model
was already set to BLK_ZONED_NONE, which is always the case for regular
devices.

Reported by: Brian Bunker <[email protected]>

Fixes: 508aebb ("block: introduce blk_queue_clear_zone_settings()")
Cc: [email protected]
Signed-off-by: Damien Le Moal <[email protected]>
Reviewed-by: Ming Lei <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Jens Axboe <[email protected]>
  • Loading branch information
damien-lemoal authored and axboe committed May 29, 2023
1 parent f270f85 commit 47fe1c3
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion block/blk-settings.c
Original file line number Diff line number Diff line change
Expand Up @@ -915,6 +915,7 @@ static bool disk_has_partitions(struct gendisk *disk)
void disk_set_zoned(struct gendisk *disk, enum blk_zoned_model model)
{
struct request_queue *q = disk->queue;
unsigned int old_model = q->limits.zoned;

switch (model) {
case BLK_ZONED_HM:
Expand Down Expand Up @@ -952,7 +953,7 @@ void disk_set_zoned(struct gendisk *disk, enum blk_zoned_model model)
*/
blk_queue_zone_write_granularity(q,
queue_logical_block_size(q));
} else {
} else if (old_model != BLK_ZONED_NONE) {
disk_clear_zone_settings(disk);
}
}
Expand Down

0 comments on commit 47fe1c3

Please sign in to comment.