Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp765957imu; Thu, 22 Nov 2018 05:08:44 -0800 (PST) X-Google-Smtp-Source: AFSGD/Wzwlc6asvwpc1C8Bp1W0/97sOlK6L8ZdKRdQ/CvjoY2ZYJ7pVmIeNgVvTEHvar6E+3Zu01 X-Received: by 2002:a17:902:6b0c:: with SMTP id o12mr11357389plk.291.1542892124885; Thu, 22 Nov 2018 05:08:44 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1542892124; cv=none; d=google.com; s=arc-20160816; b=f10TVkxwL2+N4b4q8sDOoWMDl9/9OaojCJS59USm/pOBUze1MeZgTAntYHjav3WReo DfEuT6HCnddi9AsOTCzHKTGSRr65TPgxpFJziRk/qWVfj+vtueWTfZoTvpzrPBLKAq4Z 1+MidxfwdbePrO1cLHaY1tJtDBDOVAoDBOd5HT6dTOOQE0Gd/1BOiMZCB3J04WrhmeO9 fc1c1iICaHpeGujGnDEvaen1UJZko7cxCz09YSCMZqkKWhETGcUYolDyxQOpuHyLVCHe kM3IJln2LBB79MPokrUpO/YyTdXBBVIqQkTFjskfu0wiJ4UyW9dkhku4SOwwSMKoWXsb J6Mg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=GSVaISECjLR9PTtEu8GP6+CDWeS2lG/GQekE7sho/9M=; b=JvA/pNqLJrM4fe43MTLqRT8I+maBio7KWCsRXKwnMjOYDw5+oZ5s2R9RoDaiOm+swT wg3AnAZ0J8QGmzCKXj6inLFeUNCQ+jq0h5XTmGHgbNdJlurx63CF06YiK+zNQ8mjJcRU sOX3jh2fviatzySi+F83GaGpqvXCCpsME90/th0S1rIoIjn/Vq1+qXom/yWyI0JQZlD6 jLYXGP7/GfEa8VrPLnmSvHeO/rw6DDyPizUTm8V+MI/AuI/qbo8A+jVun4lWq+QpZR03 Jij9H9OA4Itqamgsn/h5BVmrdrekX8u1PsKZole26MxaiDoeCaGM7xw/63atkwOqzEyO 76TA== 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 82si36618219pfa.115.2018.11.22.05.08.28; Thu, 22 Nov 2018 05:08:44 -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 S2391317AbeKVLy0 (ORCPT + 99 others); Thu, 22 Nov 2018 06:54:26 -0500 Received: from mx1.redhat.com ([209.132.183.28]:38064 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732495AbeKVLy0 (ORCPT ); Thu, 22 Nov 2018 06:54:26 -0500 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id BEAE7792B7; Thu, 22 Nov 2018 01:17:30 +0000 (UTC) Received: from ming.t460p (ovpn-8-27.pek2.redhat.com [10.72.8.27]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 8687A600D6; Thu, 22 Nov 2018 01:17:10 +0000 (UTC) Date: Thu, 22 Nov 2018 09:17:06 +0800 From: Ming Lei To: Christoph Hellwig Cc: Jens Axboe , 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 , linux-ext4@vger.kernel.org, Coly Li , linux-bcache@vger.kernel.org, Boaz Harrosh , Bob Peterson , cluster-devel@redhat.com Subject: Re: [PATCH V11 03/19] block: introduce bio_for_each_bvec() Message-ID: <20181122011705.GC20814@ming.t460p> References: <20181121032327.8434-1-ming.lei@redhat.com> <20181121032327.8434-4-ming.lei@redhat.com> <20181121133244.GB1640@lst.de> <20181121153135.GB19111@ming.t460p> <20181121161025.GB4977@lst.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20181121161025.GB4977@lst.de> User-Agent: Mutt/1.9.1 (2017-09-22) X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Thu, 22 Nov 2018 01:17:31 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Nov 21, 2018 at 05:10:25PM +0100, Christoph Hellwig wrote: > On Wed, Nov 21, 2018 at 11:31:36PM +0800, Ming Lei wrote: > > > But while looking over this I wonder why we even need the max_seg_len > > > here. The only thing __bvec_iter_advance does it to move bi_bvec_done > > > and bi_idx forward, with corresponding decrements of bi_size. As far > > > as I can tell the only thing that max_seg_len does is that we need > > > to more iterations of the while loop to archive the same thing. > > > > > > And actual bvec used by the caller will be obtained using > > > bvec_iter_bvec or segment_iter_bvec depending on if they want multi-page > > > or single-page variants. > > > > Right, we let __bvec_iter_advance() serve for both multi-page and single-page > > case, then we have to tell it via one way or another, now we use the constant > > of 'max_seg_len'. > > > > Or you suggest to implement two versions of __bvec_iter_advance()? > > No - I think we can always use the code without any segment in > bvec_iter_advance. Because bvec_iter_advance only operates on the > iteractor, the generation of an actual single-page or multi-page > bvec is left to the caller using the bvec_iter_bvec or segment_iter_bvec > helpers. The only difference is how many bytes you can move the > iterator forward in a single loop iteration - so if you pass in > PAGE_SIZE as the max_seg_len you just will have to loop more often > for a large enough bytes, but not actually do anything different. Yeah, I see that. The difference is made by bio_iter_iovec()/bio_iter_mp_iovec() in __bio_for_each_segment()/__bio_for_each_bvec(). Thanks, Ming