From patchwork Mon Jan 22 03:35:48 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ming Lei X-Patchwork-Id: 10177229 X-Patchwork-Delegate: snitzer@redhat.com Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id BE5316055D for ; Mon, 22 Jan 2018 03:37:06 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BFC761FEBA for ; Mon, 22 Jan 2018 03:37:06 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B4D65260CD; Mon, 22 Jan 2018 03:37:06 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=unavailable version=3.3.1 Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 5C49126223 for ; Mon, 22 Jan 2018 03:37:06 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 9F726C0587CB; Mon, 22 Jan 2018 03:37:05 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 7E0766444D; Mon, 22 Jan 2018 03:37:05 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 56B3E180CB23; Mon, 22 Jan 2018 03:37:05 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w0M3b4kr028305 for ; Sun, 21 Jan 2018 22:37:04 -0500 Received: by smtp.corp.redhat.com (Postfix) id AFB9387C4; Mon, 22 Jan 2018 03:37:04 +0000 (UTC) Delivered-To: dm-devel@redhat.com Received: from localhost (ovpn-12-18.pek2.redhat.com [10.72.12.18]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0DC0687BF; Mon, 22 Jan 2018 03:36:49 +0000 (UTC) From: Ming Lei To: Jens Axboe , linux-block@vger.kernel.org, Christoph Hellwig , Mike Snitzer Date: Mon, 22 Jan 2018 11:35:48 +0800 Message-Id: <20180122033550.27855-4-ming.lei@redhat.com> In-Reply-To: <20180122033550.27855-1-ming.lei@redhat.com> References: <20180122033550.27855-1-ming.lei@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: dm-devel@redhat.com Cc: Bart Van Assche , dm-devel@redhat.com, Laurence Oberman , Ming Lei Subject: [dm-devel] [PATCH 3/5] dm-rq: return BLK_STS_* from map_request() X-BeenThere: dm-devel@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: device-mapper development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: dm-devel-bounces@redhat.com Errors-To: dm-devel-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Mon, 22 Jan 2018 03:37:05 +0000 (UTC) X-Virus-Scanned: ClamAV using ClamSMTP 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 Cc: Laurence Oberman Cc: Bart Van Assche Signed-off-by: Ming Lei --- 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 = {