Skip to content

Commit 843283e

Browse files
damien-lemoalaxboe
authored andcommitted
block: Fake max open zones limit when there is no limit
For a zoned block device that has no limit on the number of open zones and no limit on the number of active zones, the zone write plug mempool is created with a size of 128 zone write plugs. For such case, set the device max_open_zones queue limit to this value to indicate to the user the potential performance penalty that may happen when writing simultaneously to more zones than the mempool size. Signed-off-by: Damien Le Moal <[email protected]> Reviewed-by: Christoph Hellwig <[email protected]> Reviewed-by: Hannes Reinecke <[email protected]> Reviewed-by: Bart Van Assche <[email protected]> Tested-by: Hans Holmberg <[email protected]> Tested-by: Dennis Maisenbacher <[email protected]> Reviewed-by: Martin K. Petersen <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jens Axboe <[email protected]>
1 parent dd291d7 commit 843283e

File tree

1 file changed

+35
-6
lines changed

1 file changed

+35
-6
lines changed

block/blk-zoned.c

+35-6
Original file line numberDiff line numberDiff line change
@@ -1503,6 +1503,38 @@ struct blk_revalidate_zone_args {
15031503
sector_t sector;
15041504
};
15051505

1506+
/*
1507+
* Update the disk zone resources information and device queue limits.
1508+
* The disk queue is frozen when this is executed.
1509+
*/
1510+
static int disk_update_zone_resources(struct gendisk *disk,
1511+
struct blk_revalidate_zone_args *args)
1512+
{
1513+
struct request_queue *q = disk->queue;
1514+
struct queue_limits lim;
1515+
1516+
disk->nr_zones = args->nr_zones;
1517+
disk->zone_capacity = args->zone_capacity;
1518+
swap(disk->seq_zones_wlock, args->seq_zones_wlock);
1519+
swap(disk->conv_zones_bitmap, args->conv_zones_bitmap);
1520+
1521+
/*
1522+
* If the device has no limit on the maximum number of open and active
1523+
* zones, set its max open zone limit to the mempool size to indicate
1524+
* to the user that there is a potential performance impact due to
1525+
* dynamic zone write plug allocation when simultaneously writing to
1526+
* more zones than the size of the mempool.
1527+
*/
1528+
if (disk->zone_wplugs_pool) {
1529+
lim = queue_limits_start_update(q);
1530+
if (!lim.max_open_zones && !lim.max_active_zones)
1531+
lim.max_open_zones = disk->zone_wplugs_pool->min_nr;
1532+
return queue_limits_commit_update(q, &lim);
1533+
}
1534+
1535+
return 0;
1536+
}
1537+
15061538
/*
15071539
* Helper function to check the validity of zones of a zoned block device.
15081540
*/
@@ -1703,17 +1735,14 @@ int blk_revalidate_disk_zones(struct gendisk *disk,
17031735
*/
17041736
blk_mq_freeze_queue(q);
17051737
if (ret > 0) {
1706-
disk->nr_zones = args.nr_zones;
1707-
disk->zone_capacity = args.zone_capacity;
1708-
swap(disk->seq_zones_wlock, args.seq_zones_wlock);
1709-
swap(disk->conv_zones_bitmap, args.conv_zones_bitmap);
1738+
ret = disk_update_zone_resources(disk, &args);
17101739
if (update_driver_data)
17111740
update_driver_data(disk);
1712-
ret = 0;
17131741
} else {
17141742
pr_warn("%s: failed to revalidate zones\n", disk->disk_name);
1715-
disk_free_zone_resources(disk);
17161743
}
1744+
if (ret)
1745+
disk_free_zone_resources(disk);
17171746
blk_mq_unfreeze_queue(q);
17181747

17191748
kfree(args.seq_zones_wlock);

0 commit comments

Comments
 (0)