From: Mike Snitzer <snitzer@redhat.com>
To: Bart Van Assche <Bart.VanAssche@wdc.com>,
Laurence Oberman <loberman@redhat.com>
Cc: "axboe@kernel.dk" <axboe@kernel.dk>, "hch@lst.de" <hch@lst.de>,
"dm-devel@redhat.com" <dm-devel@redhat.com>,
"linux-block@vger.kernel.org" <linux-block@vger.kernel.org>,
"tom.leiming@gmail.com" <tom.leiming@gmail.com>
Subject: [PATCH] blk mq: don't blk_mq_request_bypass_insert _and_ return BLK_STS_RESOURCE
Date: Wed, 17 Jan 2018 22:33:35 -0500 [thread overview]
Message-ID: <20180118033334.GA30338@redhat.com> (raw)
In-Reply-To: <20180118005452.GB7649@redhat.com>
On Wed, Jan 17 2018 at 7:54P -0500,
Mike Snitzer <snitzer@redhat.com> wrote:
> But sure, I suppose there is something I missed when refactoring Ming's
> change to get it acceptable for upstream. I went over the mechanical
> nature of what I did many times (comparing Ming's v4 to my v5).
And yes there is one subtlety that I missed.
> The call to blk_mq_request_bypass_insert will only occur via
> __blk_mq_fallback_to_insert. Which as the name implies this is not the
> fast path. This will occur if the underlying blk-mq device cannot get
> resources it needs in order to issue the request. Specifically: if/when
> in __blk_mq_try_issue_directly() the hctx is stopped, or queue is
> quiesced, or it cannot get the driver tag or dispatch_budget (in the
> case of scsi-mq).
>
> The same fallback, via call to blk_mq_request_bypass_insert, occured
> with Ming's v4 though.
Turns out Ming's v4 doesn't fallback to insert for the "or it cannot get
the driver tag or dispatch_budget" case.
This patch should fix it (Laurence, please report back on if this fixes
your list_add corruption, pretty sure it will):
From: Mike Snitzer <snitzer@redhat.com>
Date: Wed, 17 Jan 2018 22:02:07 -0500
Subject: [PATCH] blk mq: don't blk_mq_request_bypass_insert _and_ return BLK_STS_RESOURCE
It isn't ever valid to call blk_mq_request_bypass_insert() and return
BLK_STS_RESOURCE.
Unfortunately after commit 396eaf21ee ("blk-mq: improve DM's blk-mq IO
merging via blk_insert_cloned_request feedback") we do just that if
blk_mq_request_direct_issue() cannot get the resources (driver_tag or
dispatch_budget) needed to directly issue a request. This will lead to
"list_add corruption" because blk-mq submits the IO but then reports
that it didn't (BLK_STS_RESOURCE in this case).
Fix this by simply returning BLK_STS_RESOURCE for this case.
Fixes: 396eaf21ee ("blk-mq: improve DM's blk-mq IO merging via blk_insert_cloned_request feedback")
Reported-by: Laurence Oberman <loberman@redhat.com>
Signed-off-by: Mike Snitzer <snitzer@redhat.com>
---
block/blk-mq.c | 12 +++++-------
1 file changed, 5 insertions(+), 7 deletions(-)
diff --git a/block/blk-mq.c b/block/blk-mq.c
index c418858a60ef..8bee37239255 100644
--- a/block/blk-mq.c
+++ b/block/blk-mq.c
@@ -1799,20 +1799,18 @@ static blk_status_t __blk_mq_try_issue_directly(struct blk_mq_hw_ctx *hctx,
if (q->elevator && !bypass_insert)
goto insert;
- if (!blk_mq_get_driver_tag(rq, NULL, false))
- goto insert;
-
- if (!blk_mq_get_dispatch_budget(hctx)) {
+ if (!blk_mq_get_driver_tag(rq, NULL, false) ||
+ !blk_mq_get_dispatch_budget(hctx)) {
+ /* blk_mq_put_driver_tag() is idempotent */
blk_mq_put_driver_tag(rq);
+ if (bypass_insert)
+ return BLK_STS_RESOURCE;
goto insert;
}
return __blk_mq_issue_directly(hctx, rq, cookie);
insert:
__blk_mq_fallback_to_insert(rq, run_queue, bypass_insert);
- if (bypass_insert)
- return BLK_STS_RESOURCE;
-
return BLK_STS_OK;
}
--
2.15.0
next prev parent reply other threads:[~2018-01-18 3:33 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-01-17 16:25 [for-4.16 PATCH v6 0/3] blk-mq: improve DM's blk-mq IO merging via blk_insert_cloned_request feedback Mike Snitzer
2018-01-17 16:25 ` [for-4.16 PATCH v6 1/3] blk-mq: factor out a few helpers from __blk_mq_try_issue_directly Mike Snitzer
2018-01-17 16:25 ` [for-4.16 PATCH v6 2/3] blk-mq: improve DM's blk-mq IO merging via blk_insert_cloned_request feedback Mike Snitzer
2018-01-18 3:25 ` Ming Lei
2018-01-18 3:37 ` Mike Snitzer
2018-01-18 3:44 ` Ming Lei
2018-01-17 16:25 ` [for-4.16 PATCH v6 3/3] blk-mq-sched: remove unused 'can_block' arg from blk_mq_sched_insert_request Mike Snitzer
2018-01-17 16:50 ` [for-4.16 PATCH v6 0/3] blk-mq: improve DM's blk-mq IO merging via blk_insert_cloned_request feedback Jens Axboe
2018-01-17 16:58 ` Mike Snitzer
2018-01-17 23:31 ` Bart Van Assche
2018-01-17 23:43 ` Laurence Oberman
2018-01-17 23:53 ` Bart Van Assche
2018-01-17 23:57 ` Laurence Oberman
2018-01-18 0:12 ` Laurence Oberman
2018-01-18 0:54 ` Mike Snitzer
2018-01-18 3:33 ` Mike Snitzer [this message]
2018-01-18 3:39 ` [PATCH] blk mq: don't blk_mq_request_bypass_insert _and_ return BLK_STS_RESOURCE Ming Lei
2018-01-18 3:49 ` Mike Snitzer
2018-01-18 3:52 ` Ming Lei
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20180118033334.GA30338@redhat.com \
--to=snitzer@redhat.com \
--cc=Bart.VanAssche@wdc.com \
--cc=axboe@kernel.dk \
--cc=dm-devel@redhat.com \
--cc=hch@lst.de \
--cc=linux-block@vger.kernel.org \
--cc=loberman@redhat.com \
--cc=tom.leiming@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).