Received: by 2002:ac0:946b:0:0:0:0:0 with SMTP id j40csp871791imj; Fri, 15 Feb 2019 08:10:30 -0800 (PST) X-Google-Smtp-Source: AHgI3IYyg3jUW2MBV3Bjjt41YxcL4tvfskPgigQDMVygp1jXcMVOM4euRNT2l+Zdtv+3GX5Mlv6r X-Received: by 2002:a17:902:708b:: with SMTP id z11mr10994009plk.203.1550247030077; Fri, 15 Feb 2019 08:10:30 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550247030; cv=none; d=google.com; s=arc-20160816; b=G5wk9PJz6XzyB/j6prMddYHkf4+ui8S+q3Md3t2DkNgiKh08x8WMS4283tdPV/UY94 c/9li7nKh1a0FwoLNHOAoz2ikZj4kik4ynFW6OGhXkQZyLw47HKrenzLTRxBVRypN3o2 T9FcxRb0R744Cmzy2nh1ul/lx6rn6hSFNrK7PijmtuBlJsAvPpQZHQIv8uAR4+lWZQBh 5SsFkdsUCIch8CYdWpPTpAtqXMKrDO1f3F1VrdGbWK77mx9V+q9SgzKYFtGAKDCchGwe gbPLzfjdzmQh4co2ZDZzWmzSp2E17VVnKcT+IM29IO2GyeMJlQz8DMIP9fHqTUH0s020 lj4g== 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=slTW8uoG6sTMlKcMLmau18LMT15MeeTevHwmv3l5NcU=; b=LHvv6V9J5FiwsI//M6F7nQqw3rJZ2vQ2FaQXfa8sP975OC2hlIuw5Y1NJRTJXst6K2 gcrX6Uy0/0lhwFGILo7IAcCMrnGX/B9KC13+9a1WJ/306LuSOseoy/7WiVa+Mmz14t8L K0m2NCc85Y7RXTCvqXsJZ07nt6PpsKEL+oRzM/p20jeJdyFXx09jNZTbFYdHaOXZM/H3 WhukjfwyLLmG5qs9De0smiKpTKQjn3qOl4ZZbNCnk7inryJTbRaWiSnySyBXjkchpBPD wfcapRmszOA5+pb1dif1k1ePtm0+HYubfFvXzRaAh3cCD404MJluNbGR4eImhSrWhkL5 q+VA== 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 o24si6390748pfa.34.2019.02.15.08.10.13; Fri, 15 Feb 2019 08:10:30 -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 S2394161AbfBOLOT (ORCPT + 99 others); Fri, 15 Feb 2019 06:14:19 -0500 Received: from mx1.redhat.com ([209.132.183.28]:63522 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727852AbfBOLOR (ORCPT ); Fri, 15 Feb 2019 06:14:17 -0500 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id B0FAE8666D; Fri, 15 Feb 2019 11:14:16 +0000 (UTC) Received: from localhost (ovpn-8-22.pek2.redhat.com [10.72.8.22]) by smtp.corp.redhat.com (Postfix) with ESMTP id 01A5960C62; Fri, 15 Feb 2019 11:13:59 +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, 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 V15 02/18] block: don't use bio->bi_vcnt to figure out segment number Date: Fri, 15 Feb 2019 19:13:08 +0800 Message-Id: <20190215111324.30129-3-ming.lei@redhat.com> In-Reply-To: <20190215111324.30129-1-ming.lei@redhat.com> References: <20190215111324.30129-1-ming.lei@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Fri, 15 Feb 2019 11:14: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: Omar Sandoval 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 71e9ac03f621..f85d878f313d 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