Skip to content

Commit

Permalink
md: Convert md_trim_bio() to use bio_advance()
Browse files Browse the repository at this point in the history
Signed-off-by: Kent Overstreet <[email protected]>
CC: Jens Axboe <[email protected]>
CC: NeilBrown <[email protected]>
Acked-by: NeilBrown <[email protected]>
  • Loading branch information
Kent Overstreet committed Mar 23, 2013
1 parent f79ea41 commit fb9e353
Showing 1 changed file with 4 additions and 13 deletions.
17 changes: 4 additions & 13 deletions drivers/md/md.c
Original file line number Diff line number Diff line change
Expand Up @@ -194,21 +194,12 @@ void md_trim_bio(struct bio *bio, int offset, int size)
if (offset == 0 && size == bio->bi_size)
return;

bio->bi_sector += offset;
bio->bi_size = size;
offset <<= 9;
clear_bit(BIO_SEG_VALID, &bio->bi_flags);

while (bio->bi_idx < bio->bi_vcnt &&
bio->bi_io_vec[bio->bi_idx].bv_len <= offset) {
/* remove this whole bio_vec */
offset -= bio->bi_io_vec[bio->bi_idx].bv_len;
bio->bi_idx++;
}
if (bio->bi_idx < bio->bi_vcnt) {
bio->bi_io_vec[bio->bi_idx].bv_offset += offset;
bio->bi_io_vec[bio->bi_idx].bv_len -= offset;
}
bio_advance(bio, offset << 9);

bio->bi_size = size;

/* avoid any complications with bi_idx being non-zero*/
if (bio->bi_idx) {
memmove(bio->bi_io_vec, bio->bi_io_vec+bio->bi_idx,
Expand Down

0 comments on commit fb9e353

Please sign in to comment.