Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp7769509imu; Thu, 15 Nov 2018 00:59:11 -0800 (PST) X-Google-Smtp-Source: AJdET5e5HJAxDHf/UCvy7b5tWgZ+STNO7j0OvJa8GMphP4eeT4KeP3sNglVVaK9mKswUPUhrgzMG X-Received: by 2002:a62:995c:: with SMTP id d89-v6mr5486576pfe.11.1542272351210; Thu, 15 Nov 2018 00:59:11 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1542272351; cv=none; d=google.com; s=arc-20160816; b=cF91HRFcM7lgcyUP1uycQZJTUpDu3S8mcQJLf+06R6LeLQ0vSjTmaBBR0/faRvt9yd WhdXSz83Z2C6MKWEuWPxdl49UEa68xitPRvJaLjfuHTyVs8cs8jn9HMmzDQ7PJp6IkAX 7dRh1/DO+mVwWpiMKr5YuSboOonTesF6XTlFDSEZ1gk2zsTGiHyHcW2ACIdPj/9EeT7n BWLdgh9Mf/r1O8TsJGmNRcoPUOE2hjtPO8SJkA0rR/i+1Xn48EPrigQcIdynR1jGT1em 60mO53XmAY3XK8gkG6RB05+1ZVFqWv+Wo1rxjLiT9wvwyGxD4gOgE+JasPhtboMJt3/M L2iQ== 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=bMFfeA1s4ovfbuodnvxSUpfFDcroT0auXSYw4L+o2mc=; b=XYxM4yKbDNm9eAJjnD4xrQ6c34pPXwim4K+cSx4nYYMKYLltBlMO8+v/9e2ypsD8M2 ryLBrZsVEphV6g/RitXXYYcsHFE4gX1v5ZeZLBV0bbb9G4O/3T+TRHRSn7huctjkqGOh TdB0ftV2IqvBGdl8lGRKfBReXG+8tHwg5XdqnMYOfh3f97H5/BlvHtJrKmm3lQgGEBtS jV1gJlRshgq3JoTSxtKIdgvoGVwIgnR7u0I8ww9GOzb2O8g1L1vuVApCfTD5JbYvxZa0 7MY8e7fluO9Kmjk6HZ/KRmjrT0n2kpOrTRSGmz653XKoxDWKc/RqpcenuKDDNC3RCZUp 5ZUA== 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 102si177821plc.277.2018.11.15.00.58.56; Thu, 15 Nov 2018 00:59:11 -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 S2387603AbeKOTFI (ORCPT + 99 others); Thu, 15 Nov 2018 14:05:08 -0500 Received: from mx1.redhat.com ([209.132.183.28]:60946 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728748AbeKOTFI (ORCPT ); Thu, 15 Nov 2018 14:05:08 -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 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) 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"). 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 --- 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))) -- 2.9.5