diff mbox series

[5/7] block: Introduce zoned block device elevator feature

Message ID 20190823001528.5673-6-damien.lemoal@wdc.com (mailing list archive)
State New, archived
Headers show
Series Elevator cleanups and improvements | expand

Commit Message

Damien Le Moal Aug. 23, 2019, 12:15 a.m. UTC
Introduce the elevator feature ELEVATOR_F_ZONED_BLOCK_DEV to indicate
that an elevator supports zoned block device write ordering control.

Mark the mq-deadline as supporting this feature which is implemented
using zone write locking. SCSI zoned block device scan and null_blk
device creation with zoned mode enabled are also modified to require
this feature using the helper blk_queue_required_elevator_features().

This requirement can always be satisfied as the mq-deadline scheduler is
always selected for in-kernel compilation when CONFIG_BLK_DEV_ZONED
(zoned block device support) is enabled.

Signed-off-by: Damien Le Moal <damien.lemoal@wdc.com>
---
 block/mq-deadline.c           | 1 +
 drivers/block/null_blk_main.c | 5 +++++
 drivers/scsi/sd_zbc.c         | 2 ++
 include/linux/elevator.h      | 7 +++++++
 4 files changed, 15 insertions(+)

Comments

Johannes Thumshirn Aug. 23, 2019, 11:41 a.m. UTC | #1
On 23/08/2019 02:15, Damien Le Moal wrote:
> Introduce the elevator feature ELEVATOR_F_ZONED_BLOCK_DEV to indicate
> that an elevator supports zoned block device write ordering control.
> 
> Mark the mq-deadline as supporting this feature which is implemented
> using zone write locking. SCSI zoned block device scan and null_blk
> device creation with zoned mode enabled are also modified to require
> this feature using the helper blk_queue_required_elevator_features().
> 
> This requirement can always be satisfied as the mq-deadline scheduler is
> always selected for in-kernel compilation when CONFIG_BLK_DEV_ZONED
> (zoned block device support) is enabled.

Hmm I would have preferred this to be split into two patches, one
introducing the features (not just ELEVATOR_F_ZONED_BLOCK_DEV but also
the features you describe in 4/7) and mark all schedulers with the
feature bits and then one pulling the requirement of
ELEVATOR_F_ZONED_BLOCK_DEV in null_blk and sd.
diff mbox series

Patch

diff --git a/block/mq-deadline.c b/block/mq-deadline.c
index 2a2a2e82832e..95e03408f2ac 100644
--- a/block/mq-deadline.c
+++ b/block/mq-deadline.c
@@ -795,6 +795,7 @@  static struct elevator_type mq_deadline = {
 	.elevator_attrs = deadline_attrs,
 	.elevator_name = "mq-deadline",
 	.elevator_alias = "deadline",
+	.elevator_features = ELEVATOR_F_ZONED_BLOCK_DEV,
 	.elevator_owner = THIS_MODULE,
 };
 MODULE_ALIAS("mq-deadline-iosched");
diff --git a/drivers/block/null_blk_main.c b/drivers/block/null_blk_main.c
index 99c56d72ff78..253bb7b4443e 100644
--- a/drivers/block/null_blk_main.c
+++ b/drivers/block/null_blk_main.c
@@ -1538,6 +1538,9 @@  static int null_gendisk_register(struct nullb *nullb)
 
 		if (ret != 0)
 			return ret;
+
+		blk_queue_required_elevator_features(disk->queue,
+						ELEVATOR_F_ZONED_BLOCK_DEV);
 	}
 
 	add_disk(disk);
@@ -1691,6 +1694,8 @@  static int null_add_dev(struct nullb_device *dev)
 		blk_queue_chunk_sectors(nullb->q, dev->zone_size_sects);
 		nullb->q->limits.zoned = BLK_ZONED_HM;
 		blk_queue_flag_set(QUEUE_FLAG_ZONE_RESETALL, nullb->q);
+		blk_queue_required_elevator_features(nullb->q,
+						ELEVATOR_F_ZONED_BLOCK_DEV);
 	}
 
 	nullb->q->queuedata = nullb;
diff --git a/drivers/scsi/sd_zbc.c b/drivers/scsi/sd_zbc.c
index 367614f0e34f..983f5d0be902 100644
--- a/drivers/scsi/sd_zbc.c
+++ b/drivers/scsi/sd_zbc.c
@@ -490,6 +490,8 @@  int sd_zbc_read_zones(struct scsi_disk *sdkp, unsigned char *buf)
 		goto err;
 
 	/* The drive satisfies the kernel restrictions: set it up */
+	blk_queue_required_elevator_features(sdkp->disk->queue,
+					     ELEVATOR_F_ZONED_BLOCK_DEV);
 	blk_queue_chunk_sectors(sdkp->disk->queue,
 			logical_to_sectors(sdkp->device, zone_blocks));
 	blk_queue_flag_set(QUEUE_FLAG_ZONE_RESETALL, sdkp->disk->queue);
diff --git a/include/linux/elevator.h b/include/linux/elevator.h
index a99ca9979d71..2b667cb23fc0 100644
--- a/include/linux/elevator.h
+++ b/include/linux/elevator.h
@@ -166,5 +166,12 @@  extern struct request *elv_rb_find(struct rb_root *, sector_t);
 #define rq_entry_fifo(ptr)	list_entry((ptr), struct request, queuelist)
 #define rq_fifo_clear(rq)	list_del_init(&(rq)->queuelist)
 
+/*
+ * Elevator features.
+ */
+
+/* Supports zoned block devices sequential write */
+#define ELEVATOR_F_ZONED_BLOCK_DEV	(1UL << 0)
+
 #endif /* CONFIG_BLOCK */
 #endif