diff options
Diffstat (limited to 'drivers/md/md.c')
-rw-r--r-- | drivers/md/md.c | 17 |
1 files changed, 4 insertions, 13 deletions
diff --git a/drivers/md/md.c b/drivers/md/md.c index 6330c727396c..681d1099a2d5 100644 --- a/drivers/md/md.c +++ b/drivers/md/md.c | |||
@@ -197,21 +197,12 @@ void md_trim_bio(struct bio *bio, int offset, int size) | |||
197 | if (offset == 0 && size == bio->bi_size) | 197 | if (offset == 0 && size == bio->bi_size) |
198 | return; | 198 | return; |
199 | 199 | ||
200 | bio->bi_sector += offset; | ||
201 | bio->bi_size = size; | ||
202 | offset <<= 9; | ||
203 | clear_bit(BIO_SEG_VALID, &bio->bi_flags); | 200 | clear_bit(BIO_SEG_VALID, &bio->bi_flags); |
204 | 201 | ||
205 | while (bio->bi_idx < bio->bi_vcnt && | 202 | bio_advance(bio, offset << 9); |
206 | bio->bi_io_vec[bio->bi_idx].bv_len <= offset) { | 203 | |
207 | /* remove this whole bio_vec */ | 204 | bio->bi_size = size; |
208 | offset -= bio->bi_io_vec[bio->bi_idx].bv_len; | 205 | |
209 | bio->bi_idx++; | ||
210 | } | ||
211 | if (bio->bi_idx < bio->bi_vcnt) { | ||
212 | bio->bi_io_vec[bio->bi_idx].bv_offset += offset; | ||
213 | bio->bi_io_vec[bio->bi_idx].bv_len -= offset; | ||
214 | } | ||
215 | /* avoid any complications with bi_idx being non-zero*/ | 206 | /* avoid any complications with bi_idx being non-zero*/ |
216 | if (bio->bi_idx) { | 207 | if (bio->bi_idx) { |
217 | memmove(bio->bi_io_vec, bio->bi_io_vec+bio->bi_idx, | 208 | memmove(bio->bi_io_vec, bio->bi_io_vec+bio->bi_idx, |