@@ -3008,9 +3008,19 @@ blk_status_t blk_insert_cloned_request(struct request *rq)
blk_account_io_start(rq);
/*
- * Since we have a scheduler attached on the top device,
- * bypass a potential scheduler on the bottom device for
- * insert.
+ * Send zoned writes to the I/O scheduler if an I/O scheduler has been
+ * attached.
+ */
+ if (q->elevator && blk_rq_is_seq_zoned_write(rq)) {
+ blk_mq_sched_insert_request(rq, /*at_head=*/false,
+ /*run_queue=*/true,
+ /*async=*/false);
+ return BLK_STS_OK;
+ }
+
+ /*
+ * If no I/O scheduler has been attached or if the request is not a
+ * zoned write bypass the I/O scheduler attached to the bottom device.
*/
blk_mq_run_dispatch_ops(q,
ret = blk_mq_request_issue_directly(rq, true));
@@ -118,6 +118,25 @@ static inline bool bvec_gap_to_prev(const struct queue_limits *lim,
return __bvec_gap_to_prev(lim, bprv, offset);
}
+/**
+ * blk_rq_is_seq_zoned_write() - Whether @rq is a write request for a sequential zone.
+ * @rq: Request to examine.
+ *
+ * In this context sequential zone means either a sequential write required or
+ * to a sequential write preferred zone.
+ */
+static inline bool blk_rq_is_seq_zoned_write(struct request *rq)
+{
+ switch (req_op(rq)) {
+ case REQ_OP_WRITE:
+ case REQ_OP_WRITE_ZEROES:
+ return disk_zone_is_seq(rq->q->disk, blk_rq_pos(rq));
+ case REQ_OP_ZONE_APPEND:
+ default:
+ return false;
+ }
+}
+
static inline bool rq_mergeable(struct request *rq)
{
if (blk_rq_is_passthrough(rq))
Send zoned writes inserted by the device mapper to the I/O scheduler. This prevents that zoned writes get reordered if a device mapper driver has been stacked on top of a driver for a zoned block device. Cc: Christoph Hellwig <hch@lst.de> Cc: Damien Le Moal <damien.lemoal@opensource.wdc.com> Cc: Ming Lei <ming.lei@redhat.com> Cc: Mike Snitzer <snitzer@kernel.org> Signed-off-by: Bart Van Assche <bvanassche@acm.org> --- block/blk-mq.c | 16 +++++++++++++--- block/blk.h | 19 +++++++++++++++++++ 2 files changed, 32 insertions(+), 3 deletions(-)