From patchwork Wed Dec 27 03:22:57 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Snitzer X-Patchwork-Id: 10133363 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 828BB604D3 for ; Wed, 27 Dec 2017 03:23:26 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 75B492DB5B for ; Wed, 27 Dec 2017 03:23:26 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6AA002DB64; Wed, 27 Dec 2017 03:23:26 +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 0AA1B2DB5C for ; Wed, 27 Dec 2017 03:23:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751426AbdL0DXZ (ORCPT ); Tue, 26 Dec 2017 22:23:25 -0500 Received: from mx1.redhat.com ([209.132.183.28]:43904 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751225AbdL0DXZ (ORCPT ); Tue, 26 Dec 2017 22:23:25 -0500 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 0544561491; Wed, 27 Dec 2017 03:23:25 +0000 (UTC) Received: from localhost (ovpn-112-18.rdu2.redhat.com [10.10.112.18]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 9B25B60BEC; Wed, 27 Dec 2017 03:23:24 +0000 (UTC) From: Mike Snitzer To: axboe@kernel.dk, hch@lst.de, keith.busch@intel.com Cc: emilne@redhat.com, james.smart@broadcom.com, 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 v2 5/5] dm mpath: skip calls to end_io_bio if using NVMe bio-based and round-robin Date: Tue, 26 Dec 2017 22:22:57 -0500 Message-Id: <20171227032257.8182-6-snitzer@redhat.com> In-Reply-To: <20171227032257.8182-1-snitzer@redhat.com> References: <20171227032257.8182-1-snitzer@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Wed, 27 Dec 2017 03:23:25 +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 875df8ad6efe..fc0f1940b107 100644 --- a/drivers/md/dm-mpath.c +++ b/drivers/md/dm-mpath.c @@ -1187,6 +1187,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; @@ -1672,11 +1687,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 758feae899f9..f3c4bd29083f 100644 --- a/include/linux/device-mapper.h +++ b/include/linux/device-mapper.h @@ -310,6 +310,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 */