Skip to content

Commit 1b6d65a

Browse files
KAGA-KOKOaxboe
authored andcommitted
block: Introduce BLK_MQ_REQ_PREEMPT
Set RQF_PREEMPT if BLK_MQ_REQ_PREEMPT is passed to blk_get_request_flags(). Signed-off-by: Bart Van Assche <bart.vanassche@wdc.com> Reviewed-by: Hannes Reinecke <hare@suse.com> Tested-by: Martin Steigerwald <martin@lichtvoll.de> Tested-by: Oleksandr Natalenko <oleksandr@natalenko.name> Cc: Christoph Hellwig <hch@lst.de> Cc: Ming Lei <ming.lei@redhat.com> Cc: Johannes Thumshirn <jthumshirn@suse.de> Signed-off-by: Jens Axboe <axboe@kernel.dk>
1 parent 6a15674 commit 1b6d65a

File tree

3 files changed

+6
-1
lines changed

3 files changed

+6
-1
lines changed

block/blk-core.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1263,6 +1263,8 @@ static struct request *__get_request(struct request_list *rl, unsigned int op,
12631263
blk_rq_set_rl(rq, rl);
12641264
rq->cmd_flags = op;
12651265
rq->rq_flags = rq_flags;
1266+
if (flags & BLK_MQ_REQ_PREEMPT)
1267+
rq->rq_flags |= RQF_PREEMPT;
12661268

12671269
/* init elvpriv */
12681270
if (rq_flags & RQF_ELVPRIV) {
@@ -1444,7 +1446,7 @@ struct request *blk_get_request_flags(struct request_queue *q, unsigned int op,
14441446
struct request *req;
14451447

14461448
WARN_ON_ONCE(op & REQ_NOWAIT);
1447-
WARN_ON_ONCE(flags & ~BLK_MQ_REQ_NOWAIT);
1449+
WARN_ON_ONCE(flags & ~(BLK_MQ_REQ_NOWAIT | BLK_MQ_REQ_PREEMPT));
14481450

14491451
if (q->mq_ops) {
14501452
req = blk_mq_alloc_request(q, op, flags);

block/blk-mq.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -291,6 +291,8 @@ static struct request *blk_mq_rq_ctx_init(struct blk_mq_alloc_data *data,
291291
rq->q = data->q;
292292
rq->mq_ctx = data->ctx;
293293
rq->cmd_flags = op;
294+
if (data->flags & BLK_MQ_REQ_PREEMPT)
295+
rq->rq_flags |= RQF_PREEMPT;
294296
if (blk_queue_io_stat(data->q))
295297
rq->rq_flags |= RQF_IO_STAT;
296298
/* do not touch atomic flags, it needs atomic ops against the timer */

include/linux/blk-mq.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,7 @@ enum {
212212
BLK_MQ_REQ_NOWAIT = (1 << 0), /* return when out of requests */
213213
BLK_MQ_REQ_RESERVED = (1 << 1), /* allocate from reserved pool */
214214
BLK_MQ_REQ_INTERNAL = (1 << 2), /* allocate internal/sched tag */
215+
BLK_MQ_REQ_PREEMPT = (1 << 3), /* set RQF_PREEMPT */
215216
};
216217

217218
struct request *blk_mq_alloc_request(struct request_queue *q, unsigned int op,

0 commit comments

Comments
 (0)