From patchwork Tue Dec 19 21:05:46 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Snitzer X-Patchwork-Id: 10124377 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 4F3D96019C for ; Tue, 19 Dec 2017 21:06:21 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 41FC0294C6 for ; Tue, 19 Dec 2017 21:06:21 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 37156295BA; Tue, 19 Dec 2017 21:06:21 +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=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CBBEB29550 for ; Tue, 19 Dec 2017 21:06:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752860AbdLSVGU (ORCPT ); Tue, 19 Dec 2017 16:06:20 -0500 Received: from mx1.redhat.com ([209.132.183.28]:57876 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752826AbdLSVGT (ORCPT ); Tue, 19 Dec 2017 16:06:19 -0500 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 BA8ED6F5; Tue, 19 Dec 2017 21:06:19 +0000 (UTC) Received: from localhost (wlan-196-89.bos.redhat.com [10.16.196.89]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 86BFD1964B; Tue, 19 Dec 2017 21:06:19 +0000 (UTC) From: Mike Snitzer To: axboe@kernel.dk, hch@lst.de, emilne@redhat.com, james.smart@broadcom.com Cc: hare@suse.de, Bart.VanAssche@wdc.com, linux-block@vger.kernel.org, linux-nvme@lists.infradead.org, dm-devel@redhat.com Subject: [for-4.16 PATCH 5/5] dm mpath: skip calls to end_io_bio if using NVMe bio-based and round-robin Date: Tue, 19 Dec 2017 16:05:46 -0500 Message-Id: <20171219210546.65928-6-snitzer@redhat.com> In-Reply-To: <20171219210546.65928-1-snitzer@redhat.com> References: <20171219210546.65928-1-snitzer@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.29]); Tue, 19 Dec 2017 21:06:19 +0000 (UTC) Sender: linux-block-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Add a 'skip_endio_hook' flag member to 'struct dm_target' that if set instructs calls to .end_io (or .rq_end_io) to be skipped. NVMe bio-based doesn't use multipath_end_io_bio() for anything other than updating the path-selector. So it can be avoided completely if the round-robin path selector is used (because round-robin doesn't have an end_io hook). Signed-off-by: Mike Snitzer --- drivers/md/dm-mpath.c | 24 ++++++++++++++++++++---- drivers/md/dm-rq.c | 8 ++++---- drivers/md/dm.c | 7 ++++--- include/linux/device-mapper.h | 6 ++++++ 4 files changed, 34 insertions(+), 11 deletions(-) diff --git a/drivers/md/dm-mpath.c b/drivers/md/dm-mpath.c index 0ed407e150f5..5b4c88c1980f 100644 --- a/drivers/md/dm-mpath.c +++ b/drivers/md/dm-mpath.c @@ -1186,6 +1186,21 @@ static int multipath_ctr(struct dm_target *ti, unsigned argc, char **argv) goto bad; } + /* + * If NVMe bio-based and all path selectors don't provide .end_io hook: + * inform DM core that there is no need to call this target's end_io hook. + */ + if (m->queue_mode == DM_TYPE_NVME_BIO_BASED) { + struct priority_group *pg; + if (!m->nr_priority_groups) + goto finish; + list_for_each_entry(pg, &m->priority_groups, list) { + if (pg->ps.type->end_io) + goto finish; + } + ti->skip_end_io_hook = true; + } +finish: ti->num_flush_bios = 1; ti->num_discard_bios = 1; ti->num_write_same_bios = 1; @@ -1671,11 +1686,12 @@ static void multipath_failover_rq(struct request *rq) unsigned long flags; if (pgpath) { - struct path_selector *ps = &pgpath->pg->ps; - - if (ps->type->end_io) - ps->type->end_io(ps, &pgpath->path, blk_rq_bytes(rq)); + if (!ti->skip_end_io_hook) { + struct path_selector *ps = &pgpath->pg->ps; + if (ps->type->end_io) + ps->type->end_io(ps, &pgpath->path, blk_rq_bytes(rq)); + } fail_path(pgpath); } diff --git a/drivers/md/dm-rq.c b/drivers/md/dm-rq.c index 9d32f25489c2..64206743da8f 100644 --- a/drivers/md/dm-rq.c +++ b/drivers/md/dm-rq.c @@ -285,12 +285,12 @@ static void dm_done(struct request *clone, blk_status_t error, bool mapped) { int r = DM_ENDIO_DONE; struct dm_rq_target_io *tio = clone->end_io_data; - dm_request_endio_fn rq_end_io = NULL; + struct dm_target *ti = tio->ti; - if (tio->ti) { - rq_end_io = tio->ti->type->rq_end_io; + if (ti) { + dm_request_endio_fn rq_end_io = ti->type->rq_end_io; - if (mapped && rq_end_io) + if (mapped && rq_end_io && !ti->skip_end_io_hook) r = rq_end_io(tio->ti, clone, error, &tio->info); } diff --git a/drivers/md/dm.c b/drivers/md/dm.c index 9f4c4a7fd40d..5c83d9dcbfe8 100644 --- a/drivers/md/dm.c +++ b/drivers/md/dm.c @@ -937,7 +937,8 @@ static void clone_endio(struct bio *bio) struct dm_target_io *tio = container_of(bio, struct dm_target_io, clone); struct dm_io *io = tio->io; struct mapped_device *md = tio->io->md; - dm_endio_fn endio = tio->ti->type->end_io; + struct dm_target *ti = tio->ti; + dm_endio_fn endio = ti->type->end_io; if (unlikely(error == BLK_STS_TARGET) && md->type != DM_TYPE_NVME_BIO_BASED) { if (bio_op(bio) == REQ_OP_WRITE_SAME && @@ -948,8 +949,8 @@ static void clone_endio(struct bio *bio) disable_write_zeroes(md); } - if (endio) { - int r = endio(tio->ti, bio, &error); + if (endio && !ti->skip_end_io_hook) { + int r = endio(ti, bio, &error); switch (r) { case DM_ENDIO_REQUEUE: error = BLK_STS_DM_REQUEUE; diff --git a/include/linux/device-mapper.h b/include/linux/device-mapper.h index e46ad2ada674..1dfb75ca5d09 100644 --- a/include/linux/device-mapper.h +++ b/include/linux/device-mapper.h @@ -307,6 +307,12 @@ struct dm_target { * on max_io_len boundary. */ bool split_discard_bios:1; + + /* + * Set if there is no need to call this target's end_io hook + * (be it .end_io or .end_io_rq). + */ + bool skip_end_io_hook:1; }; /* Each target can link one of these into the table */