Skip to contentSkip to conversation

block: fix revalidate performance regression

PATCH Superseded Damien Le Moal 3 participants 3 messages May 29, 2023 – May 30, 2023 Block layer

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 block: fix revalidate performance regression

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 quiesced, even if there is no zone resource to free.

Avoid this overhead for non zoned devices by not calling disk_clear_zone_settings() in disk_set_zoned() if the device model already was set to BLK_ZONED_NONE.

Reported by: Brian Bunker <[email protected]>

Fixes 508aebb80527 ("block: introduce blk_queue_clear_zone_settings()")
---
 block/blk-settings.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
block/blk-settings.c +2 -1
index 896b4654ab00..4dd59059b788 100644
@@ -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:
@@ -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);
 	}
 }
Signature · 1 line
2.40.1
Reviewed-by on v1 1/1
#1 lore raw
Quoted 11 lines · Damien Le Moal

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 quiesced, even if there is no zone resource to

s/quiesced/frozen

Quoted 10 lines

free.

Avoid this overhead for non zoned devices by not calling disk_clear_zone_settings() in disk_set_zoned() if the device model already was set to BLK_ZONED_NONE.

Reported by: Brian Bunker <[email protected]>

Fixes 508aebb80527 ("block: introduce blk_queue_clear_zone_settings()")
Reviewed-by on v1 1/1
#2 lore raw
In reply to Damien Le Moal
Quoted 37 lines · Damien Le Moal

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 quiesced, even if there is no zone resource to free.

Avoid this overhead for non zoned devices by not calling disk_clear_zone_settings() in disk_set_zoned() if the device model already was set to BLK_ZONED_NONE.

Reported by: Brian Bunker <[email protected]>

Fixes 508aebb80527 ("block: introduce blk_queue_clear_zone_settings()")
---
  block/blk-settings.c | 3 ++-
  1 file changed, 2 insertions(+), 1 deletion(-)
block/blk-settings.c +1 -0
index 896b4654ab00..4dd59059b788 100644
@@ -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:

block/blk-settings.c void disk_set_zoned(struct gendisk *disk, enum blk_zoned_model model) · line 959

Quoted 8 lines
block/blk-settings.c +1 -1
@@ -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);
  	}
  }

Cheers,

Hannes

Signature · 5 lines
Dr. Hannes Reinecke                Kernel Storage Architect
[email protected]                              +49 911 74053 688
SUSE Software Solutions GmbH, Maxfeldstr. 5, 90409 Nürnberg
HRB 36809 (AG Nürnberg), Geschäftsführer: Ivo Totev, Andrew
Myers, Andrew McDonald, Martje Boudien Moerman