From mboxrd@z Thu Jan 1 00:00:00 1970 From: Ming Lei Subject: [PATCH 2/5] dm-rq: handle dispatch exception in dm_dispatch_clone_request() Date: Mon, 22 Jan 2018 11:35:47 +0800 Message-ID: <20180122033550.27855-3-ming.lei@redhat.com> References: <20180122033550.27855-1-ming.lei@redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <20180122033550.27855-1-ming.lei@redhat.com> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: dm-devel-bounces@redhat.com Errors-To: dm-devel-bounces@redhat.com To: Jens Axboe , linux-block@vger.kernel.org, Christoph Hellwig , Mike Snitzer Cc: Bart Van Assche , dm-devel@redhat.com, Laurence Oberman , Ming Lei List-Id: dm-devel.ids 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 -- 2.9.5