block: add max_active_zones to blk-sysfs
authorNiklas Cassel <niklas.cassel@wdc.com>
Tue, 14 Jul 2020 21:18:24 +0000 (23:18 +0200)
committerJens Axboe <axboe@kernel.dk>
Wed, 15 Jul 2020 20:26:11 +0000 (14:26 -0600)
Add a new max_active zones definition in the sysfs documentation.
This definition will be common for all devices utilizing the zoned block
device support in the kernel.

Export max_active_zones according to this new definition for NVMe Zoned
Namespace devices, ZAC ATA devices (which are treated as SCSI devices by
the kernel), and ZBC SCSI devices.

Add the new max_active_zones member to struct request_queue, rather
than as a queue limit, since this property cannot be split across stacking
drivers.

For SCSI devices, even though max active zones is not part of the ZBC/ZAC
spec, export max_active_zones as 0, signifying "no limit".

Signed-off-by: Niklas Cassel <niklas.cassel@wdc.com>
Reviewed-by: Javier González <javier@javigon.com>
Reviewed-by: Damien Le Moal <damien.lemoal@wdc.com>
Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
Reviewed-by: Martin K. Petersen <martin.petersen@oracle.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Documentation/ABI/testing/sysfs-block
Documentation/block/queue-sysfs.rst
block/blk-sysfs.c
drivers/nvme/host/zns.c
drivers/scsi/sd_zbc.c
include/linux/blkdev.h

index f151d9cf90dea0a9d09ee2ac7474f6d32d819570..2322eb748b38774b2936d5411cafa091fef644ab 100644 (file)
@@ -273,6 +273,15 @@ Description:
                device ("host-aware" or "host-managed" zone model). For regular
                block devices, the value is always 0.
 
+What:          /sys/block/<disk>/queue/max_active_zones
+Date:          July 2020
+Contact:       Niklas Cassel <niklas.cassel@wdc.com>
+Description:
+               For zoned block devices (zoned attribute indicating
+               "host-managed" or "host-aware"), the sum of zones belonging to
+               any of the zone states: EXPLICIT OPEN, IMPLICIT OPEN or CLOSED,
+               is limited by this value. If this value is 0, there is no limit.
+
 What:          /sys/block/<disk>/queue/max_open_zones
 Date:          July 2020
 Contact:       Niklas Cassel <niklas.cassel@wdc.com>
index f01cf8530ae4fd9a459a675f44ea2792885fe88a..f261a5c84170843c3eba524b0112a416c16f26bd 100644 (file)
@@ -117,6 +117,13 @@ Maximum number of elements in a DMA scatter/gather list with integrity
 data that will be submitted by the block layer core to the associated
 block driver.
 
+max_active_zones (RO)
+---------------------
+For zoned block devices (zoned attribute indicating "host-managed" or
+"host-aware"), the sum of zones belonging to any of the zone states:
+EXPLICIT OPEN, IMPLICIT OPEN or CLOSED, is limited by this value.
+If this value is 0, there is no limit.
+
 max_open_zones (RO)
 -------------------
 For zoned block devices (zoned attribute indicating "host-managed" or
index 414f04579d770e25eafb7020b635f69fdf7cc9f7..7dda709f3ccb6f79034ef91b1d76966f9b73f2a8 100644 (file)
@@ -311,6 +311,11 @@ static ssize_t queue_max_open_zones_show(struct request_queue *q, char *page)
        return queue_var_show(queue_max_open_zones(q), page);
 }
 
+static ssize_t queue_max_active_zones_show(struct request_queue *q, char *page)
+{
+       return queue_var_show(queue_max_active_zones(q), page);
+}
+
 static ssize_t queue_nomerges_show(struct request_queue *q, char *page)
 {
        return queue_var_show((blk_queue_nomerges(q) << 1) |
@@ -678,6 +683,11 @@ static struct queue_sysfs_entry queue_max_open_zones_entry = {
        .show = queue_max_open_zones_show,
 };
 
+static struct queue_sysfs_entry queue_max_active_zones_entry = {
+       .attr = {.name = "max_active_zones", .mode = 0444 },
+       .show = queue_max_active_zones_show,
+};
+
 static struct queue_sysfs_entry queue_nomerges_entry = {
        .attr = {.name = "nomerges", .mode = 0644 },
        .show = queue_nomerges_show,
@@ -777,6 +787,7 @@ static struct attribute *queue_attrs[] = {
        &queue_zoned_entry.attr,
        &queue_nr_zones_entry.attr,
        &queue_max_open_zones_entry.attr,
+       &queue_max_active_zones_entry.attr,
        &queue_nomerges_entry.attr,
        &queue_rq_affinity_entry.attr,
        &queue_iostats_entry.attr,
@@ -804,7 +815,8 @@ static umode_t queue_attr_visible(struct kobject *kobj, struct attribute *attr,
                (!q->mq_ops || !q->mq_ops->timeout))
                        return 0;
 
-       if (attr == &queue_max_open_zones_entry.attr &&
+       if ((attr == &queue_max_open_zones_entry.attr ||
+            attr == &queue_max_active_zones_entry.attr) &&
            !blk_queue_is_zoned(q))
                return 0;
 
index 3d80b9cf6bfc1c9f2976a99a574fe2eafeb97e51..57cfd78731fbbebf3e698b72ae3096391f5808d9 100644 (file)
@@ -97,6 +97,7 @@ int nvme_update_zone_info(struct gendisk *disk, struct nvme_ns *ns,
        q->limits.zoned = BLK_ZONED_HM;
        blk_queue_flag_set(QUEUE_FLAG_ZONE_RESETALL, q);
        blk_queue_max_open_zones(q, le32_to_cpu(id->mor) + 1);
+       blk_queue_max_active_zones(q, le32_to_cpu(id->mar) + 1);
 free_data:
        kfree(id);
        return status;
index aa3564139b40a79e2c8fe2504a9c3c900edbed4c..d8b2c49d645b293c3cb112b4a46d820c82077b20 100644 (file)
@@ -721,6 +721,7 @@ int sd_zbc_read_zones(struct scsi_disk *sdkp, unsigned char *buf)
                blk_queue_max_open_zones(q, 0);
        else
                blk_queue_max_open_zones(q, sdkp->zones_max_open);
+       blk_queue_max_active_zones(q, 0);
        nr_zones = round_up(sdkp->capacity, zone_blocks) >> ilog2(zone_blocks);
 
        /* READ16/WRITE16 is mandatory for ZBC disks */
index c8beb8bbdb08285c27409b5a0ed3231d0d1aa5dc..285b59cfc06467dc12652eb37720329797c1287e 100644 (file)
@@ -514,6 +514,7 @@ struct request_queue {
        unsigned long           *conv_zones_bitmap;
        unsigned long           *seq_zones_wlock;
        unsigned int            max_open_zones;
+       unsigned int            max_active_zones;
 #endif /* CONFIG_BLK_DEV_ZONED */
 
        /*
@@ -734,6 +735,17 @@ static inline unsigned int queue_max_open_zones(const struct request_queue *q)
 {
        return q->max_open_zones;
 }
+
+static inline void blk_queue_max_active_zones(struct request_queue *q,
+               unsigned int max_active_zones)
+{
+       q->max_active_zones = max_active_zones;
+}
+
+static inline unsigned int queue_max_active_zones(const struct request_queue *q)
+{
+       return q->max_active_zones;
+}
 #else /* CONFIG_BLK_DEV_ZONED */
 static inline unsigned int blk_queue_nr_zones(struct request_queue *q)
 {
@@ -753,6 +765,10 @@ static inline unsigned int queue_max_open_zones(const struct request_queue *q)
 {
        return 0;
 }
+static inline unsigned int queue_max_active_zones(const struct request_queue *q)
+{
+       return 0;
+}
 #endif /* CONFIG_BLK_DEV_ZONED */
 
 static inline bool rq_is_sync(struct request *rq)
@@ -1544,6 +1560,15 @@ static inline unsigned int bdev_max_open_zones(struct block_device *bdev)
        return 0;
 }
 
+static inline unsigned int bdev_max_active_zones(struct block_device *bdev)
+{
+       struct request_queue *q = bdev_get_queue(bdev);
+
+       if (q)
+               return queue_max_active_zones(q);
+       return 0;
+}
+
 static inline int queue_dma_alignment(const struct request_queue *q)
 {
        return q ? q->dma_alignment : 511;