Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp2408151imu; Wed, 21 Nov 2018 11:08:53 -0800 (PST) X-Google-Smtp-Source: AFSGD/WwzHtoHYgRrd4jjz0soBMVqkIkd/+Q+M7z2OhIiPxMuMvRRf+tDzAfK20PvNC+5vebbbDc X-Received: by 2002:a63:b81a:: with SMTP id p26mr7219277pge.433.1542827333674; Wed, 21 Nov 2018 11:08:53 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1542827333; cv=none; d=google.com; s=arc-20160816; b=RkXTy1K3un4FL9WIDY2mlkGGnTdcEUsKHfbr4pOognjNn4rBdFb8+L7HWL4ikEwfKd yih/oB2rQwUQ3q5UV8xy02sk2FAq9r7gFx3889NbuG2mnOZatDqyMzcqJW+89cAzy07N KXa4B98b9Df7KDaCjjHyt89RMW3q9eAOmdFofOUnjMb98yweODo6Ri+rdAftjBjuEV2r hGV90cG38X4mWNdoL7Khzimkzmta4qKWxRlDVaSyMXB3bChd6kmRGOoTEwtH4raOb4sR YStGWOV2bt6eKsPVLVChIlYtUWdY88MEL4Nn/Kzo0a3pw5v6ZmOb63gNqF9KeHi81X3j ajZQ== 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=YnJDOh+/cbB0imn5MRiVtPrY1WoJBqHd2cr2U4QG1LI=; b=p70SlT5RCUawf6A1BMHfLW4jNXczoovliV4kjd8PEvEMMMsAy8CkbbI/5iMWbda9RU ZKBOupiEeO/zynPVUTMJYHIY3cbhwkGKw9wX8YjzFFAkdi6DTjblJOwWxRt0raij51kz 7l474UjF2w4i0vnroYBf0B4wECh7C2KnM9fhB8SZemFmeaH6aLK9Jvq19cJORUngSlJ3 aiCF3zrHopzVB6Jpmf1wLVsJeJ2Czei2ecb+a3a4mOR1grlKRCS3vHjvu+ocRlg2+KKK uVyBhsrEo66B3BRvmVH3pd2eYvXLJyl0CMUS3Z9bueZ8N+udNdFYbznUXSwsrSCNRARy tptw== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id o61si3052267pld.246.2018.11.21.11.08.38; Wed, 21 Nov 2018 11:08:53 -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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732124AbeKVDre (ORCPT + 99 others); Wed, 21 Nov 2018 22:47:34 -0500 Received: from verein.lst.de ([213.95.11.211]:52660 "EHLO newverein.lst.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725995AbeKVDre (ORCPT ); Wed, 21 Nov 2018 22:47:34 -0500 Received: by newverein.lst.de (Postfix, from userid 2407) id 248B268C19; Wed, 21 Nov 2018 18:12:17 +0100 (CET) Date: Wed, 21 Nov 2018 18:12:17 +0100 From: Christoph Hellwig To: Ming Lei Cc: Christoph Hellwig , 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: <20181121171217.GA6259@lst.de> 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.5.17 (2007-11-01) 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: > 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. FYI, this patch reverts the max_seg_len related changes back to where we are in mainline, and as expected everything works fine for me: diff --git a/include/linux/bio.h b/include/linux/bio.h index e5b975fa0558..926550ce2d21 100644 --- a/include/linux/bio.h +++ b/include/linux/bio.h @@ -137,24 +137,18 @@ static inline bool bio_full(struct bio *bio) for (i = 0, iter_all.idx = 0; iter_all.idx < (bio)->bi_vcnt; iter_all.idx++) \ bvec_for_each_segment(bvl, &((bio)->bi_io_vec[iter_all.idx]), i, iter_all) -static inline void __bio_advance_iter(struct bio *bio, struct bvec_iter *iter, - unsigned bytes, unsigned max_seg_len) +static inline void bio_advance_iter(struct bio *bio, struct bvec_iter *iter, + unsigned bytes) { iter->bi_sector += bytes >> 9; if (bio_no_advance_iter(bio)) iter->bi_size -= bytes; else - __bvec_iter_advance(bio->bi_io_vec, iter, bytes, max_seg_len); + bvec_iter_advance(bio->bi_io_vec, iter, bytes); /* TODO: It is reasonable to complete bio with error here. */ } -static inline void bio_advance_iter(struct bio *bio, struct bvec_iter *iter, - unsigned bytes) -{ - __bio_advance_iter(bio, iter, bytes, PAGE_SIZE); -} - #define __bio_for_each_segment(bvl, bio, iter, start) \ for (iter = (start); \ (iter).bi_size && \ @@ -168,7 +162,7 @@ static inline void bio_advance_iter(struct bio *bio, struct bvec_iter *iter, for (iter = (start); \ (iter).bi_size && \ ((bvl = bio_iter_mp_iovec((bio), (iter))), 1); \ - __bio_advance_iter((bio), &(iter), (bvl).bv_len, BVEC_MAX_LEN)) + bio_advance_iter((bio), &(iter), (bvl).bv_len)) /* returns one real segment(multi-page bvec) each time */ #define bio_for_each_bvec(bvl, bio, iter) \ diff --git a/include/linux/bvec.h b/include/linux/bvec.h index cab36d838ed0..138b4007b8f2 100644 --- a/include/linux/bvec.h +++ b/include/linux/bvec.h @@ -25,8 +25,6 @@ #include #include -#define BVEC_MAX_LEN ((unsigned int)-1) - /* * was unsigned short, but we might as well be ready for > 64kB I/O pages */ @@ -102,8 +100,8 @@ struct bvec_iter_all { .bv_offset = segment_iter_offset((bvec), (iter)), \ }) -static inline bool __bvec_iter_advance(const struct bio_vec *bv, - struct bvec_iter *iter, unsigned bytes, unsigned max_seg_len) +static inline bool bvec_iter_advance(const struct bio_vec *bv, + struct bvec_iter *iter, unsigned bytes) { if (WARN_ONCE(bytes > iter->bi_size, "Attempted to advance past end of bvec iter\n")) { @@ -112,18 +110,12 @@ static inline bool __bvec_iter_advance(const struct bio_vec *bv, } while (bytes) { - unsigned segment_len = segment_iter_len(bv, *iter); - - if (max_seg_len < BVEC_MAX_LEN) - segment_len = min_t(unsigned, segment_len, - max_seg_len - - bvec_iter_offset(bv, *iter)); + unsigned iter_len = bvec_iter_len(bv, *iter); + unsigned len = min(bytes, iter_len); - segment_len = min(bytes, segment_len); - - bytes -= segment_len; - iter->bi_size -= segment_len; - iter->bi_bvec_done += segment_len; + bytes -= len; + iter->bi_size -= len; + iter->bi_bvec_done += len; if (iter->bi_bvec_done == __bvec_iter_bvec(bv, *iter)->bv_len) { iter->bi_bvec_done = 0; @@ -157,13 +149,6 @@ static inline bool bvec_iter_rewind(const struct bio_vec *bv, return true; } -static inline bool bvec_iter_advance(const struct bio_vec *bv, - struct bvec_iter *iter, - unsigned bytes) -{ - return __bvec_iter_advance(bv, iter, bytes, PAGE_SIZE); -} - #define for_each_bvec(bvl, bio_vec, iter, start) \ for (iter = (start); \ (iter).bi_size && \