block: Fix cloning of discard/write same bios

Immutable biovecs changed the way bio segments are treated in such a way that
bio_for_each_segment() cannot now do what we want for discard/write same bios,
since bi_size means something completely different for them.

Fortunately discard and write same bios never have more than a single biovec, so
bio_for_each_segment() is unnecessary and not terribly meaningful for them, but
we still have to special case them in a few places.

Signed-off-by: Kent Overstreet <kmo@daterainc.com>
Tested-by: Richard W.M. Jones <rjones@redhat.com>
Signed-off-by: Jens Axboe <axboe@fb.com>
This commit is contained in:
Kent Overstreet 2014-02-10 17:45:50 -08:00 committed by Jens Axboe
parent 9d4cb8e3a5
commit 8423ae3d7a
2 changed files with 21 additions and 5 deletions

View file

@ -250,6 +250,17 @@ static inline unsigned bio_segments(struct bio *bio)
struct bio_vec bv;
struct bvec_iter iter;
/*
* We special case discard/write same, because they interpret bi_size
* differently:
*/
if (bio->bi_rw & REQ_DISCARD)
return 1;
if (bio->bi_rw & REQ_WRITE_SAME)
return 1;
bio_for_each_segment(bv, bio, iter)
segs++;