From: Dave Chinner <david@fromorbit.com>
To: Chaitanya Kulkarni <Chaitanya.Kulkarni@wdc.com>
Cc: Damien Le Moal <Damien.LeMoal@wdc.com>,
"linux-block@vger.kernel.org" <linux-block@vger.kernel.org>,
"linux-xfs@vger.kernel.org" <linux-xfs@vger.kernel.org>,
"hch@lst.de" <hch@lst.de>,
"danil.kipnis@cloud.ionos.com" <danil.kipnis@cloud.ionos.com>,
"jinpu.wang@cloud.ionos.com" <jinpu.wang@cloud.ionos.com>
Subject: Re: [PATCH 2/2] xfs: use block layer helper for rw
Date: Wed, 8 Apr 2020 09:27:49 +1000 [thread overview]
Message-ID: <20200407232749.GC24067@dread.disaster.area> (raw)
In-Reply-To: <BYAPR04MB4965A3A58D804CCE9892266686C30@BYAPR04MB4965.namprd04.prod.outlook.com>
On Tue, Apr 07, 2020 at 08:06:35PM +0000, Chaitanya Kulkarni wrote:
> On 04/06/2020 05:32 PM, Damien Le Moal wrote:
> >> -
> >> >- do {
> >> >- struct page *page = kmem_to_page(data);
> >> >- unsigned int off = offset_in_page(data);
> >> >- unsigned int len = min_t(unsigned, left, PAGE_SIZE - off);
> >> >-
> >> >- while (bio_add_page(bio, page, len, off) != len) {
> >> >- struct bio *prev = bio;
> >> >-
> >> >- bio = bio_alloc(GFP_KERNEL, bio_max_vecs(left));
> >> >- bio_copy_dev(bio, prev);
> >> >- bio->bi_iter.bi_sector = bio_end_sector(prev);
> >> >- bio->bi_opf = prev->bi_opf;
> >> >- bio_chain(prev, bio);
> >> >-
> >> >- submit_bio(prev);
> >> >- }
> >> >-
> >> >- data += len;
> >> >- left -= len;
> >> >- } while (left > 0);
> > Your helper could use a similar loop structure. This is very easy to read.
> >
> If I understand correctly this pattern is used since it is not a part of
> block layer.
It's because it was simple and easy to understandi, not because of
the fact it is outside the core block layer.
Us XFS folks are simple people who like simple things that are easy to
understand because there is so much of XFS that is so horrifically
complex that we want to implement simple stuff once and just not
have to care about it again.
> The helpers in blk-lib.c are not accessible so this :-
So export the helpers?
> All above breaks the existing pattern and code reuse in blk-lib.c, since
> blk-lib.c:-
> 1. Already provides blk_next_bio() why repeat the bio allocation
> and bio chaining code ?
So export the helper?
> 2. Instead of adding a new helper bio_max_vecs() why not use existing
> __blkdev_sectors_to_bio_pages() ?
That's not an improvement. The XFS code is _much_ easier to read
and understand.
> 3. Why use two bios when it can be done with one bio with the helpers
> in blk-lib.c ?
That helper is blk_next_bio(), which hides the second bio inside it.
So you aren't actually getting rid of the need for two bio pointers.
> 4. Allows async version.
Which is not used by XFS, so just adds complexity to this XFS path
for no good reason.
Seriously, this 20 lines of code in XFS turns into 50-60 lines
of code in the block layer to do the same thing. How is that an
improvement?
Cheers,
Dave.
--
Dave Chinner
david@fromorbit.com
next prev parent reply other threads:[~2020-04-07 23:27 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-04-06 23:24 [PATCH 0/2] block: add bio based read-write helper Chaitanya Kulkarni
2020-04-06 23:24 ` [PATCH 1/2] block: add bio based rw helper for data buffer Chaitanya Kulkarni
2020-04-07 0:28 ` Damien Le Moal
2020-04-07 20:01 ` Chaitanya Kulkarni
2020-04-07 10:09 ` Danil Kipnis
2020-04-06 23:24 ` [PATCH 2/2] xfs: use block layer helper for rw Chaitanya Kulkarni
2020-04-07 0:32 ` Damien Le Moal
2020-04-07 20:06 ` Chaitanya Kulkarni
2020-04-07 23:27 ` Dave Chinner [this message]
2020-04-08 23:22 ` Chaitanya Kulkarni
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=20200407232749.GC24067@dread.disaster.area \
--to=david@fromorbit.com \
--cc=Chaitanya.Kulkarni@wdc.com \
--cc=Damien.LeMoal@wdc.com \
--cc=danil.kipnis@cloud.ionos.com \
--cc=hch@lst.de \
--cc=jinpu.wang@cloud.ionos.com \
--cc=linux-block@vger.kernel.org \
--cc=linux-xfs@vger.kernel.org \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox