summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDamien Le Moal <dlemoal@kernel.org>2025-11-07 09:38:43 +0300
committerJens Axboe <axboe@kernel.dk>2025-11-07 19:28:08 +0300
commite2b0ec776164c11569ee021fac89596a2642654c (patch)
treeaa0c83307781d2f95c6e5682a173124626b37824
parentbbac6e0fa57f6624123edf20ba8f9b7c0e092117 (diff)
downloadlinux-e2b0ec776164c11569ee021fac89596a2642654c.tar.xz
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 <dlemoal@kernel.org> Reviewed-by: Bart Van Assche <bvanassche@acm.org> Reviewed-by: Christoph Hellwig <hch@lst.de> Reviewed-by: Hannes Reinecke <hare@suse.de> Signed-off-by: Jens Axboe <axboe@kernel.dk>
-rw-r--r--block/blk-zoned.c27
1 files changed, 13 insertions, 14 deletions
diff --git a/block/blk-zoned.c b/block/blk-zoned.c
index 7ce7b8ea5a4f..b580d59ce210 100644
--- a/block/blk-zoned.c
+++ b/block/blk-zoned.c
@@ -817,23 +817,24 @@ static unsigned int blk_zone_wp_offset(struct blk_zone *zone)
}
}
-static void disk_zone_wplug_sync_wp_offset(struct gendisk *disk,
- struct blk_zone *zone)
+static unsigned int disk_zone_wplug_sync_wp_offset(struct gendisk *disk,
+ struct blk_zone *zone)
{
struct blk_zone_wplug *zwplug;
- unsigned long flags;
+ unsigned int wp_offset = blk_zone_wp_offset(zone);
zwplug = disk_get_zone_wplug(disk, zone->start);
- if (!zwplug)
- return;
+ if (zwplug) {
+ unsigned long flags;
- spin_lock_irqsave(&zwplug->lock, flags);
- if (zwplug->flags & BLK_ZONE_WPLUG_NEED_WP_UPDATE)
- disk_zone_wplug_set_wp_offset(disk, zwplug,
- blk_zone_wp_offset(zone));
- spin_unlock_irqrestore(&zwplug->lock, flags);
+ spin_lock_irqsave(&zwplug->lock, flags);
+ if (zwplug->flags & BLK_ZONE_WPLUG_NEED_WP_UPDATE)
+ disk_zone_wplug_set_wp_offset(disk, zwplug, wp_offset);
+ spin_unlock_irqrestore(&zwplug->lock, flags);
+ disk_put_zone_wplug(zwplug);
+ }
- disk_put_zone_wplug(zwplug);
+ return wp_offset;
}
/**
@@ -2101,9 +2102,7 @@ static int blk_revalidate_seq_zone(struct blk_zone *zone, unsigned int idx,
if (!queue_emulates_zone_append(disk->queue) || !disk->zone_wplugs_hash)
return 0;
- disk_zone_wplug_sync_wp_offset(disk, zone);
-
- wp_offset = blk_zone_wp_offset(zone);
+ wp_offset = disk_zone_wplug_sync_wp_offset(disk, zone);
if (!wp_offset || wp_offset >= zone->capacity)
return 0;