Skip to content

Commit

Permalink
block: Introduce BLK_MQ_REQ_PREEMPT
Browse files Browse the repository at this point in the history
Set RQF_PREEMPT if BLK_MQ_REQ_PREEMPT is passed to
blk_get_request_flags().

Signed-off-by: Bart Van Assche <[email protected]>
Reviewed-by: Hannes Reinecke <[email protected]>
Tested-by: Martin Steigerwald <[email protected]>
Tested-by: Oleksandr Natalenko <[email protected]>
Cc: Christoph Hellwig <[email protected]>
Cc: Ming Lei <[email protected]>
Cc: Johannes Thumshirn <[email protected]>
Signed-off-by: Jens Axboe <[email protected]>
  • Loading branch information
KAGA-KOKO authored and axboe committed Nov 11, 2017
1 parent 6a15674 commit 1b6d65a
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 1 deletion.
4 changes: 3 additions & 1 deletion block/blk-core.c
Original file line number Diff line number Diff line change
Expand Up @@ -1263,6 +1263,8 @@ static struct request *__get_request(struct request_list *rl, unsigned int op,
blk_rq_set_rl(rq, rl);
rq->cmd_flags = op;
rq->rq_flags = rq_flags;
if (flags & BLK_MQ_REQ_PREEMPT)
rq->rq_flags |= RQF_PREEMPT;

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

WARN_ON_ONCE(op & REQ_NOWAIT);
WARN_ON_ONCE(flags & ~BLK_MQ_REQ_NOWAIT);
WARN_ON_ONCE(flags & ~(BLK_MQ_REQ_NOWAIT | BLK_MQ_REQ_PREEMPT));

if (q->mq_ops) {
req = blk_mq_alloc_request(q, op, flags);
Expand Down
2 changes: 2 additions & 0 deletions block/blk-mq.c
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,8 @@ static struct request *blk_mq_rq_ctx_init(struct blk_mq_alloc_data *data,
rq->q = data->q;
rq->mq_ctx = data->ctx;
rq->cmd_flags = op;
if (data->flags & BLK_MQ_REQ_PREEMPT)
rq->rq_flags |= RQF_PREEMPT;
if (blk_queue_io_stat(data->q))
rq->rq_flags |= RQF_IO_STAT;
/* do not touch atomic flags, it needs atomic ops against the timer */
Expand Down
1 change: 1 addition & 0 deletions include/linux/blk-mq.h
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,7 @@ enum {
BLK_MQ_REQ_NOWAIT = (1 << 0), /* return when out of requests */
BLK_MQ_REQ_RESERVED = (1 << 1), /* allocate from reserved pool */
BLK_MQ_REQ_INTERNAL = (1 << 2), /* allocate internal/sched tag */
BLK_MQ_REQ_PREEMPT = (1 << 3), /* set RQF_PREEMPT */
};

struct request *blk_mq_alloc_request(struct request_queue *q, unsigned int op,
Expand Down

0 comments on commit 1b6d65a

Please sign in to comment.