blk-mq: don't clear RQF_MQ_INFLIGHT in blk_mq_rq_ctx_init()
PATCH 1/1 blk-mq: don't clear RQF_MQ_INFLIGHT in blk_mq_rq_ctx_init()
In case of no IO scheduler, RQF_MQ_INFLIGHT is set in blk_mq_rq_ctx_init(), but 7c3fb70f0341 clears it mistakenly, so fix it.
This patch fixes systemd-udevd hang when starting multipathd service:
[ 914.409660] systemd-journald[213]: Successfully sent stream file descriptor to service manager. [ 984.028104] INFO: task systemd-udevd:1518 blocked for more than 120 seconds. [ 984.030916] Not tainted 4.15.0-rc6+ #62 [ 984.032709] "echo 0 > /proc/sys/kernel/hung_task_timeout_secs" disables this message. [ 984.035818] systemd-udevd D 0 1518 232 0x80000006 [ 984.035826] Call Trace: [ 984.035846] ? __schedule+0x626/0x759 [ 984.035855] schedule+0x88/0x9b [ 984.035861] io_schedule+0x12/0x33 [ 984.035867] __lock_page+0xef/0x127 [ 984.035874] ? add_to_page_cache_lru+0xd4/0xd4 [ 984.035889] truncate_inode_pages_range+0x533/0x62f [ 984.035929] ? cpumask_next+0x17/0x18 [ 984.035937] ? cpumask_next+0x17/0x18 [ 984.035943] ? smp_call_function_many+0x1e4/0x218 [ 984.035949] ? __find_get_block+0x2ba/0x2ba [ 984.035961] ? __find_get_block+0x216/0x2ba [ 984.035977] ? on_each_cpu_cond+0xbf/0x143 [ 984.035992] __blkdev_put+0x69/0x1a5 [ 984.036009] blkdev_close+0x21/0x24 [ 984.036025] __fput+0xdb/0x18a [ 984.036039] task_work_run+0x6f/0x80 [ 984.036048] do_exit+0x452/0x96b [ 984.036055] ? preempt_count_add+0x7a/0x8c [ 984.036061] do_group_exit+0x3c/0x98 [ 984.036067] get_signal+0x47c/0x4fd [ 984.036076] do_signal+0x36/0x51f [ 984.036090] exit_to_usermode_loop+0x3a/0x73 [ 984.036096] syscall_return_slowpath+0x97/0xcf [ 984.036103] entry_SYSCALL_64_fastpath+0x7b/0x7d [ 984.036109] RIP: 0033:0x7f2ffce94540 [ 984.036112] RSP: 002b:00007ffffd1cb888 EFLAGS: 00000246 ORIG_RAX: 0000000000000000 [ 984.036117] RAX: fffffffffffffffc RBX: 000055d9840e72d0 RCX: 00007f2ffce94540 [ 984.036120] RDX: 0000000000000018 RSI: 000055d9840e72f8 RDI: 0000000000000007 [ 984.036122] RBP: 000055d984111860 R08: 000055d9840e72d0 R09: 0000000000000092 [ 984.036125] R10: 00007f2ffce7ebb8 R11: 0000000000000246 R12: 0000000000000018 [ 984.036127] R13: 000000020014e200 R14: 000055d9841118b0 R15: 000055d9840e72e8 [ 1034.410125] systemd-journald[213]: Sent WATCHDOG=1 notification.
--- block/blk-mq.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
block/blk-mq.c +3 -2
@@ -269,13 +269,14 @@ static struct request *blk_mq_rq_ctx_init(struct blk_mq_alloc_data *data, {struct blk_mq_tags *tags =blk_mq_tags_from_data (data);struct request *rq = tags->static_rqs[tag]; +bool inflight = false;if (data->flags &BLK_MQ_REQ_INTERNAL ) { rq->tag =-1 ; rq->internal_tag = tag; }else {if (blk_mq_tag_busy (data->hctx)) { - rq->rq_flags =RQF_MQ_INFLIGHT ; + inflight = true;atomic_inc (&data->hctx->nr_active); } rq->tag = tag;
@@ -286,7 +287,7 @@ static struct request *blk_mq_rq_ctx_init(struct blk_mq_alloc_data *data,/* csd/requeue_work/fifo_time is initialized before use */ rq->q = data->q; rq->mq_ctx = data->ctx; - rq->rq_flags =0 ; + rq->rq_flags = inflight ?RQF_MQ_INFLIGHT :0 ; rq->cpu =-1 ; rq->cmd_flags = op;if (data->flags &BLK_MQ_REQ_PREEMPT )
Signature · 1 line
2.9.5
Jens Axboe
maintainerQuoted 2 lines · Ming Lei
In case of no IO scheduler,
RQF_MQ_INFLIGHTis set inblk_mq_rq_ctx_init(), but7c3fb70f0341clears it mistakenly, so fix it.
Oops yeah, that's my bad. However, I think the below fix is cleaner and avoids a conditional.
block/blk-mq.c +3 -2
@@ -269,13 +269,14 @@ static struct request *blk_mq_rq_ctx_init(struct blk_mq_alloc_data *data, {struct blk_mq_tags *tags =blk_mq_tags_from_data (data);struct request *rq = tags->static_rqs[tag]; +req_flags_t rq_flags =0 ;if (data->flags &BLK_MQ_REQ_INTERNAL ) { rq->tag =-1 ; rq->internal_tag = tag; }else {if (blk_mq_tag_busy (data->hctx)) { - rq->rq_flags =RQF_MQ_INFLIGHT ; + rq_flags =RQF_MQ_INFLIGHT ;atomic_inc (&data->hctx->nr_active); } rq->tag = tag;
@@ -286,7 +287,7 @@ static struct request *blk_mq_rq_ctx_init(struct blk_mq_alloc_data *data,/* csd/requeue_work/fifo_time is initialized before use */ rq->q = data->q; rq->mq_ctx = data->ctx; - rq->rq_flags =0 ; + rq->rq_flags = rq_flags; rq->cpu =-1 ; rq->cmd_flags = op;if (data->flags &BLK_MQ_REQ_PREEMPT )
Signature · 5 lines
Jens Axboe -- Jens Axboe
Mike Snitzer
Reviewed-byQuoted 29 lines · Jens Axboe
Quoted 2 lines · Ming Lei
In case of no IO scheduler,
RQF_MQ_INFLIGHTis set inblk_mq_rq_ctx_init(), but7c3fb70f0341clears it mistakenly, so fix it.Oops yeah, that's my bad. However, I think the below fix is cleaner and avoids a conditional.
block/blk-mq.c +2
-1@@ -269,13 +269,14 @@ static struct request *blk_mq_rq_ctx_init(struct blk_mq_alloc_data *data, {struct blk_mq_tags *tags =blk_mq_tags_from_data (data);struct request *rq = tags->static_rqs[tag]; +req_flags_t rq_flags =0 ;if (data->flags &BLK_MQ_REQ_INTERNAL ) { rq->tag =-1 ; rq->internal_tag = tag; }else {if (blk_mq_tag_busy (data->hctx)) { - rq->rq_flags =RQF_MQ_INFLIGHT ; + rq_flags =RQF_MQ_INFLIGHT ;atomic_inc (&data->hctx->nr_active); } rq->tag = tag;
block/blk-mq.c static struct request *blk_mq_rq_ctx_init(struct blk_mq_alloc_data *data, · line 293
Quoted 8 lines
block/blk-mq.c +1
-1@@ -286,7 +287,7 @@ static struct request *blk_mq_rq_ctx_init(struct blk_mq_alloc_data *data,/* csd/requeue_work/fifo_time is initialized before use */ rq->q = data->q; rq->mq_ctx = data->ctx; - rq->rq_flags =0 ; + rq->rq_flags = rq_flags; rq->cpu =-1 ; rq->cmd_flags = op;if (data->flags &BLK_MQ_REQ_PREEMPT )
Yeap, looks good.
Defintely need this fix, without it all my dm-mpath testing hangs
Thanks,
Mike
Jens Axboe
maintainerQuoted 43 lines · Mike Snitzer
Quoted 29 lines · Jens Axboe
Quoted 2 lines · Ming Lei
In case of no IO scheduler,
RQF_MQ_INFLIGHTis set inblk_mq_rq_ctx_init(), but7c3fb70f0341clears it mistakenly, so fix it.Oops yeah, that's my bad. However, I think the below fix is cleaner and avoids a conditional.
block/blk-mq.c +2
-1@@ -269,13 +269,14 @@ static struct request *blk_mq_rq_ctx_init(struct blk_mq_alloc_data *data, {struct blk_mq_tags *tags =blk_mq_tags_from_data (data);struct request *rq = tags->static_rqs[tag]; +req_flags_t rq_flags =0 ;if (data->flags &BLK_MQ_REQ_INTERNAL ) { rq->tag =-1 ; rq->internal_tag = tag; }else {if (blk_mq_tag_busy (data->hctx)) { - rq->rq_flags =RQF_MQ_INFLIGHT ; + rq_flags =RQF_MQ_INFLIGHT ;atomic_inc (&data->hctx->nr_active); } rq->tag = tag;block/blk-mq.c static struct request *blk_mq_rq_ctx_init(struct blk_mq_alloc_data *data, · line 293
Quoted 8 lines
block/blk-mq.c +1
-1@@ -286,7 +287,7 @@ static struct request *blk_mq_rq_ctx_init(struct blk_mq_alloc_data *data,/* csd/requeue_work/fifo_time is initialized before use */ rq->q = data->q; rq->mq_ctx = data->ctx; - rq->rq_flags =0 ; + rq->rq_flags = rq_flags; rq->cpu =-1 ; rq->cmd_flags = op;if (data->flags &BLK_MQ_REQ_PREEMPT )Yeap, looks good.
Quoted 3 lines
Reviewed-by Mike Snitzer <[email protected]>Defintely need this fix, without it all my dm-mpath testing hangs
Yeah, pretty unfortunate... I've applied it and pushed it out.
Signature · 1 line
Jens Axboe