From patchwork Mon Jan 22 03:35:47 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ming Lei X-Patchwork-Id: 10177225 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 D90A4601D5 for ; Mon, 22 Jan 2018 03:36:50 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DA18B20407 for ; Mon, 22 Jan 2018 03:36:50 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id CF1FD26223; Mon, 22 Jan 2018 03:36:50 +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 849F820407 for ; Mon, 22 Jan 2018 03:36:50 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 6C96BC01F29E; Mon, 22 Jan 2018 03:36:49 +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 48D17608F2; Mon, 22 Jan 2018 03:36:49 +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 00E01180CB22; Mon, 22 Jan 2018 03:36:48 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w0M3amsX028277 for ; Sun, 21 Jan 2018 22:36:48 -0500 Received: by smtp.corp.redhat.com (Postfix) id 3BB4167DF5; Mon, 22 Jan 2018 03:36:48 +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 1BC0067DF0; Mon, 22 Jan 2018 03:36:30 +0000 (UTC) From: Ming Lei To: Jens Axboe , linux-block@vger.kernel.org, Christoph Hellwig , Mike Snitzer Date: Mon, 22 Jan 2018 11:35:47 +0800 Message-Id: <20180122033550.27855-3-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.14 X-loop: dm-devel@redhat.com Cc: Bart Van Assche , dm-devel@redhat.com, Laurence Oberman , Ming Lei Subject: [dm-devel] [PATCH 2/5] dm-rq: handle dispatch exception in dm_dispatch_clone_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.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Mon, 22 Jan 2018 03:36:49 +0000 (UTC) X-Virus-Scanned: ClamAV using ClamSMTP So we can clean up map_request() a bit, no functional change. Cc: Mike Snitzer Cc: Laurence Oberman Cc: Bart Van Assche Signed-off-by: Ming Lei --- drivers/md/dm-rq.c | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/drivers/md/dm-rq.c b/drivers/md/dm-rq.c index e0bb56723b9b..1408e6664c16 100644 --- a/drivers/md/dm-rq.c +++ b/drivers/md/dm-rq.c @@ -12,6 +12,9 @@ #define DM_MSG_PREFIX "core-rq" +#define dispatch_busy(r) \ + (((r) == BLK_STS_RESOURCE) || ((r) == BLK_STS_DEV_RESOURCE)) + #define DM_MQ_NR_HW_QUEUES 1 #define DM_MQ_QUEUE_DEPTH 2048 static unsigned dm_mq_nr_hw_queues = DM_MQ_NR_HW_QUEUES; @@ -399,7 +402,8 @@ static void end_clone_request(struct request *clone, blk_status_t error) dm_complete_request(tio->orig, error); } -static blk_status_t dm_dispatch_clone_request(struct request *clone, struct request *rq) +static blk_status_t dm_dispatch_clone_request(struct dm_rq_target_io *tio, + struct request *clone, struct request *rq) { blk_status_t r; @@ -408,9 +412,17 @@ static blk_status_t dm_dispatch_clone_request(struct request *clone, struct requ clone->start_time = jiffies; r = blk_insert_cloned_request(clone->q, clone); - if (r != BLK_STS_OK && r != BLK_STS_RESOURCE) + if (dispatch_busy(r)) { + blk_rq_unprep_clone(clone); + tio->ti->type->release_clone_rq(clone); + tio->clone = NULL; + } else if (r != BLK_STS_OK) { /* must complete clone in terms of original request */ dm_complete_request(rq, r); + + /* we handled the failure, so return OK */ + r = BLK_STS_OK; + } return r; } @@ -499,11 +511,8 @@ static int map_request(struct dm_rq_target_io *tio) /* The target has remapped the I/O so dispatch it */ trace_block_rq_remap(clone->q, clone, disk_devt(dm_disk(md)), blk_rq_pos(rq)); - ret = dm_dispatch_clone_request(clone, rq); - if (ret == BLK_STS_RESOURCE || ret == BLK_STS_DEV_RESOURCE) { - blk_rq_unprep_clone(clone); - tio->ti->type->release_clone_rq(clone); - tio->clone = NULL; + ret = dm_dispatch_clone_request(tio, clone, rq); + if (dispatch_busy(ret)) { if (!rq->q->mq_ops) r = DM_MAPIO_DELAY_REQUEUE; else