Re: [PATCH] bio: decrease bi_iter.bi_size by len in the fail path

From: Maurizio Lombardi
Date: Thu May 29 2014 - 03:04:48 EST


On Thu, May 29, 2014 at 02:06:18PM +0800, Jet Chen wrote:
> This patch works, thanks.
>
> Tested-by: Jet Chen <jet.chen@xxxxxxxxx>
>

> diff --git a/block/bio.c b/block/bio.c
> index 0443694..f9bae56 100644
> --- a/block/bio.c
> +++ b/block/bio.c
> @@ -744,6 +744,7 @@ static int __bio_add_page(struct request_queue *q, struct bio *bio, struct page
> }
> }
>
> + bio->bi_iter.bi_size += len;
> goto done;
> }
> }
> @@ -761,6 +762,7 @@ static int __bio_add_page(struct request_queue *q, struct bio *bio, struct page
> bvec->bv_offset = offset;
> bio->bi_vcnt++;
> bio->bi_phys_segments++;
> + bio->bi_iter.bi_size += len;
>
> /*
> * Perform a recount if the number of segments is greater
> @@ -802,7 +804,6 @@ static int __bio_add_page(struct request_queue *q, struct bio *bio, struct page
> bio->bi_flags &= ~(1 << BIO_SEG_VALID);
>
> done:
> - bio->bi_iter.bi_size += len;
> return len;
>
> failed:
> @@ -810,6 +811,7 @@ static int __bio_add_page(struct request_queue *q, struct bio *bio, struct page
> bvec->bv_len = 0;
> bvec->bv_offset = 0;
> bio->bi_vcnt--;
> + bio->bi_iter.bi_size -= len;
> blk_recount_segments(q, bio);
> return 0;
> }

Good!

Jens, can you review and merge it?

Thanks,
Maurizio Lombardi

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/