From cd4d66e62ba14b84579aa07f2a2f5a6843b59e99 Mon Sep 17 00:00:00 2001 From: Bart Van Assche Date: Fri, 31 Mar 2023 09:39:07 -0700 Subject: [PATCH] ANDROID: block: Send FUA requests to the I/O scheduler Send requests with the REQ_FUA or REQ_PREFLUSH flag set to the I/O scheduler. Do not change the behavior for REQ_OP_FLUSH requests. This patch prevents that zoned writes with the REQ_FUA and/or REQ_PREFLUSH flag set are reordered against each other. Bug: 275581839 Change-Id: Ib7f18932a066c40f5b76dc69c1864a080350251d Signed-off-by: Bart Van Assche --- block/blk-flush.c | 2 +- block/blk-mq-sched.c | 2 +- block/blk-mq.c | 9 ++++----- 3 files changed, 6 insertions(+), 7 deletions(-) diff --git a/block/blk-flush.c b/block/blk-flush.c index 94a86acbb7f6..79855ebd85ee 100644 --- a/block/blk-flush.c +++ b/block/blk-flush.c @@ -423,7 +423,7 @@ void blk_insert_flush(struct request *rq) */ if ((policy & REQ_FSEQ_DATA) && !(policy & (REQ_FSEQ_PREFLUSH | REQ_FSEQ_POSTFLUSH))) { - blk_mq_request_bypass_insert(rq, false, false); + blk_mq_sched_insert_request(rq, false, false, false); return; } diff --git a/block/blk-mq-sched.c b/block/blk-mq-sched.c index ff5ad2ae3e24..30c64cbe96ea 100644 --- a/block/blk-mq-sched.c +++ b/block/blk-mq-sched.c @@ -425,7 +425,7 @@ static bool blk_mq_sched_bypass_insert(struct request *rq) * passthrough request is added to scheduler queue, there isn't any * chance to dispatch it given we prioritize requests in hctx->dispatch. */ - return (rq->rq_flags & RQF_FLUSH_SEQ) || blk_rq_is_passthrough(rq); + return req_op(rq) == REQ_OP_FLUSH || blk_rq_is_passthrough(rq); } void blk_mq_sched_insert_request(struct request *rq, bool at_head, diff --git a/block/blk-mq.c b/block/blk-mq.c index dd7d1a8b2d3d..d9a27a866c2c 100644 --- a/block/blk-mq.c +++ b/block/blk-mq.c @@ -336,7 +336,7 @@ static struct request *blk_mq_rq_ctx_init(struct blk_mq_alloc_data *data, data->ctx->rq_dispatched[op_is_sync(data->cmd_flags)]++; refcount_set(&rq->ref, 1); - if (!op_is_flush(data->cmd_flags)) { + if ((data->cmd_flags & REQ_OP_MASK) != REQ_OP_FLUSH) { struct elevator_queue *e = data->q->elevator; rq->elv.icq = NULL; @@ -370,11 +370,10 @@ static struct request *__blk_mq_alloc_request(struct blk_mq_alloc_data *data) if (e) { /* - * Flush/passthrough requests are special and go directly to the - * dispatch list. Don't include reserved tags in the - * limiting, as it isn't useful. + * Do not limit the depth for passthrough requests nor for flush + * requests nor for requests with a reserved tag. */ - if (!op_is_flush(data->cmd_flags) && + if ((data->cmd_flags & REQ_OP_MASK) != REQ_OP_FLUSH && !blk_op_is_passthrough(data->cmd_flags) && e->type->ops.limit_depth && !(data->flags & BLK_MQ_REQ_RESERVED))