Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp8756952imu; Thu, 15 Nov 2018 17:24:57 -0800 (PST) X-Google-Smtp-Source: AJdET5c0QWaHJspbcM3Ht48ZC5bIa/VvYmI8Mp8Ylk4ZPlzr3XciQif6cTk+qHlslihdyP1zIk/6 X-Received: by 2002:a62:995c:: with SMTP id d89-v6mr8823281pfe.11.1542331497047; Thu, 15 Nov 2018 17:24:57 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1542331497; cv=none; d=google.com; s=arc-20160816; b=GRhbvJbEgwHiR20trXNs4NlY0rCclzeok5liLqrJ/A4iELFRVbRC/OVM6FTP9LGqg4 XXj2q2dAy7/44o0vrJP48mN9IQpBHy9aRWpDLHJv3UXfC+YZbsRLvXSynwd9/pNtUi3P arwjfGQZpA+gEtj3PYEJY2+fJlFKpdN+WKhH34d9nJBNVhXIavzWQjKcjPAzIAAXkQzA J74E9vPMveNgQNnCncLJo+K7+gfkCRv2U3sQq/92vj321Q8rE8LIL8w4RVjw/QH9KjLK 4jS6xbFgHkYuK1yq4bEwWctBqzJhekAoLJjP2UhfH2eA6YrLrS6IVCbb4LBgbbUV4xEI fqoQ== 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:dkim-signature; bh=++YP5hB9hKOFTY9FyOygO4kny3j/4AWi7Xqs+ptUFOc=; b=hgkco/OtexYusmyk8RUEtMmT14EYgRWDDmPC2taIT8Q28C9BQVKcArD82aKIg7ZfE1 Zrj2yUEioOO49d3TcdBsmrQfEUZmNyTTJRFSl5YRGyhPoQUmovr3Cy7rVV0DDtRLF/Jq ubR+tI3WKfumgGpaqrZtxAmlYB9FvLrUPBrHj58PNR+DwAgXxBsd7QdPUtwO+0dvsmWC VvpH6QhUfmnRQOsAioQOEbRmd07TkxRrUUJ0Oa+YcFKwEpYvW1tMCtA5xD3OpwryDjJ7 df7EMVsvgqWqTN5/DTMwsLS+k8cQSguHfP9XFfMC3pA1t6Z4TnFHpFS+3xjHetE7mZST SWVA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@osandov-com.20150623.gappssmtp.com header.s=20150623 header.b=rUdgOAW6; 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 bh6-v6si29306228plb.66.2018.11.15.17.24.41; Thu, 15 Nov 2018 17:24:57 -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; dkim=pass header.i=@osandov-com.20150623.gappssmtp.com header.s=20150623 header.b=rUdgOAW6; 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 S2389006AbeKPLdG (ORCPT + 99 others); Fri, 16 Nov 2018 06:33:06 -0500 Received: from mail-pl1-f193.google.com ([209.85.214.193]:35738 "EHLO mail-pl1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726980AbeKPLdG (ORCPT ); Fri, 16 Nov 2018 06:33:06 -0500 Received: by mail-pl1-f193.google.com with SMTP id v1-v6so3183878plo.2 for ; Thu, 15 Nov 2018 17:22:48 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=osandov-com.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=++YP5hB9hKOFTY9FyOygO4kny3j/4AWi7Xqs+ptUFOc=; b=rUdgOAW6730Y6L8qEFYTU8q/Jt5JNki5S7YVhpSCExYA9kcDfcx5P/GH2Py46jiFjd 1YfueXgp9PZuDh9EnuVZZhcVzLKwNUP4rXxEQGteaQvVgYB0YBNYulpd+7R9DErTK7AU lYawijmUMVfwfGUSQ4kmbtEY4J1C0BNqBCBxSgRDLqJYY+TKoZO3v454Yrmzh5bzUwby 4DOIsYJlmBYg/X0/OKFIUDfljLYk5d9pXY7rfeWIKLzbrtTPLF7veR2mi/2x+IvxKHBN zpEBnGp8mSBQs1fNs4AjStW0GrB3qO8Ys6VMqXFclvSHUdyx+t5tUo5CBytmmxj5W4Yw /yAA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=++YP5hB9hKOFTY9FyOygO4kny3j/4AWi7Xqs+ptUFOc=; b=ECqD3TlihhU1c8hK6AWMoEmr/5OfDeJS0EyAZ0+NNmirODpk6Q/Ny4ojxsQfAv5/mX bbWfHfCi5vwcsD5NuBtv3S7bH9R8IH6oYvgNrh0Nd4YfQvgIyEUJgZ3krrSd3pI4aCwt h8G1MGLGBA2HAUf5hSSy3i03k0JMkIb3FozufKPedNAKSwoy1VVTkU8B+riIoAppiuX0 wNwkGG76D4BZbP7tag1CZFdWkYZS9Xv/lb3mVieScrIduqCHWZS6ZhgcPv+vksEGYWkj 1Y8GxaBoQFs6YU/aN6FAu88ttVq4RezZfNL1CzHlrYAxRJpbivTmI4kQDdLOeTtN+9Pe 5SOw== X-Gm-Message-State: AGRZ1gJb7WMVjehHHtl9+hKUqe0TSNoP3w2KQznoeGdXZYmrCSsqWzLL 2CxhvunpAVaF1BNQxhjDhD751Q== X-Received: by 2002:a17:902:3283:: with SMTP id z3-v6mr8763583plb.308.1542331367373; Thu, 15 Nov 2018 17:22:47 -0800 (PST) Received: from vader ([64.114.255.97]) by smtp.gmail.com with ESMTPSA id t62sm32081185pgb.39.2018.11.15.17.22.46 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 15 Nov 2018 17:22:46 -0800 (PST) Date: Thu, 15 Nov 2018 17:22:45 -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 , linux-fsdevel@vger.kernel.org, Alexander Viro , Shaohua Li , linux-raid@vger.kernel.org, linux-erofs@lists.ozlabs.org, linux-btrfs@vger.kernel.org, David Sterba , "Darrick J . Wong" , 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 12/19] block: allow bio_for_each_segment_all() to iterate over multi-page bvec Message-ID: <20181116012245.GG23828@vader> References: <20181115085306.9910-1-ming.lei@redhat.com> <20181115085306.9910-13-ming.lei@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20181115085306.9910-13-ming.lei@redhat.com> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Nov 15, 2018 at 04:52:59PM +0800, Ming Lei wrote: > This patch introduces one extra iterator variable to bio_for_each_segment_all(), > then we can allow bio_for_each_segment_all() to iterate over multi-page bvec. > > Given it is just one mechannical & simple change on all bio_for_each_segment_all() > users, this patch does tree-wide change in one single patch, so that we can > avoid to use a temporary helper for this conversion. > > Cc: Dave Chinner > Cc: Kent Overstreet > Cc: linux-fsdevel@vger.kernel.org > Cc: Alexander Viro > Cc: Shaohua Li > Cc: linux-raid@vger.kernel.org > Cc: linux-erofs@lists.ozlabs.org > Cc: linux-btrfs@vger.kernel.org > Cc: David Sterba > Cc: Darrick J. Wong > 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/bio.c | 27 ++++++++++++++++++--------- > block/blk-zoned.c | 1 + > block/bounce.c | 6 ++++-- > drivers/md/bcache/btree.c | 3 ++- > drivers/md/dm-crypt.c | 3 ++- > drivers/md/raid1.c | 3 ++- > drivers/staging/erofs/data.c | 3 ++- > drivers/staging/erofs/unzip_vle.c | 3 ++- > fs/block_dev.c | 6 ++++-- > fs/btrfs/compression.c | 3 ++- > fs/btrfs/disk-io.c | 3 ++- > fs/btrfs/extent_io.c | 12 ++++++++---- > fs/btrfs/inode.c | 6 ++++-- > fs/btrfs/raid56.c | 3 ++- > fs/crypto/bio.c | 3 ++- > fs/direct-io.c | 4 +++- > fs/exofs/ore.c | 3 ++- > fs/exofs/ore_raid.c | 3 ++- > fs/ext4/page-io.c | 3 ++- > fs/ext4/readpage.c | 3 ++- > fs/f2fs/data.c | 9 ++++++--- > fs/gfs2/lops.c | 6 ++++-- > fs/gfs2/meta_io.c | 3 ++- > fs/iomap.c | 6 ++++-- > fs/mpage.c | 3 ++- > fs/xfs/xfs_aops.c | 5 +++-- > include/linux/bio.h | 11 +++++++++-- > include/linux/bvec.h | 31 +++++++++++++++++++++++++++++++ > 28 files changed, 129 insertions(+), 46 deletions(-) > [snip] > diff --git a/include/linux/bio.h b/include/linux/bio.h > index 3496c816946e..1a2430a8b89d 100644 > --- a/include/linux/bio.h > +++ b/include/linux/bio.h > @@ -131,12 +131,19 @@ static inline bool bio_full(struct bio *bio) > return bio->bi_vcnt >= bio->bi_max_vecs; > } > > +#define bvec_for_each_segment(bv, bvl, i, iter_all) \ > + for (bv = bvec_init_iter_all(&iter_all); \ > + (iter_all.done < (bvl)->bv_len) && \ > + ((bvec_next_segment((bvl), &iter_all)), 1); \ The parentheses around (bvec_next_segment((bvl), &iter_all)) are unnecessary. > + iter_all.done += bv->bv_len, i += 1) > + > /* > * drivers should _never_ use the all version - the bio may have been split > * before it got to the driver and the driver won't own all of it > */ > -#define bio_for_each_segment_all(bvl, bio, i) \ > - for (i = 0, bvl = (bio)->bi_io_vec; i < (bio)->bi_vcnt; i++, bvl++) > +#define bio_for_each_segment_all(bvl, bio, i, iter_all) \ > + 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) Would it be possible to move i into iter_all to streamline this a bit? > static inline void __bio_advance_iter(struct bio *bio, struct bvec_iter *iter, > unsigned bytes, bool mp) > diff --git a/include/linux/bvec.h b/include/linux/bvec.h > index 01616a0b6220..02f26d2b59ad 100644 > --- a/include/linux/bvec.h > +++ b/include/linux/bvec.h > @@ -82,6 +82,12 @@ struct bvec_iter { > current bvec */ > }; > > +struct bvec_iter_all { > + struct bio_vec bv; > + int idx; > + unsigned done; > +}; > + > /* > * various member access, note that bio_data should of course not be used > * on highmem page vectors > @@ -216,6 +222,31 @@ static inline bool mp_bvec_iter_advance(const struct bio_vec *bv, > .bi_bvec_done = 0, \ > } > > +static inline struct bio_vec *bvec_init_iter_all(struct bvec_iter_all *iter_all) > +{ > + iter_all->bv.bv_page = NULL; > + iter_all->done = 0; > + > + return &iter_all->bv; > +} > + > +/* used for chunk_for_each_segment */ > +static inline void bvec_next_segment(const struct bio_vec *bvec, > + struct bvec_iter_all *iter_all) Indentation. > +{ > + struct bio_vec *bv = &iter_all->bv; > + > + if (bv->bv_page) { > + bv->bv_page += 1; > + bv->bv_offset = 0; > + } else { > + bv->bv_page = bvec->bv_page; > + bv->bv_offset = bvec->bv_offset; > + } > + bv->bv_len = min_t(unsigned int, PAGE_SIZE - bv->bv_offset, > + bvec->bv_len - iter_all->done); Indentation. > +} > + > /* > * Get the last singlepage segment from the multipage bvec and store it > * in @seg > -- > 2.9.5 >