Commit e15864f8 authored by Niklas Cassel's avatar Niklas Cassel Committed by Jens Axboe
Browse files

block: add max_open_zones to blk-sysfs



Add a new max_open_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 open 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_open_zones member to struct request_queue, rather
than as a queue limit, since this property cannot be split across stacking
drivers.

Signed-off-by: default avatarNiklas Cassel <niklas.cassel@wdc.com>
Reviewed-by: default avatarJavier González <javier@javigon.com>
Reviewed-by: default avatarDamien Le Moal <damien.lemoal@wdc.com>
Reviewed-by: default avatarJohannes Thumshirn <johannes.thumshirn@wdc.com>
Reviewed-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
Signed-off-by: default avatarJens Axboe <axboe@kernel.dk>
parent b1d37e5b
Loading
Loading
Loading
Loading
+9 −0
Original line number Original line Diff line number Diff line
@@ -273,6 +273,15 @@ Description:
		device ("host-aware" or "host-managed" zone model). For regular
		device ("host-aware" or "host-managed" zone model). For regular
		block devices, the value is always 0.
		block devices, the value is always 0.


What:		/sys/block/<disk>/queue/max_open_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 or IMPLICIT OPEN,
		is limited by this value. If this value is 0, there is no limit.

What:		/sys/block/<disk>/queue/chunk_sectors
What:		/sys/block/<disk>/queue/chunk_sectors
Date:		September 2016
Date:		September 2016
Contact:	Hannes Reinecke <hare@suse.com>
Contact:	Hannes Reinecke <hare@suse.com>
+7 −0
Original line number Original line Diff line number Diff line
@@ -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
data that will be submitted by the block layer core to the associated
block driver.
block driver.


max_open_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 or IMPLICIT OPEN, is limited by this value.
If this value is 0, there is no limit.

max_sectors_kb (RW)
max_sectors_kb (RW)
-------------------
-------------------
This is the maximum number of kilobytes that the block layer will allow
This is the maximum number of kilobytes that the block layer will allow
+15 −0
Original line number Original line Diff line number Diff line
@@ -306,6 +306,11 @@ static ssize_t queue_nr_zones_show(struct request_queue *q, char *page)
	return queue_var_show(blk_queue_nr_zones(q), page);
	return queue_var_show(blk_queue_nr_zones(q), page);
}
}


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_nomerges_show(struct request_queue *q, char *page)
static ssize_t queue_nomerges_show(struct request_queue *q, char *page)
{
{
	return queue_var_show((blk_queue_nomerges(q) << 1) |
	return queue_var_show((blk_queue_nomerges(q) << 1) |
@@ -668,6 +673,11 @@ static struct queue_sysfs_entry queue_nr_zones_entry = {
	.show = queue_nr_zones_show,
	.show = queue_nr_zones_show,
};
};


static struct queue_sysfs_entry queue_max_open_zones_entry = {
	.attr = {.name = "max_open_zones", .mode = 0444 },
	.show = queue_max_open_zones_show,
};

static struct queue_sysfs_entry queue_nomerges_entry = {
static struct queue_sysfs_entry queue_nomerges_entry = {
	.attr = {.name = "nomerges", .mode = 0644 },
	.attr = {.name = "nomerges", .mode = 0644 },
	.show = queue_nomerges_show,
	.show = queue_nomerges_show,
@@ -766,6 +776,7 @@ static struct attribute *queue_attrs[] = {
	&queue_nonrot_entry.attr,
	&queue_nonrot_entry.attr,
	&queue_zoned_entry.attr,
	&queue_zoned_entry.attr,
	&queue_nr_zones_entry.attr,
	&queue_nr_zones_entry.attr,
	&queue_max_open_zones_entry.attr,
	&queue_nomerges_entry.attr,
	&queue_nomerges_entry.attr,
	&queue_rq_affinity_entry.attr,
	&queue_rq_affinity_entry.attr,
	&queue_iostats_entry.attr,
	&queue_iostats_entry.attr,
@@ -793,6 +804,10 @@ static umode_t queue_attr_visible(struct kobject *kobj, struct attribute *attr,
		(!q->mq_ops || !q->mq_ops->timeout))
		(!q->mq_ops || !q->mq_ops->timeout))
			return 0;
			return 0;


	if (attr == &queue_max_open_zones_entry.attr &&
	    !blk_queue_is_zoned(q))
		return 0;

	return attr->mode;
	return attr->mode;
}
}


+1 −0
Original line number Original line Diff line number Diff line
@@ -96,6 +96,7 @@ int nvme_update_zone_info(struct gendisk *disk, struct nvme_ns *ns,


	q->limits.zoned = BLK_ZONED_HM;
	q->limits.zoned = BLK_ZONED_HM;
	blk_queue_flag_set(QUEUE_FLAG_ZONE_RESETALL, q);
	blk_queue_flag_set(QUEUE_FLAG_ZONE_RESETALL, q);
	blk_queue_max_open_zones(q, le32_to_cpu(id->mor) + 1);
free_data:
free_data:
	kfree(id);
	kfree(id);
	return status;
	return status;
+4 −0
Original line number Original line Diff line number Diff line
@@ -717,6 +717,10 @@ int sd_zbc_read_zones(struct scsi_disk *sdkp, unsigned char *buf)
	/* The drive satisfies the kernel restrictions: set it up */
	/* The drive satisfies the kernel restrictions: set it up */
	blk_queue_flag_set(QUEUE_FLAG_ZONE_RESETALL, q);
	blk_queue_flag_set(QUEUE_FLAG_ZONE_RESETALL, q);
	blk_queue_required_elevator_features(q, ELEVATOR_F_ZBD_SEQ_WRITE);
	blk_queue_required_elevator_features(q, ELEVATOR_F_ZBD_SEQ_WRITE);
	if (sdkp->zones_max_open == U32_MAX)
		blk_queue_max_open_zones(q, 0);
	else
		blk_queue_max_open_zones(q, sdkp->zones_max_open);
	nr_zones = round_up(sdkp->capacity, zone_blocks) >> ilog2(zone_blocks);
	nr_zones = round_up(sdkp->capacity, zone_blocks) >> ilog2(zone_blocks);


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