From patchwork Thu Nov 15 08:53:04 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ming Lei X-Patchwork-Id: 10683893 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 9544614D6 for ; Thu, 15 Nov 2018 08:58:17 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 83626299C2 for ; Thu, 15 Nov 2018 08:58:17 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 768732B334; Thu, 15 Nov 2018 08:58:17 +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=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 572C6299C2 for ; Thu, 15 Nov 2018 08:58:16 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 868716B028D; Thu, 15 Nov 2018 03:58:15 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 7EEA26B028E; Thu, 15 Nov 2018 03:58:15 -0500 (EST) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 6B8C16B028F; Thu, 15 Nov 2018 03:58:15 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-qk1-f199.google.com (mail-qk1-f199.google.com [209.85.222.199]) by kanga.kvack.org (Postfix) with ESMTP id 3F8B36B028D for ; Thu, 15 Nov 2018 03:58:15 -0500 (EST) Received: by mail-qk1-f199.google.com with SMTP id 92so43695894qkx.19 for ; Thu, 15 Nov 2018 00:58:15 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-original-authentication-results:x-gm-message-state:from:to:cc :subject:date:message-id:in-reply-to:references; bh=bMFfeA1s4ovfbuodnvxSUpfFDcroT0auXSYw4L+o2mc=; b=BU7EXQ46dZnwh8rqgK4n24r1Ru8+rRnhsQ760KUXRvVwT07PyG+ir5VIL9GdJ7Av08 /TnDfcldSse+zDlzbN1U2PYSXHvdxk2oo5MIAv/mzgUB8jrAJw1yNOToSmdOQ3UAd2QD SyFQ7L4JSKMAmNG59nQWdEEoTyO+XGVQ0E8CD6NCKutcS6wKn3/fbc0ahip5akSoqfS1 giizK/pGZI0XW9E6aop7cvt4sAe9IS3eSxKvL6+adx11y4TKJvNvMPnZRnzoJNqnV0MT 5zTNFCM9x+hZTz4BjfFatN+57rzwebCbUe9MUY4bUb4hMENa2n1DmzNeiUJm/Z7rR7X+ pORw== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of ming.lei@redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=ming.lei@redhat.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com X-Gm-Message-State: AGRZ1gItutrvFmlXA8uPoK3HQ79kco2APLCO2WNB3GrAE/5nNnrudjr7 SWbUuEK0h9sUf4bEhVH0rLGYTkmhV2fPwYgGOpBx4kTsPywcCqE9k0Salbd0ILMKwi16+bLRBWF 28myj8Rv+W1Cv0s5sroZIw4Acny7A07VUNjSroQKBdRINLm5Nl2ArUJJKdaZjgHGW7g== X-Received: by 2002:a37:7003:: with SMTP id l3mr5353608qkc.80.1542272295003; Thu, 15 Nov 2018 00:58:15 -0800 (PST) X-Google-Smtp-Source: AJdET5dcqR9aC8OxfgeSpjjAjUDrGEZgDJP4q3LtUOfI6sUrNnB4rue2JWYsOGEDHR2rTTFj4hz0 X-Received: by 2002:a37:7003:: with SMTP id l3mr5353582qkc.80.1542272294426; Thu, 15 Nov 2018 00:58:14 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1542272294; cv=none; d=google.com; s=arc-20160816; b=KI+hxW1zIWwDTnbv5YHwcucRJbxabnolMRLf2/SotXmdJHgqmHM284eAfve33/zEW+ 0PeMeN7xJCpxCrDFWx8ZfoYhlNhevKP06S1odpCS40BSXZhDgNcC2/sPd0SB2302CnT7 q9FvixZiRHw0wtwZYWfqZZubO5ilA+rUGLiAYoq6ScYEmrbnDT9yg39nIf0zHlqhIqgL bZx/KoBqKSzIxpmrd24aAXPglrSKqypjFGH42NnQQtnS/rFINrEF34q6tsi65R9lIOLH 9Gn/Xk/fw1t5W0cxW9ajuNNsLVoSE5hNYBdMU4Pn5jXb6RFyOBJ4ZLRNziR+msH5e9WP MurQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from; bh=bMFfeA1s4ovfbuodnvxSUpfFDcroT0auXSYw4L+o2mc=; b=osJCXFA25Gd9QTt72WoYgWx10MM5TSwtjhMTcOn6lNyhYWL3FK3A0jsoDG3UbQwG/5 aG8GRVxt7VqZfZqX+fXD/14HneiEgEcU/ZcmnauBQhDNJmVskqYNb7qZrNx8lcrpMJi+ 0526+kC3S4+SU7VEQzUDFrOzUN7bBn6ajp4MtR2lbjUgf45dmuPamjHFwBRqKc2HvocW 34Gd696RJRa1ENfK0BhBNY8ynvyUimL3RTdCMbPb6sRtiycj7pSPCOhwb2qEgQ+eUOIy HruMkbat2E/hZR6kvlFDj7ABh4VIfsTNspsaFkNJsBL8b5Oww9FO7cy11ECFYV/70qmr /m3A== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of ming.lei@redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=ming.lei@redhat.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from mx1.redhat.com (mx1.redhat.com. [209.132.183.28]) by mx.google.com with ESMTPS id p93si12041096qtd.400.2018.11.15.00.58.14 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 15 Nov 2018 00:58:14 -0800 (PST) Received-SPF: pass (google.com: domain of ming.lei@redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; Authentication-Results: mx.google.com; spf=pass (google.com: domain of ming.lei@redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=ming.lei@redhat.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 3A9533082B72; Thu, 15 Nov 2018 08:58:13 +0000 (UTC) Received: from localhost (ovpn-8-23.pek2.redhat.com [10.72.8.23]) by smtp.corp.redhat.com (Postfix) with ESMTP id 869DA611A0; Thu, 15 Nov 2018 08:57:48 +0000 (UTC) From: Ming Lei To: Jens Axboe Cc: linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, Ming Lei , Dave Chinner , Kent Overstreet , Mike Snitzer , dm-devel@redhat.com, Alexander Viro , linux-fsdevel@vger.kernel.org, Shaohua Li , linux-raid@vger.kernel.org, linux-erofs@lists.ozlabs.org, David Sterba , linux-btrfs@vger.kernel.org, "Darrick J . Wong" , linux-xfs@vger.kernel.org, Gao Xiang , Christoph Hellwig , Theodore Ts'o , linux-ext4@vger.kernel.org, Coly Li , linux-bcache@vger.kernel.org, Boaz Harrosh , Bob Peterson , cluster-devel@redhat.com Subject: [PATCH V10 17/19] block: don't use bio->bi_vcnt to figure out segment number Date: Thu, 15 Nov 2018 16:53:04 +0800 Message-Id: <20181115085306.9910-18-ming.lei@redhat.com> In-Reply-To: <20181115085306.9910-1-ming.lei@redhat.com> References: <20181115085306.9910-1-ming.lei@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.45]); Thu, 15 Nov 2018 08:58:13 +0000 (UTC) X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP It is wrong to use bio->bi_vcnt to figure out how many segments there are in the bio even though CLONED flag isn't set on this bio, because this bio may be splitted or advanced. So always use bio_segments() in blk_recount_segments(), and it shouldn't cause any performance loss now because the physical segment number is figured out in blk_queue_split() and BIO_SEG_VALID is set meantime since bdced438acd83ad83a6c ("block: setup bi_phys_segments after splitting"). Cc: Dave Chinner Cc: Kent Overstreet Fixes: 7f60dcaaf91 ("block: blk-merge: fix blk_recount_segments()") Cc: Mike Snitzer Cc: dm-devel@redhat.com Cc: Alexander Viro Cc: linux-fsdevel@vger.kernel.org Cc: Shaohua Li Cc: linux-raid@vger.kernel.org Cc: linux-erofs@lists.ozlabs.org Cc: David Sterba Cc: linux-btrfs@vger.kernel.org Cc: Darrick J. Wong Cc: linux-xfs@vger.kernel.org Cc: Gao Xiang Cc: Christoph Hellwig Cc: Theodore Ts'o Cc: linux-ext4@vger.kernel.org Cc: Coly Li Cc: linux-bcache@vger.kernel.org Cc: Boaz Harrosh Cc: Bob Peterson Cc: cluster-devel@redhat.com Signed-off-by: Ming Lei Reviewed-by: Christoph Hellwig --- block/blk-merge.c | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/block/blk-merge.c b/block/blk-merge.c index cb9f49bcfd36..153a659fde74 100644 --- a/block/blk-merge.c +++ b/block/blk-merge.c @@ -429,13 +429,7 @@ void blk_recalc_rq_segments(struct request *rq) void blk_recount_segments(struct request_queue *q, struct bio *bio) { - unsigned short seg_cnt; - - /* estimate segment number by bi_vcnt for non-cloned bio */ - if (bio_flagged(bio, BIO_CLONED)) - seg_cnt = bio_segments(bio); - else - seg_cnt = bio->bi_vcnt; + unsigned short seg_cnt = bio_segments(bio); if (test_bit(QUEUE_FLAG_NO_SG_MERGE, &q->queue_flags) && (seg_cnt < queue_max_segments(q)))