2012-10-02 18:44:12

by Vivek Goyal

[permalink] [raw]
Subject: Re: [dm-devel] [PATCH v3 04/26] block: Refactor blk_update_request()

On Mon, Sep 24, 2012 at 03:34:44PM -0700, Kent Overstreet wrote:
> Converts it to use bio_advance(), simplifying it quite a bit in the
> process.
>
> Note that req_bio_endio() now always calls bio_advance() - which means
> it always loops over the biovec, not just on partial completions. Don't
> expect it to affect performance, but worth noting.
>
> Tested it by forcing partial updates, and dumping before and after on
> various bio/bvec fields when doing a partial update.
>
> Signed-off-by: Kent Overstreet <[email protected]>
> CC: Jens Axboe <[email protected]>
> ---
> block/blk-core.c | 80 +++++++++-----------------------------------------------
> 1 file changed, 12 insertions(+), 68 deletions(-)
>
> diff --git a/block/blk-core.c b/block/blk-core.c
> index a17869f..a8a1a9e 100644
> --- a/block/blk-core.c
> +++ b/block/blk-core.c
> @@ -158,20 +158,10 @@ static void req_bio_endio(struct request *rq, struct bio *bio,
> else if (!test_bit(BIO_UPTODATE, &bio->bi_flags))
> error = -EIO;
>
> - if (unlikely(nbytes > bio->bi_size)) {
> - printk(KERN_ERR "%s: want %u bytes done, %u left\n",
> - __func__, nbytes, bio->bi_size);
> - nbytes = bio->bi_size;
> - }
> -

You are dropping this warning because nobody is calling req_bio_endio()
with bytes greater than bio size in current code?

Otherwise this looks like a good simplification of blk_update_request()
code.

Thanks
Vivek


2012-10-02 20:10:19

by Kent Overstreet

[permalink] [raw]
Subject: Re: [dm-devel] [PATCH v3 04/26] block: Refactor blk_update_request()

On Tue, Oct 02, 2012 at 02:43:59PM -0400, Vivek Goyal wrote:
> On Mon, Sep 24, 2012 at 03:34:44PM -0700, Kent Overstreet wrote:
> > Converts it to use bio_advance(), simplifying it quite a bit in the
> > process.
> >
> > Note that req_bio_endio() now always calls bio_advance() - which means
> > it always loops over the biovec, not just on partial completions. Don't
> > expect it to affect performance, but worth noting.
> >
> > Tested it by forcing partial updates, and dumping before and after on
> > various bio/bvec fields when doing a partial update.
> >
> > Signed-off-by: Kent Overstreet <[email protected]>
> > CC: Jens Axboe <[email protected]>
> > ---
> > block/blk-core.c | 80 +++++++++-----------------------------------------------
> > 1 file changed, 12 insertions(+), 68 deletions(-)
> >
> > diff --git a/block/blk-core.c b/block/blk-core.c
> > index a17869f..a8a1a9e 100644
> > --- a/block/blk-core.c
> > +++ b/block/blk-core.c
> > @@ -158,20 +158,10 @@ static void req_bio_endio(struct request *rq, struct bio *bio,
> > else if (!test_bit(BIO_UPTODATE, &bio->bi_flags))
> > error = -EIO;
> >
> > - if (unlikely(nbytes > bio->bi_size)) {
> > - printk(KERN_ERR "%s: want %u bytes done, %u left\n",
> > - __func__, nbytes, bio->bi_size);
> > - nbytes = bio->bi_size;
> > - }
> > -
>
> You are dropping this warning because nobody is calling req_bio_endio()
> with bytes greater than bio size in current code?

Not dropping it, just moved it to bio_advance()

2012-10-02 20:15:03

by Vivek Goyal

[permalink] [raw]
Subject: Re: [dm-devel] [PATCH v3 04/26] block: Refactor blk_update_request()

On Tue, Oct 02, 2012 at 01:10:14PM -0700, Kent Overstreet wrote:
> On Tue, Oct 02, 2012 at 02:43:59PM -0400, Vivek Goyal wrote:
> > On Mon, Sep 24, 2012 at 03:34:44PM -0700, Kent Overstreet wrote:
> > > Converts it to use bio_advance(), simplifying it quite a bit in the
> > > process.
> > >
> > > Note that req_bio_endio() now always calls bio_advance() - which means
> > > it always loops over the biovec, not just on partial completions. Don't
> > > expect it to affect performance, but worth noting.
> > >
> > > Tested it by forcing partial updates, and dumping before and after on
> > > various bio/bvec fields when doing a partial update.
> > >
> > > Signed-off-by: Kent Overstreet <[email protected]>
> > > CC: Jens Axboe <[email protected]>
> > > ---
> > > block/blk-core.c | 80 +++++++++-----------------------------------------------
> > > 1 file changed, 12 insertions(+), 68 deletions(-)
> > >
> > > diff --git a/block/blk-core.c b/block/blk-core.c
> > > index a17869f..a8a1a9e 100644
> > > --- a/block/blk-core.c
> > > +++ b/block/blk-core.c
> > > @@ -158,20 +158,10 @@ static void req_bio_endio(struct request *rq, struct bio *bio,
> > > else if (!test_bit(BIO_UPTODATE, &bio->bi_flags))
> > > error = -EIO;
> > >
> > > - if (unlikely(nbytes > bio->bi_size)) {
> > > - printk(KERN_ERR "%s: want %u bytes done, %u left\n",
> > > - __func__, nbytes, bio->bi_size);
> > > - nbytes = bio->bi_size;
> > > - }
> > > -
> >
> > You are dropping this warning because nobody is calling req_bio_endio()
> > with bytes greater than bio size in current code?
>
> Not dropping it, just moved it to bio_advance()

bio_advance() is checking bio vec count and idx and not nr_bytes.

Thanks
Vivek

2012-10-02 20:25:24

by Kent Overstreet

[permalink] [raw]
Subject: Re: [dm-devel] [PATCH v3 04/26] block: Refactor blk_update_request()

On Tue, Oct 02, 2012 at 04:14:51PM -0400, Vivek Goyal wrote:
> On Tue, Oct 02, 2012 at 01:10:14PM -0700, Kent Overstreet wrote:
> > On Tue, Oct 02, 2012 at 02:43:59PM -0400, Vivek Goyal wrote:
> > > On Mon, Sep 24, 2012 at 03:34:44PM -0700, Kent Overstreet wrote:
> > > > Converts it to use bio_advance(), simplifying it quite a bit in the
> > > > process.
> > > >
> > > > Note that req_bio_endio() now always calls bio_advance() - which means
> > > > it always loops over the biovec, not just on partial completions. Don't
> > > > expect it to affect performance, but worth noting.
> > > >
> > > > Tested it by forcing partial updates, and dumping before and after on
> > > > various bio/bvec fields when doing a partial update.
> > > >
> > > > Signed-off-by: Kent Overstreet <[email protected]>
> > > > CC: Jens Axboe <[email protected]>
> > > > ---
> > > > block/blk-core.c | 80 +++++++++-----------------------------------------------
> > > > 1 file changed, 12 insertions(+), 68 deletions(-)
> > > >
> > > > diff --git a/block/blk-core.c b/block/blk-core.c
> > > > index a17869f..a8a1a9e 100644
> > > > --- a/block/blk-core.c
> > > > +++ b/block/blk-core.c
> > > > @@ -158,20 +158,10 @@ static void req_bio_endio(struct request *rq, struct bio *bio,
> > > > else if (!test_bit(BIO_UPTODATE, &bio->bi_flags))
> > > > error = -EIO;
> > > >
> > > > - if (unlikely(nbytes > bio->bi_size)) {
> > > > - printk(KERN_ERR "%s: want %u bytes done, %u left\n",
> > > > - __func__, nbytes, bio->bi_size);
> > > > - nbytes = bio->bi_size;
> > > > - }
> > > > -
> > >
> > > You are dropping this warning because nobody is calling req_bio_endio()
> > > with bytes greater than bio size in current code?
> >
> > Not dropping it, just moved it to bio_advance()
>
> bio_advance() is checking bio vec count and idx and not nr_bytes.

Whoops, -ENOCOFFEE... I didn't fully read that code fragment.

Yes, req_bio_endio() is only called from one place, and
blk_update_request() never calls it with nbytes > bio->bi_size (and
after the refactor it's more obviously impossible).