summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDamien Le Moal <dlemoal@kernel.org>2026-09-08 17:57:45 +0900
committerJens Axboe <axboe@kernel.dk>2026-09-15 06:53:06 -0600
commit85bffad4d2fea373a72d68bed8012e8cbccb8ee7 (patch)
treedc4a22ecb32e12a8078060f20f0e770d02607106
parentd44a97c2535453898df0a9f8b70923abe63651e8 (diff)
downloadlinux-next-85bffad4d2fea373a72d68bed8012e8cbccb8ee7.tar.gz
linux-next-85bffad4d2fea373a72d68bed8012e8cbccb8ee7.zip
block: simplify disk_zone_set_cond()
disk_zone_set_cond() is used to set a zone condition afer a reset, a finish or a reset all operation. For a single zone reset or finish, we are guaranteed that the target zone is a sequential one that is not offline nor read-only (otherwise, the operation would have failed). For a reset all operation, there is no point in calling this function for offline and read-only zones since the condition checks in disk_zone_set_cond() will result in nothing being done. Simplify all this using disk_zone_is_offline_or_readonly() in blk_zone_reset_all_bio_endio() to skip zones that are offline or read-only. This change allows simplifying disk_zone_set_cond() by removing the zone condition checks. This change is also consistent with the fact that conventional zones can now have the offline or read-only condition. 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: Johannes Thumshirn <johannes.thumshirn@wdc.com> Reviewed-by: Hannes Reinecke <hare@kernel.org> Link: https://patch.msgid.link/20260908085745.1082697-17-dlemoal@kernel.org Signed-off-by: Jens Axboe <axboe@kernel.dk>
-rw-r--r--block/blk-zoned.c23
1 files changed, 5 insertions, 18 deletions
diff --git a/block/blk-zoned.c b/block/blk-zoned.c
index 2a8e573034b3..ec510d66dfe2 100644
--- a/block/blk-zoned.c
+++ b/block/blk-zoned.c
@@ -240,23 +240,9 @@ static void disk_zone_set_cond(struct gendisk *disk, sector_t sector,
rcu_read_lock();
zones_state = rcu_dereference(disk->zones_state);
- if (zones_state && zno < disk->nr_zones) {
- /*
- * The condition of a conventional, readonly and offline zones
- * never changes, so do nothing if the target zone is in one of
- * these conditions.
- */
- switch (zones_state[zno] & BLK_ZSTATE_COND_MASK) {
- case BLK_ZSTATE_NOT_WP:
- case BLK_ZSTATE_READONLY:
- case BLK_ZSTATE_OFFLINE:
- break;
- default:
- blk_zstate_set(zones_state, disk->nr_zones, zno, cond,
- blk_zstate_flags(zones_state[zno]));
- break;
- }
- }
+ if (likely(zones_state && zno < disk->nr_zones))
+ blk_zstate_set(zones_state, disk->nr_zones, zno, cond,
+ blk_zstate_flags(zones_state[zno]));
rcu_read_unlock();
}
@@ -1310,7 +1296,8 @@ static void blk_zone_reset_all_bio_endio(struct bio *bio)
/* Update the cached zone conditions. */
for (sector = 0; sector < get_capacity(disk);
sector += bdev_zone_sectors(bio->bi_bdev)) {
- if (disk_zone_is_offline_or_readonly(disk, sector))
+ if (!disk_zone_is_seq(disk, sector) ||
+ disk_zone_is_offline_or_readonly(disk, sector))
continue;
disk_zone_set_cond(disk, sector, BLK_ZONE_COND_EMPTY);
}