On 3/22/19 7:13 AM, Johannes Thumshirn wrote:
> @@ -712,7 +714,10 @@ int bio_add_pc_page(struct request_queue *q, struct bio 
> *bio, struct page
>       bvec->bv_len = len;
>       bvec->bv_offset = offset;
>       bio->bi_vcnt++;
> -     bio->bi_phys_segments++;
> +     if (bio->bi_phys_segments == -1)
> +             bio->bi_phys_segments = 1;
> +     else
> +             bio->bi_phys_segments++;
>       bio->bi_iter.bi_size += len;

Echo Christophs suggestion here.

> diff --git a/block/blk-core.c b/block/blk-core.c
> index 4673ebe42255..53372a16dd7c 100644
> --- a/block/blk-core.c
> +++ b/block/blk-core.c
> @@ -1514,6 +1514,7 @@ void blk_rq_bio_prep(struct request_queue *q, struct 
> request *rq,
>       else if (bio_op(bio) == REQ_OP_DISCARD)
>               rq->nr_phys_segments = 1;
>  
> +     WARN_ON(rq->nr_phys_segments == -1);
>       rq->__data_len = bio->bi_iter.bi_size;
>       rq->bio = rq->biotail = bio;

Just make that:

        else
                rq->nr_phys_segments = 0;

for the third case?

-- 
Jens Axboe

Reply via email to