From patchwork Thu Feb 1 20:31:58 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Keith Busch X-Patchwork-Id: 10196013 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 A325E60380 for ; Thu, 1 Feb 2018 21:15:27 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8B34D28B59 for ; Thu, 1 Feb 2018 21:15:27 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 887282871B; Thu, 1 Feb 2018 21:15:27 +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 176AE289A0 for ; Thu, 1 Feb 2018 20:36:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754980AbeBAU2W (ORCPT ); Thu, 1 Feb 2018 15:28:22 -0500 Received: from mga14.intel.com ([192.55.52.115]:15517 "EHLO mga14.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754958AbeBAU2V (ORCPT ); Thu, 1 Feb 2018 15:28:21 -0500 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by fmsmga103.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 01 Feb 2018 12:28:21 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.46,444,1511856000"; d="scan'208";a="14677839" Received: from unknown (HELO localhost.lm.intel.com) ([10.232.112.44]) by fmsmga007.fm.intel.com with ESMTP; 01 Feb 2018 12:28:21 -0800 From: Keith Busch To: Linux Block , Linux NVMe , Christoph Hellwig , Jens Axboe Cc: Keith Busch Subject: [PATCHv2 2/2] block: Handle merging discards in IO schedulers Date: Thu, 1 Feb 2018 13:31:58 -0700 Message-Id: <20180201203158.24761-3-keith.busch@intel.com> X-Mailer: git-send-email 2.13.6 In-Reply-To: <20180201203158.24761-1-keith.busch@intel.com> References: <20180201203158.24761-1-keith.busch@intel.com> 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 This adds support for merging discard requests in all IO schedulers. Signed-off-by: Keith Busch --- block/bfq-iosched.c | 2 +- block/blk-core.c | 4 ++++ block/blk-mq-sched.c | 2 ++ block/cfq-iosched.c | 2 +- block/deadline-iosched.c | 4 +++- block/elevator.c | 2 +- block/mq-deadline.c | 2 +- 7 files changed, 13 insertions(+), 5 deletions(-) diff --git a/block/bfq-iosched.c b/block/bfq-iosched.c index 47e6ec7427c4..9b08c08298a6 100644 --- a/block/bfq-iosched.c +++ b/block/bfq-iosched.c @@ -1839,7 +1839,7 @@ static int bfq_request_merge(struct request_queue *q, struct request **req, __rq = bfq_find_rq_fmerge(bfqd, bio, q); if (__rq && elv_bio_merge_ok(__rq, bio)) { *req = __rq; - return ELEVATOR_FRONT_MERGE; + return blk_try_merge(__rq, bio); } return ELEVATOR_NO_MERGE; diff --git a/block/blk-core.c b/block/blk-core.c index a2005a485335..295ce3cbe1f6 100644 --- a/block/blk-core.c +++ b/block/blk-core.c @@ -1952,6 +1952,10 @@ static blk_qc_t blk_queue_bio(struct request_queue *q, struct bio *bio) else elv_merged_request(q, req, ELEVATOR_FRONT_MERGE); goto out_unlock; + case ELEVATOR_DISCARD_MERGE: + if (!bio_attempt_discard_merge(q, req, bio)) + break; + goto out_unlock; default: break; } diff --git a/block/blk-mq-sched.c b/block/blk-mq-sched.c index 55c0a745b427..25c14c58385c 100644 --- a/block/blk-mq-sched.c +++ b/block/blk-mq-sched.c @@ -259,6 +259,8 @@ bool blk_mq_sched_try_merge(struct request_queue *q, struct bio *bio, if (!*merged_request) elv_merged_request(q, rq, ELEVATOR_FRONT_MERGE); return true; + case ELEVATOR_DISCARD_MERGE: + return bio_attempt_discard_merge(q, rq, bio); default: return false; } diff --git a/block/cfq-iosched.c b/block/cfq-iosched.c index 9f342ef1ad42..38158873d775 100644 --- a/block/cfq-iosched.c +++ b/block/cfq-iosched.c @@ -2518,7 +2518,7 @@ static enum elv_merge cfq_merge(struct request_queue *q, struct request **req, __rq = cfq_find_rq_fmerge(cfqd, bio); if (__rq && elv_bio_merge_ok(__rq, bio)) { *req = __rq; - return ELEVATOR_FRONT_MERGE; + return blk_try_merge(__rq, bio); } return ELEVATOR_NO_MERGE; diff --git a/block/deadline-iosched.c b/block/deadline-iosched.c index 9de9f156e203..849e03938653 100644 --- a/block/deadline-iosched.c +++ b/block/deadline-iosched.c @@ -14,6 +14,8 @@ #include #include +#include "blk.h" + /* * See Documentation/block/deadline-iosched.txt */ @@ -142,7 +144,7 @@ deadline_merge(struct request_queue *q, struct request **req, struct bio *bio) if (elv_bio_merge_ok(__rq, bio)) { *req = __rq; - return ELEVATOR_FRONT_MERGE; + return blk_try_merge(__rq, bio); } } } diff --git a/block/elevator.c b/block/elevator.c index e87e9b43aba0..7fd6cb9cfec1 100644 --- a/block/elevator.c +++ b/block/elevator.c @@ -484,7 +484,7 @@ enum elv_merge elv_merge(struct request_queue *q, struct request **req, __rq = elv_rqhash_find(q, bio->bi_iter.bi_sector); if (__rq && elv_bio_merge_ok(__rq, bio)) { *req = __rq; - return ELEVATOR_BACK_MERGE; + return blk_try_merge(__rq, bio); } if (e->uses_mq && e->type->ops.mq.request_merge) diff --git a/block/mq-deadline.c b/block/mq-deadline.c index c56f211c8440..a0f5752b6858 100644 --- a/block/mq-deadline.c +++ b/block/mq-deadline.c @@ -451,7 +451,7 @@ static int dd_request_merge(struct request_queue *q, struct request **rq, if (elv_bio_merge_ok(__rq, bio)) { *rq = __rq; - return ELEVATOR_FRONT_MERGE; + return blk_try_merge(__rq, bio); } }