From: Ming Lei <ming.lei@redhat.com>
To: Jens Axboe <axboe@kernel.dk>,
linux-block@vger.kernel.org,
Christoph Hellwig <hch@infradead.org>,
Mike Snitzer <snitzer@redhat.com>
Cc: Bart Van Assche <bart.vanassche@sandisk.com>,
dm-devel@redhat.com, Laurence Oberman <loberman@redhat.com>,
Ming Lei <ming.lei@redhat.com>
Subject: [PATCH 3/5] dm-rq: return BLK_STS_* from map_request()
Date: Mon, 22 Jan 2018 11:35:48 +0800 [thread overview]
Message-ID: <20180122033550.27855-4-ming.lei@redhat.com> (raw)
In-Reply-To: <20180122033550.27855-1-ming.lei@redhat.com>
Except for DM_MAPIO_REQUEUE, map_request() handles other dispatch exception
already, so return BLK_STS_* from map_request() directly.
Another change is that if dm_dispatch_clone_request() returns
BLK_STS_DEV_RESOURCE from underlying queue, this status is returned
to blk-mq too, since underlying queue's RESTART can handle dm-rq's
RESTART in this case.
Cc: Mike Snitzer <snitzer@redhat.com>
Cc: Laurence Oberman <loberman@redhat.com>
Cc: Bart Van Assche <bart.vanassche@sandisk.com>
Signed-off-by: Ming Lei <ming.lei@redhat.com>
---
drivers/md/dm-rq.c | 30 +++++++++++++++++-------------
1 file changed, 17 insertions(+), 13 deletions(-)
diff --git a/drivers/md/dm-rq.c b/drivers/md/dm-rq.c
index 1408e6664c16..830e1ccfbb44 100644
--- a/drivers/md/dm-rq.c
+++ b/drivers/md/dm-rq.c
@@ -482,9 +482,10 @@ static void init_tio(struct dm_rq_target_io *tio, struct request *rq,
/*
* Returns:
- * DM_MAPIO_* : the request has been processed as indicated
- * DM_MAPIO_REQUEUE : the original request needs to be immediately requeued
- * < 0 : the request was completed due to failure
+ * BLK_STS_OK : the request has been processed aready, no need to
+ * ask block layer to handle it any more
+ * BLK_STS_RESOURCE : the original request needs to be immediately requeued
+ * BLK_STS_DEV_RESOURCE : same with BLK_STS_RESOURCE, but blk-mq need this info
*/
static int map_request(struct dm_rq_target_io *tio)
{
@@ -493,7 +494,7 @@ static int map_request(struct dm_rq_target_io *tio)
struct mapped_device *md = tio->md;
struct request *rq = tio->orig;
struct request *clone = NULL;
- blk_status_t ret;
+ blk_status_t ret, result = BLK_STS_OK;
r = ti->type->clone_and_map_rq(ti, rq, &tio->info, &clone);
check_again:
@@ -513,15 +514,16 @@ static int map_request(struct dm_rq_target_io *tio)
blk_rq_pos(rq));
ret = dm_dispatch_clone_request(tio, clone, rq);
if (dispatch_busy(ret)) {
- if (!rq->q->mq_ops)
+ if (!rq->q->mq_ops) {
r = DM_MAPIO_DELAY_REQUEUE;
- else
- r = DM_MAPIO_REQUEUE;
- goto check_again;
+ goto check_again;
+ }
+ result = ret;
}
break;
case DM_MAPIO_REQUEUE:
/* The target wants to requeue the I/O */
+ result = BLK_STS_RESOURCE;
break;
case DM_MAPIO_DELAY_REQUEUE:
/* The target wants to requeue the I/O after a delay */
@@ -536,7 +538,7 @@ static int map_request(struct dm_rq_target_io *tio)
BUG();
}
- return r;
+ return result;
}
static void dm_start_request(struct mapped_device *md, struct request *orig)
@@ -599,7 +601,7 @@ static void map_tio_request(struct kthread_work *work)
{
struct dm_rq_target_io *tio = container_of(work, struct dm_rq_target_io, work);
- if (map_request(tio) == DM_MAPIO_REQUEUE)
+ if (dispatch_busy(map_request(tio)))
dm_requeue_original_request(tio, false);
}
@@ -754,6 +756,7 @@ static blk_status_t dm_mq_queue_rq(struct blk_mq_hw_ctx *hctx,
struct dm_rq_target_io *tio = blk_mq_rq_to_pdu(rq);
struct mapped_device *md = tio->md;
struct dm_target *ti = md->immutable_target;
+ blk_status_t ret;
if (unlikely(!ti)) {
int srcu_idx;
@@ -777,14 +780,15 @@ static blk_status_t dm_mq_queue_rq(struct blk_mq_hw_ctx *hctx,
tio->ti = ti;
/* Direct call is fine since .queue_rq allows allocations */
- if (map_request(tio) == DM_MAPIO_REQUEUE) {
+ ret = map_request(tio);
+ if (dispatch_busy(ret)) {
/* Undo dm_start_request() before requeuing */
rq_end_stats(md, rq);
rq_completed(md, rq_data_dir(rq), false);
- return BLK_STS_RESOURCE;
+ return ret;
}
- return BLK_STS_OK;
+ return ret;
}
static const struct blk_mq_ops dm_mq_ops = {
--
2.9.5
next prev parent reply other threads:[~2018-01-22 3:35 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-01-22 3:35 [PATCH 0/5] blk-mq & dm: fix IO hang and deal with one performance issue Ming Lei
2018-01-22 3:35 ` [PATCH 1/5] blk-mq: introduce BLK_STS_DEV_RESOURCE Ming Lei
2018-01-22 16:32 ` Christoph Hellwig
2018-01-22 16:49 ` Bart Van Assche
2018-01-23 0:57 ` Ming Lei
2018-01-23 16:17 ` Bart Van Assche
2018-01-23 16:26 ` Ming Lei
2018-01-23 16:37 ` Bart Van Assche
2018-01-23 16:41 ` Ming Lei
2018-01-23 16:47 ` Bart Van Assche
2018-01-23 16:49 ` Ming Lei
2018-01-23 16:54 ` Bart Van Assche
2018-01-23 16:59 ` Ming Lei
2018-01-23 22:01 ` Bart Van Assche
2018-01-24 2:31 ` Ming Lei
2018-01-22 3:35 ` [PATCH 2/5] dm-rq: handle dispatch exception in dm_dispatch_clone_request() Ming Lei
2018-01-22 3:35 ` Ming Lei [this message]
2018-01-22 5:35 ` [PATCH 3/5] dm-rq: return BLK_STS_* from map_request() Ming Lei
2018-01-22 3:35 ` [PATCH 4/5] blk-mq: introduce blk_get_request_notify Ming Lei
2018-01-22 10:19 ` Ming Lei
2018-01-22 17:13 ` Bart Van Assche
2018-01-23 1:29 ` Ming Lei
2018-01-22 3:35 ` [PATCH 5/5] dm-mpath: use blk_mq_alloc_request_notify for allocating blk-mq req 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=20180122033550.27855-4-ming.lei@redhat.com \
--to=ming.lei@redhat.com \
--cc=axboe@kernel.dk \
--cc=bart.vanassche@sandisk.com \
--cc=dm-devel@redhat.com \
--cc=hch@infradead.org \
--cc=linux-block@vger.kernel.org \
--cc=loberman@redhat.com \
--cc=snitzer@redhat.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).