All of lore.kernel.org
 help / color / mirror / Atom feed
From: Matthew Wilcox <willy@infradead.org>
To: Hannes Reinecke <hare@suse.de>
Cc: Christoph Hellwig <hch@lst.de>, Ming Lei <ming.lei@redhat.com>,
	Jens Axboe <axboe@kernel.dk>,
	linux-block@vger.kernel.org, Qu Wenruo <quwenruo.btrfs@gmx.com>,
	linux-btrfs@vger.kernel.org, linux-fsdevel@vger.kernel.org,
	Omar Sandoval <osandov@fb.com>
Subject: Re: [PATCH] block: don't use for-inside-for in bio_for_each_segment_all
Date: Mon, 8 Apr 2019 07:12:04 -0700	[thread overview]
Message-ID: <20190408141203.GT22763@bombadil.infradead.org> (raw)
In-Reply-To: <f0c82caf-24f3-dba7-0bf0-85dd0e056e73@suse.de>

On Mon, Apr 08, 2019 at 08:07:55AM +0200, Hannes Reinecke wrote:
> Oh yes, please do.
> The macros are fast becoming unparseable :-)

I think something that would help is removing the mandatory 'i' parameter
to this iterator.  Most of the users don't use it, and the ones that do
can implement it themselves.  eg:


                int j;
                struct bio_vec *bv;
                void *base = (void *) ((unsigned long) i & ~(PAGE_SIZE - 1));
                struct bvec_iter_all iter_all;

                bio_for_each_segment_all(bv, b->bio, j, iter_all)
                        memcpy(page_address(bv->bv_page),
                               base + j * PAGE_SIZE, PAGE_SIZE);

could become

                struct bio_vec *bv;
                void *addr = (void *) ((unsigned long) i & ~(PAGE_SIZE - 1));
                struct bvec_iter_all iter_all;

                bio_for_each_segment_all(bv, b->bio, iter_all) {
                        memcpy(page_address(bv->bv_page), addr, PAGE_SIZE);
			addr += PAGE_SIZE;
		}

eg2:

                bio_for_each_segment_all(bi, sbio, j, iter_all)
                        page_len[j] = bi->bv_len;

could become:
                bio_for_each_segment_all(bi, sbio, iter_all)
                        page_len[j++] = bi->bv_len;


  reply	other threads:[~2019-04-08 14:12 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-04-06 21:54 [PATCH] block: don't use for-inside-for in bio_for_each_segment_all Ming Lei
2019-04-07  6:52 ` Christoph Hellwig
2019-04-07  7:37   ` Ming Lei
2019-04-07  7:38     ` Christoph Hellwig
2019-04-07  7:54     ` Ming Lei
2019-04-07  7:58       ` Christoph Hellwig
2019-04-07  8:13         ` Ming Lei
2019-04-08  6:07   ` Hannes Reinecke
2019-04-08 14:12     ` Matthew Wilcox [this message]
2019-04-09  9:48       ` Christoph Hellwig
2019-04-09 10:25         ` Johannes Thumshirn
2019-04-09 11:38         ` Matthew Wilcox
2019-04-09 15:36           ` David Sterba

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190408141203.GT22763@bombadil.infradead.org \
    --to=willy@infradead.org \
    --cc=axboe@kernel.dk \
    --cc=hare@suse.de \
    --cc=hch@lst.de \
    --cc=linux-block@vger.kernel.org \
    --cc=linux-btrfs@vger.kernel.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=ming.lei@redhat.com \
    --cc=osandov@fb.com \
    --cc=quwenruo.btrfs@gmx.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.