Re: [PATCH] blk-mq: don't clear RQF_MQ_INFLIGHT in blk_mq_rq_ctx_init()
On 1/13/18 10:49 AM, Ming Lei wrote: > 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. Oops yeah, that's my bad. However, I think the below fix is cleaner and avoids a conditional. diff --git a/block/blk-mq.c b/block/blk-mq.c index b3b2003b7429..c8f62e6be6b6 100644 --- a/block/blk-mq.c +++ b/block/blk-mq.c @@ -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(>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) -- Jens Axboe -- Jens Axboe
[PATCH] 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 D0 1518232 0x8006 [ 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:7d1cb888 EFLAGS: 0246 ORIG_RAX: [ 984.036117] RAX: fffc RBX: 55d9840e72d0 RCX: 7f2ffce94540 [ 984.036120] RDX: 0018 RSI: 55d9840e72f8 RDI: 0007 [ 984.036122] RBP: 55d984111860 R08: 55d9840e72d0 R09: 0092 [ 984.036125] R10: 7f2ffce7ebb8 R11: 0246 R12: 0018 [ 984.036127] R13: 00020014e200 R14: 55d9841118b0 R15: 55d9840e72e8 [ 1034.410125] systemd-journald[213]: Sent WATCHDOG=1 notification. Cc: Laurence ObermanCc: Mike Snitzer Fixes: 7c3fb70f0341 ("block: rearrange a few request fields for better cache layout") Signed-off-by: Ming Lei --- block/blk-mq.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/block/blk-mq.c b/block/blk-mq.c index ef9beca2d117..c1c74d891ce7 100644 --- a/block/blk-mq.c +++ b/block/blk-mq.c @@ -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(>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) -- 2.9.5