Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

block: Allow BIO-based drivers to use blk_revalidate_disk_zones()

In preparation for allowing BIO based device drivers to use zone write
plugging and its zone append emulation, allow these drivers to call
blk_revalidate_disk_zones() so that all zone resources necessary to zone
write plugging can be initialized.

To do so, remove the check in blk_revalidate_disk_zones() restricting
the use of this function to mq request-based drivers to allow also
BIO-based drivers to use it. This is safe to do as long as the
BIO-based block device queue is already setup and usable, as it should,
and can be safely frozen.

The helper function disk_need_zone_resources() is added to control the
allocation and initialization of the zone write plug hash table and
of the conventional zone bitmap only for mq devices and for BIO-based
devices that require zone append emulation.

Signed-off-by: Damien Le Moal <dlemoal@kernel.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Hannes Reinecke <hare@suse.de>
Reviewed-by: Bart Van Assche <bvanassche@acm.org>
Tested-by: Hans Holmberg <hans.holmberg@wdc.com>
Tested-by: Dennis Maisenbacher <dennis.maisenbacher@wdc.com>
Reviewed-by: Martin K. Petersen <martin.petersen@oracle.com>
Link: https://lore.kernel.org/r/20240408014128.205141-12-dlemoal@kernel.org
Signed-off-by: Jens Axboe <axboe@kernel.dk>

authored by

Damien Le Moal and committed by
Jens Axboe
946dd71e 9b1ce7f0

+24 -6
+24 -6
block/blk-zoned.c
··· 1512 1512 disk->nr_zones = 0; 1513 1513 } 1514 1514 1515 + static inline bool disk_need_zone_resources(struct gendisk *disk) 1516 + { 1517 + /* 1518 + * All mq zoned devices need zone resources so that the block layer 1519 + * can automatically handle write BIO plugging. BIO-based device drivers 1520 + * (e.g. DM devices) are normally responsible for handling zone write 1521 + * ordering and do not need zone resources, unless the driver requires 1522 + * zone append emulation. 1523 + */ 1524 + return queue_is_mq(disk->queue) || 1525 + queue_emulates_zone_append(disk->queue); 1526 + } 1527 + 1515 1528 static int disk_revalidate_zone_resources(struct gendisk *disk, 1516 1529 unsigned int nr_zones) 1517 1530 { 1518 1531 struct queue_limits *lim = &disk->queue->limits; 1519 1532 unsigned int pool_size; 1533 + 1534 + if (!disk_need_zone_resources(disk)) 1535 + return 0; 1520 1536 1521 1537 /* 1522 1538 * If the device has no limit on the maximum number of open and active ··· 1651 1635 disk->disk_name); 1652 1636 return -ENODEV; 1653 1637 } 1638 + 1639 + if (!disk_need_zone_resources(disk)) 1640 + break; 1654 1641 if (!args->conv_zones_bitmap) { 1655 1642 args->conv_zones_bitmap = 1656 1643 blk_alloc_zone_bitmap(q->node, args->nr_zones); ··· 1685 1666 /* 1686 1667 * We need to track the write pointer of all zones that are not 1687 1668 * empty nor full. So make sure we have a zone write plug for 1688 - * such zone. 1669 + * such zone if the device has a zone write plug hash table. 1689 1670 */ 1690 1671 wp_offset = blk_zone_wp_offset(zone); 1691 - if (wp_offset && wp_offset < zone_sectors) { 1672 + if (disk->zone_wplugs_hash && 1673 + wp_offset && wp_offset < zone_sectors) { 1692 1674 zwplug = disk_get_and_lock_zone_wplug(disk, zone->start, 1693 1675 GFP_NOIO, &flags); 1694 1676 if (!zwplug) ··· 1720 1700 * be called within the disk ->revalidate method for blk-mq based drivers. 1721 1701 * Before calling this function, the device driver must already have set the 1722 1702 * device zone size (chunk_sector limit) and the max zone append limit. 1723 - * For BIO based drivers, this function cannot be used. BIO based device drivers 1724 - * only need to set disk->nr_zones so that the sysfs exposed value is correct. 1703 + * BIO based drivers can also use this function as long as the device queue 1704 + * can be safely frozen. 1725 1705 * If the @update_driver_data callback function is not NULL, the callback is 1726 1706 * executed with the device request queue frozen after all zones have been 1727 1707 * checked. ··· 1737 1717 int ret = -ENOMEM; 1738 1718 1739 1719 if (WARN_ON_ONCE(!blk_queue_is_zoned(q))) 1740 - return -EIO; 1741 - if (WARN_ON_ONCE(!queue_is_mq(q))) 1742 1720 return -EIO; 1743 1721 1744 1722 if (!capacity)