Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp5173451imu; Sun, 25 Nov 2018 18:19:28 -0800 (PST) X-Google-Smtp-Source: AFSGD/VzuPR+0JrWuyrEsTzoK2hzG99pTQVZGr0tH4RQ4y+/pK1oekOU1SX9qPmfVjPYxyWbP2rm X-Received: by 2002:a17:902:1005:: with SMTP id b5mr17605489pla.310.1543198768321; Sun, 25 Nov 2018 18:19:28 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543198768; cv=none; d=google.com; s=arc-20160816; b=zGvnrDLWK8l9N/QNrTSurLvheFtybl1dSeYCTFNP3g6u/q1qszO4PIRzQfAQugiCgc pISiVdTKaawdRlAfIW+SBxl8ssPtRNC8B3UyYefksV+UgLCD2GXUMMsBlpckYe7AM898 YA+QeWpzrrjcjtK+tNGmrSYHIw1EuiIjOJsKUrL9RKMjP5WZg7xNa+DGH8ZH4M0oR0Ev bX41rNkcF+l/E4nMdGsAM5ys/a7wHrLFi5xVBTq5o1XJcmjy3jLOyCmUzM+nFuOW/KYF Ls9nFTmaCkaN87iUDTLBxHvpppkfBP0YmYgScluFP/ix1sotNsnMwMWUxQQZnNcxBkyO fMJQ== 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=i2RSDXiiLv4eqGo5PQxpOUk/2wBp+PkxCNDt1NMuxnk=; b=DqtspsAGxXT5rXDrk5tCpQLsa27ZFfNXvpLLyu0gnVqRIseR8SOZYiFMvipGsHooP9 FwAgTmm0ninSEBD6MJhkxfJGUiVSvzKuj+Etvaw4rqrC4s1QZUNy07gqfzt3WnP8+EE7 KhqANGZDrIPwonGjb8Ateo/0657mkphaKPq8O7+tXG2EyZFq1tlDaP2CK1BzL6RM1IhR UdZOVB0tb5Km/j3XeXgCZ0mmFJm6HdMwjbLciZkBNWvz9FfBSluJ/VboIaXqPIpSGMK9 VRUI6MJSMXwiUTBgPNbX567fa91abUuF7De6PSCgRHwC7QyUntMabFM8pB8Ze8nQ31kw Cmdg== 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 v1-v6si28679978pfm.71.2018.11.25.18.19.13; Sun, 25 Nov 2018 18:19:28 -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 S1726407AbeKZNKx (ORCPT + 99 others); Mon, 26 Nov 2018 08:10:53 -0500 Received: from mx1.redhat.com ([209.132.183.28]:57070 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726053AbeKZNKw (ORCPT ); Mon, 26 Nov 2018 08:10:52 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id B9DF4C0578FA; Mon, 26 Nov 2018 02:18:16 +0000 (UTC) Received: from localhost (ovpn-8-19.pek2.redhat.com [10.72.8.19]) by smtp.corp.redhat.com (Postfix) with ESMTP id EC0292CD5B; Mon, 26 Nov 2018 02:18:15 +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 V12 04/20] block: don't use bio->bi_vcnt to figure out segment number Date: Mon, 26 Nov 2018 10:17:04 +0800 Message-Id: <20181126021720.19471-5-ming.lei@redhat.com> In-Reply-To: <20181126021720.19471-1-ming.lei@redhat.com> References: <20181126021720.19471-1-ming.lei@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Mon, 26 Nov 2018 02:18:17 +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 e69d8f8ba819..51ec6ca56a0a 100644 --- a/block/blk-merge.c +++ b/block/blk-merge.c @@ -367,13 +367,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