From patchwork Wed Jul 3 13:00:34 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 11029565 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id E574A138B for ; Wed, 3 Jul 2019 13:00:46 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D7AB92875E for ; Wed, 3 Jul 2019 13:00:46 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id CBFC8287F5; Wed, 3 Jul 2019 13:00:46 +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=-7.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,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 4C74C2875E for ; Wed, 3 Jul 2019 13:00:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725944AbfGCNAp (ORCPT ); Wed, 3 Jul 2019 09:00:45 -0400 Received: from bombadil.infradead.org ([198.137.202.133]:57058 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725847AbfGCNAp (ORCPT ); Wed, 3 Jul 2019 09:00:45 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender :Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From :Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=Lv3d4n66kjW1UoxQrY+WZ6kJmTM9S3HPEFhaF13q4M8=; b=pB0H7uI30DEkin7R5FgWOv0peb Z9O3jRMJBZzCandrGWR5qeOSpDcvFdi5DQGfjsclgSZiL82PP5pajVO/i4tXLa2m3cDE/+xK0UrmY K40SCW3PCuskm0s+0FEMua5n1nYS2RwVThXDMVfAP2n7/jNK8U8Z+X4iOobN4NuXKdgOTBdoUM0NF k8z8G83qEGb3+4EcoEKBNm2M2YOkYzl5sbKnkk+gafbINSwfNybUoMbaruDVTFzMdDRuPiSAvFnlc RrYO/uzwPcsMoCg+/NdhSsJYPxSWsv/CRO8dmF1CjbwlBSPu6ouGoGwbsHKNbYnHinqisZmob5WVt DzGLx1wQ==; Received: from [12.46.110.2] (helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.92 #3 (Red Hat Linux)) id 1hiesN-0006XU-MV; Wed, 03 Jul 2019 13:00:44 +0000 From: Christoph Hellwig To: Jens Axboe Cc: linux-block@vger.kernel.org Subject: [PATCH 1/3] block: improve the gap check in __bio_add_pc_page Date: Wed, 3 Jul 2019 06:00:34 -0700 Message-Id: <20190703130036.4105-2-hch@lst.de> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190703130036.4105-1-hch@lst.de> References: <20190703130036.4105-1-hch@lst.de> MIME-Version: 1.0 X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html 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 If we can add more data into an existing segment we do not create a gap per definition, so move the check for a gap after the attempt to merge into the segment. Signed-off-by: Christoph Hellwig Reviewed-by: Johannes Thumshirn --- block/bio.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/block/bio.c b/block/bio.c index 29cd6cf4da51..6be22b8477ce 100644 --- a/block/bio.c +++ b/block/bio.c @@ -709,18 +709,18 @@ static int __bio_add_pc_page(struct request_queue *q, struct bio *bio, goto done; } - /* - * If the queue doesn't support SG gaps and adding this - * offset would create a gap, disallow it. - */ - if (bvec_gap_to_prev(q, bvec, offset)) - return 0; - if (page_is_mergeable(bvec, page, len, offset, &same_page) && can_add_page_to_seg(q, bvec, page, len, offset)) { bvec->bv_len += len; goto done; } + + /* + * If the queue doesn't support SG gaps and adding this segment + * would create a gap, disallow it. + */ + if (bvec_gap_to_prev(q, bvec, offset)) + return 0; } if (bio_full(bio, len))