Skip to content

Commit e2b0ec7

Browse files
damien-lemoalaxboe
authored andcommitted
block: refactor disk_zone_wplug_sync_wp_offset()
The helper function blk_zone_wp_offset() is called from disk_zone_wplug_sync_wp_offset(), and again called from blk_revalidate_seq_zone() right after the call to disk_zone_wplug_sync_wp_offset(). Change disk_zone_wplug_sync_wp_offset() to return the value of obtained with blk_zone_wp_offset() to avoid this double call, which simplifies a little blk_revalidate_seq_zone(). Signed-off-by: Damien Le Moal <[email protected]> Reviewed-by: Bart Van Assche <[email protected]> Reviewed-by: Christoph Hellwig <[email protected]> Reviewed-by: Hannes Reinecke <[email protected]> Signed-off-by: Jens Axboe <[email protected]>
1 parent bbac6e0 commit e2b0ec7

1 file changed

Lines changed: 13 additions & 14 deletions

File tree

block/blk-zoned.c

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -817,23 +817,24 @@ static unsigned int blk_zone_wp_offset(struct blk_zone *zone)
817817
}
818818
}
819819

820-
static void disk_zone_wplug_sync_wp_offset(struct gendisk *disk,
821-
struct blk_zone *zone)
820+
static unsigned int disk_zone_wplug_sync_wp_offset(struct gendisk *disk,
821+
struct blk_zone *zone)
822822
{
823823
struct blk_zone_wplug *zwplug;
824-
unsigned long flags;
824+
unsigned int wp_offset = blk_zone_wp_offset(zone);
825825

826826
zwplug = disk_get_zone_wplug(disk, zone->start);
827-
if (!zwplug)
828-
return;
827+
if (zwplug) {
828+
unsigned long flags;
829829

830-
spin_lock_irqsave(&zwplug->lock, flags);
831-
if (zwplug->flags & BLK_ZONE_WPLUG_NEED_WP_UPDATE)
832-
disk_zone_wplug_set_wp_offset(disk, zwplug,
833-
blk_zone_wp_offset(zone));
834-
spin_unlock_irqrestore(&zwplug->lock, flags);
830+
spin_lock_irqsave(&zwplug->lock, flags);
831+
if (zwplug->flags & BLK_ZONE_WPLUG_NEED_WP_UPDATE)
832+
disk_zone_wplug_set_wp_offset(disk, zwplug, wp_offset);
833+
spin_unlock_irqrestore(&zwplug->lock, flags);
834+
disk_put_zone_wplug(zwplug);
835+
}
835836

836-
disk_put_zone_wplug(zwplug);
837+
return wp_offset;
837838
}
838839

839840
/**
@@ -2101,9 +2102,7 @@ static int blk_revalidate_seq_zone(struct blk_zone *zone, unsigned int idx,
21012102
if (!queue_emulates_zone_append(disk->queue) || !disk->zone_wplugs_hash)
21022103
return 0;
21032104

2104-
disk_zone_wplug_sync_wp_offset(disk, zone);
2105-
2106-
wp_offset = blk_zone_wp_offset(zone);
2105+
wp_offset = disk_zone_wplug_sync_wp_offset(disk, zone);
21072106
if (!wp_offset || wp_offset >= zone->capacity)
21082107
return 0;
21092108

0 commit comments

Comments
 (0)