Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp1502746imu; Tue, 20 Nov 2018 19:45:16 -0800 (PST) X-Google-Smtp-Source: AFSGD/UA66PRI8hdZlo7EDaikzChRVrWuWPbTLUcCldH0HLt7aWJo+ahvOo6pCLuHK0MuPJD8GnH X-Received: by 2002:a17:902:20b:: with SMTP id 11mr2119030plc.57.1542771916892; Tue, 20 Nov 2018 19:45:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1542771916; cv=none; d=google.com; s=arc-20160816; b=ugH1ocjTicEAUH28qWoB4lfL9G6nH0LjEQyZSTtUFthjZveVE9ESaTlDb+nSiaioF5 JyNIpPizhWn7ip8cutj5ZNt2SQ8BhA5uDhlMkuTkAkA8XUmgBLQrANEYJfRoqx/WEeCt EkkgrRjxf638RHuLCquyjbMvxuRx2qixxjCy5GRRzn/jbcOfVH25XBexjmjX5ty+fN7E nDFeydCRtThfCsT9/5EJ7BAORNgvKESPbYmAKdsu1bVS44GicHITKD+R1zTtbToQRvPb uMpdXj7UP2h/2C25oZMSrjcyMVqwEI3bj9WXWHnD7Bvbks/7HsFtiPZLff8dHqtwB/ED 1yWA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from; bh=ElsrrhpAVIbsmTVlPH0nJbaneQL9iVm2pKo9WSx+m1k=; b=qzJRCDChx4l5m/5RkRw4d1dbfy4OKImKCqDfo9RzrR6NiQBSFpC+fJVStWv+QUZJCF WlxSJpE42Af35gQKrRAdKhoHffQKAVzT0TRE6qnW1ZPEztDoSUFzdnLkal6zf/VWjmTc iKi4yqqMlDqdcS1PM8RcmYMylIGIQ6H854HGFpGlx4y2c84P+R7SlsXFwshnGwdG1m7w fkufjQ5Yp97/H4+cDCleEjT8FpmLjlmThxXZTbxI8qmQbUhSdYMDvY247FnHsgBKvQcd Lhx0MmXWOi3z6sAoLnyF2fEK244xdlfFqT7zjxeS5EMb6OKBDT0JY2munk5gyB7223UJ dLMw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 4-v6si48403963ple.236.2018.11.20.19.45.01; Tue, 20 Nov 2018 19:45:16 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727297AbeKUN5b (ORCPT + 99 others); Wed, 21 Nov 2018 08:57:31 -0500 Received: from mx1.redhat.com ([209.132.183.28]:42754 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726165AbeKUN5b (ORCPT ); Wed, 21 Nov 2018 08:57:31 -0500 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 81FB337E79; Wed, 21 Nov 2018 03:25:00 +0000 (UTC) Received: from localhost (ovpn-8-21.pek2.redhat.com [10.72.8.21]) by smtp.corp.redhat.com (Postfix) with ESMTP id 97DDA608C4; Wed, 21 Nov 2018 03:24:46 +0000 (UTC) From: Ming Lei To: Jens Axboe Cc: linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, Theodore Ts'o , Omar Sandoval , Sagi Grimberg , Dave Chinner , Kent Overstreet , Mike Snitzer , dm-devel@redhat.com, Alexander Viro , linux-fsdevel@vger.kernel.org, Shaohua Li , linux-raid@vger.kernel.org, David Sterba , linux-btrfs@vger.kernel.org, "Darrick J . Wong" , linux-xfs@vger.kernel.org, Gao Xiang , Christoph Hellwig , linux-ext4@vger.kernel.org, Coly Li , linux-bcache@vger.kernel.org, Boaz Harrosh , Bob Peterson , cluster-devel@redhat.com, Ming Lei Subject: [PATCH V11 01/19] block: don't use bio->bi_vcnt to figure out segment number Date: Wed, 21 Nov 2018 11:23:09 +0800 Message-Id: <20181121032327.8434-2-ming.lei@redhat.com> In-Reply-To: <20181121032327.8434-1-ming.lei@redhat.com> References: <20181121032327.8434-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.29]); Wed, 21 Nov 2018 03:25:00 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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"). Reviewed-by: Christoph Hellwig Fixes: 76d8137a3113 ("blk-merge: recaculate segment if it isn't less than max segments") Signed-off-by: Ming Lei --- 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 b1df622cbd85..f52400ce2187 100644 --- a/block/blk-merge.c +++ b/block/blk-merge.c @@ -368,13 +368,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))) -- 2.9.5