From patchwork Sat Sep 30 11:26:51 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ming Lei X-Patchwork-Id: 9979411 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 95B6E6034B for ; Sat, 30 Sep 2017 11:31:51 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8B03829463 for ; Sat, 30 Sep 2017 11:31:51 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7FABB2946E; Sat, 30 Sep 2017 11:31:51 +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 0094929467 for ; Sat, 30 Sep 2017 11:31:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752911AbdI3Lbu (ORCPT ); Sat, 30 Sep 2017 07:31:50 -0400 Received: from mx1.redhat.com ([209.132.183.28]:59740 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752907AbdI3Lbt (ORCPT ); Sat, 30 Sep 2017 07:31:49 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 1B14585543; Sat, 30 Sep 2017 11:31:49 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 1B14585543 Authentication-Results: ext-mx04.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx04.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=ming.lei@redhat.com Received: from localhost (ovpn-12-31.pek2.redhat.com [10.72.12.31]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1968C84CE0; Sat, 30 Sep 2017 11:31:36 +0000 (UTC) From: Ming Lei To: Jens Axboe , linux-block@vger.kernel.org, Christoph Hellwig , Mike Snitzer , dm-devel@redhat.com Cc: Bart Van Assche , Laurence Oberman , Paolo Valente , Oleksandr Natalenko , Tom Nguyen , linux-kernel@vger.kernel.org, Omar Sandoval , Ming Lei Subject: [PATCH V5 4/8] block: move actual bio merge code into __elv_merge Date: Sat, 30 Sep 2017 19:26:51 +0800 Message-Id: <20170930112655.31451-5-ming.lei@redhat.com> In-Reply-To: <20170930112655.31451-1-ming.lei@redhat.com> References: <20170930112655.31451-1-ming.lei@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Sat, 30 Sep 2017 11:31:49 +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 So that we can reuse __elv_merge() to merge bio into requests from sw queue in the following patches. No functional change. Tested-by: Oleksandr Natalenko Tested-by: Tom Nguyen Tested-by: Paolo Valente Signed-off-by: Ming Lei --- block/elevator.c | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/block/elevator.c b/block/elevator.c index 824cc3e69ac3..e11c7873fc21 100644 --- a/block/elevator.c +++ b/block/elevator.c @@ -409,8 +409,9 @@ void elv_dispatch_add_tail(struct request_queue *q, struct request *rq) } EXPORT_SYMBOL(elv_dispatch_add_tail); -enum elv_merge elv_merge(struct request_queue *q, struct request **req, - struct bio *bio) +static enum elv_merge __elv_merge(struct request_queue *q, + struct request **req, struct bio *bio, + struct hlist_head *hash, struct request *last_merge) { struct elevator_queue *e = q->elevator; struct request *__rq; @@ -427,11 +428,11 @@ enum elv_merge elv_merge(struct request_queue *q, struct request **req, /* * First try one-hit cache. */ - if (q->last_merge && elv_bio_merge_ok(q->last_merge, bio)) { - enum elv_merge ret = blk_try_merge(q->last_merge, bio); + if (last_merge && elv_bio_merge_ok(last_merge, bio)) { + enum elv_merge ret = blk_try_merge(last_merge, bio); if (ret != ELEVATOR_NO_MERGE) { - *req = q->last_merge; + *req = last_merge; return ret; } } @@ -442,7 +443,7 @@ enum elv_merge elv_merge(struct request_queue *q, struct request **req, /* * See if our hash lookup can find a potential backmerge. */ - __rq = elv_rqhash_find(q, bio->bi_iter.bi_sector); + __rq = rqhash_find(hash, bio->bi_iter.bi_sector); if (__rq && elv_bio_merge_ok(__rq, bio)) { *req = __rq; return ELEVATOR_BACK_MERGE; @@ -456,6 +457,12 @@ enum elv_merge elv_merge(struct request_queue *q, struct request **req, return ELEVATOR_NO_MERGE; } +enum elv_merge elv_merge(struct request_queue *q, struct request **req, + struct bio *bio) +{ + return __elv_merge(q, req, bio, q->elevator->hash, q->last_merge); +} + /* * Attempt to do an insertion back merge. Only check for the case where * we can append 'rq' to an existing request, so we can throw 'rq' away