Return-Path: Received: from mail-pg1-f193.google.com ([209.85.215.193]:42768 "EHLO mail-pg1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388816AbeKPEhu (ORCPT ); Thu, 15 Nov 2018 23:37:50 -0500 Received: by mail-pg1-f193.google.com with SMTP id d72so5934692pga.9 for ; Thu, 15 Nov 2018 10:28:56 -0800 (PST) Date: Thu, 15 Nov 2018 10:28:54 -0800 From: Omar Sandoval To: Ming Lei Cc: Jens Axboe , linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, 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: Re: [PATCH V10 02/19] block: introduce bio_for_each_bvec() Message-ID: <20181115182854.GB9348@vader> References: <20181115085306.9910-1-ming.lei@redhat.com> <20181115085306.9910-3-ming.lei@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20181115085306.9910-3-ming.lei@redhat.com> Sender: linux-ext4-owner@vger.kernel.org List-ID: On Thu, Nov 15, 2018 at 04:52:49PM +0800, Ming Lei wrote: > This helper is used for iterating over multi-page bvec for bio > split & merge code. > > Cc: Dave Chinner > Cc: Kent Overstreet > 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 Reviewed-by: Omar Sandoval One comment below. > Signed-off-by: Ming Lei > --- > include/linux/bio.h | 34 +++++++++++++++++++++++++++++++--- > include/linux/bvec.h | 36 ++++++++++++++++++++++++++++++++---- > 2 files changed, 63 insertions(+), 7 deletions(-) > > diff --git a/include/linux/bio.h b/include/linux/bio.h > index 056fb627edb3..1f0dcf109841 100644 > --- a/include/linux/bio.h > +++ b/include/linux/bio.h > @@ -76,6 +76,9 @@ > #define bio_data_dir(bio) \ > (op_is_write(bio_op(bio)) ? WRITE : READ) > > +#define bio_iter_mp_iovec(bio, iter) \ > + mp_bvec_iter_bvec((bio)->bi_io_vec, (iter)) > + > /* > * Check whether this bio carries any data or not. A NULL bio is allowed. > */ > @@ -135,18 +138,33 @@ static inline bool bio_full(struct bio *bio) > #define bio_for_each_segment_all(bvl, bio, i) \ > for (i = 0, bvl = (bio)->bi_io_vec; i < (bio)->bi_vcnt; i++, bvl++) > > -static inline void bio_advance_iter(struct bio *bio, struct bvec_iter *iter, > - unsigned bytes) > +static inline void __bio_advance_iter(struct bio *bio, struct bvec_iter *iter, > + unsigned bytes, bool mp) > { > 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); > + if (!mp) > + bvec_iter_advance(bio->bi_io_vec, iter, bytes); > + else > + mp_bvec_iter_advance(bio->bi_io_vec, iter, bytes); if (!foo) {} else {} hurts my brain, please do if (mp) mp_bvec_iter_advance(bio->bi_io_vec, iter, bytes); else bvec_iter_advance(bio->bi_io_vec, iter, bytes);