Skip to content

Commit 659bf82

Browse files
Niklas Casselaxboe
authored andcommitted
block: add max_active_zones to blk-sysfs
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 <[email protected]> Reviewed-by: Javier González <[email protected]> Reviewed-by: Damien Le Moal <[email protected]> Reviewed-by: Johannes Thumshirn <[email protected]> Reviewed-by: Martin K. Petersen <[email protected]> Signed-off-by: Jens Axboe <[email protected]>
1 parent e15864f commit 659bf82

File tree

6 files changed

+56
-1
lines changed

6 files changed

+56
-1
lines changed

Documentation/ABI/testing/sysfs-block

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -273,6 +273,15 @@ Description:
273273
device ("host-aware" or "host-managed" zone model). For regular
274274
block devices, the value is always 0.
275275

276+
What: /sys/block/<disk>/queue/max_active_zones
277+
Date: July 2020
278+
Contact: Niklas Cassel <[email protected]>
279+
Description:
280+
For zoned block devices (zoned attribute indicating
281+
"host-managed" or "host-aware"), the sum of zones belonging to
282+
any of the zone states: EXPLICIT OPEN, IMPLICIT OPEN or CLOSED,
283+
is limited by this value. If this value is 0, there is no limit.
284+
276285
What: /sys/block/<disk>/queue/max_open_zones
277286
Date: July 2020
278287
Contact: Niklas Cassel <[email protected]>

Documentation/block/queue-sysfs.rst

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,13 @@ Maximum number of elements in a DMA scatter/gather list with integrity
117117
data that will be submitted by the block layer core to the associated
118118
block driver.
119119

120+
max_active_zones (RO)
121+
---------------------
122+
For zoned block devices (zoned attribute indicating "host-managed" or
123+
"host-aware"), the sum of zones belonging to any of the zone states:
124+
EXPLICIT OPEN, IMPLICIT OPEN or CLOSED, is limited by this value.
125+
If this value is 0, there is no limit.
126+
120127
max_open_zones (RO)
121128
-------------------
122129
For zoned block devices (zoned attribute indicating "host-managed" or

block/blk-sysfs.c

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -311,6 +311,11 @@ static ssize_t queue_max_open_zones_show(struct request_queue *q, char *page)
311311
return queue_var_show(queue_max_open_zones(q), page);
312312
}
313313

314+
static ssize_t queue_max_active_zones_show(struct request_queue *q, char *page)
315+
{
316+
return queue_var_show(queue_max_active_zones(q), page);
317+
}
318+
314319
static ssize_t queue_nomerges_show(struct request_queue *q, char *page)
315320
{
316321
return queue_var_show((blk_queue_nomerges(q) << 1) |
@@ -678,6 +683,11 @@ static struct queue_sysfs_entry queue_max_open_zones_entry = {
678683
.show = queue_max_open_zones_show,
679684
};
680685

686+
static struct queue_sysfs_entry queue_max_active_zones_entry = {
687+
.attr = {.name = "max_active_zones", .mode = 0444 },
688+
.show = queue_max_active_zones_show,
689+
};
690+
681691
static struct queue_sysfs_entry queue_nomerges_entry = {
682692
.attr = {.name = "nomerges", .mode = 0644 },
683693
.show = queue_nomerges_show,
@@ -777,6 +787,7 @@ static struct attribute *queue_attrs[] = {
777787
&queue_zoned_entry.attr,
778788
&queue_nr_zones_entry.attr,
779789
&queue_max_open_zones_entry.attr,
790+
&queue_max_active_zones_entry.attr,
780791
&queue_nomerges_entry.attr,
781792
&queue_rq_affinity_entry.attr,
782793
&queue_iostats_entry.attr,
@@ -804,7 +815,8 @@ static umode_t queue_attr_visible(struct kobject *kobj, struct attribute *attr,
804815
(!q->mq_ops || !q->mq_ops->timeout))
805816
return 0;
806817

807-
if (attr == &queue_max_open_zones_entry.attr &&
818+
if ((attr == &queue_max_open_zones_entry.attr ||
819+
attr == &queue_max_active_zones_entry.attr) &&
808820
!blk_queue_is_zoned(q))
809821
return 0;
810822

drivers/nvme/host/zns.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@ int nvme_update_zone_info(struct gendisk *disk, struct nvme_ns *ns,
9797
q->limits.zoned = BLK_ZONED_HM;
9898
blk_queue_flag_set(QUEUE_FLAG_ZONE_RESETALL, q);
9999
blk_queue_max_open_zones(q, le32_to_cpu(id->mor) + 1);
100+
blk_queue_max_active_zones(q, le32_to_cpu(id->mar) + 1);
100101
free_data:
101102
kfree(id);
102103
return status;

drivers/scsi/sd_zbc.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -721,6 +721,7 @@ int sd_zbc_read_zones(struct scsi_disk *sdkp, unsigned char *buf)
721721
blk_queue_max_open_zones(q, 0);
722722
else
723723
blk_queue_max_open_zones(q, sdkp->zones_max_open);
724+
blk_queue_max_active_zones(q, 0);
724725
nr_zones = round_up(sdkp->capacity, zone_blocks) >> ilog2(zone_blocks);
725726

726727
/* READ16/WRITE16 is mandatory for ZBC disks */

include/linux/blkdev.h

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -514,6 +514,7 @@ struct request_queue {
514514
unsigned long *conv_zones_bitmap;
515515
unsigned long *seq_zones_wlock;
516516
unsigned int max_open_zones;
517+
unsigned int max_active_zones;
517518
#endif /* CONFIG_BLK_DEV_ZONED */
518519

519520
/*
@@ -734,6 +735,17 @@ static inline unsigned int queue_max_open_zones(const struct request_queue *q)
734735
{
735736
return q->max_open_zones;
736737
}
738+
739+
static inline void blk_queue_max_active_zones(struct request_queue *q,
740+
unsigned int max_active_zones)
741+
{
742+
q->max_active_zones = max_active_zones;
743+
}
744+
745+
static inline unsigned int queue_max_active_zones(const struct request_queue *q)
746+
{
747+
return q->max_active_zones;
748+
}
737749
#else /* CONFIG_BLK_DEV_ZONED */
738750
static inline unsigned int blk_queue_nr_zones(struct request_queue *q)
739751
{
@@ -753,6 +765,10 @@ static inline unsigned int queue_max_open_zones(const struct request_queue *q)
753765
{
754766
return 0;
755767
}
768+
static inline unsigned int queue_max_active_zones(const struct request_queue *q)
769+
{
770+
return 0;
771+
}
756772
#endif /* CONFIG_BLK_DEV_ZONED */
757773

758774
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)
15441560
return 0;
15451561
}
15461562

1563+
static inline unsigned int bdev_max_active_zones(struct block_device *bdev)
1564+
{
1565+
struct request_queue *q = bdev_get_queue(bdev);
1566+
1567+
if (q)
1568+
return queue_max_active_zones(q);
1569+
return 0;
1570+
}
1571+
15471572
static inline int queue_dma_alignment(const struct request_queue *q)
15481573
{
15491574
return q ? q->dma_alignment : 511;

0 commit comments

Comments
 (0)