Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit fb9e3534 authored by Kent Overstreet's avatar Kent Overstreet
Browse files

md: Convert md_trim_bio() to use bio_advance()



Signed-off-by: default avatarKent Overstreet <koverstreet@google.com>
CC: Jens Axboe <axboe@kernel.dk>
CC: NeilBrown <neilb@suse.de>
Acked-by: default avatarNeilBrown <neilb@suse.de>
parent f79ea416
Loading
Loading
Loading
Loading
+4 −13
Original line number Original line Diff line number Diff line
@@ -194,21 +194,12 @@ void md_trim_bio(struct bio *bio, int offset, int size)
	if (offset == 0 && size == bio->bi_size)
	if (offset == 0 && size == bio->bi_size)
		return;
		return;


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


	while (bio->bi_idx < bio->bi_vcnt &&
	bio_advance(bio, offset << 9);
	       bio->bi_io_vec[bio->bi_idx].bv_len <= offset) {

		/* remove this whole bio_vec */
	bio->bi_size = size;
		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;
	}
	/* avoid any complications with bi_idx being non-zero*/
	/* avoid any complications with bi_idx being non-zero*/
	if (bio->bi_idx) {
	if (bio->bi_idx) {
		memmove(bio->bi_io_vec, bio->bi_io_vec+bio->bi_idx,
		memmove(bio->bi_io_vec, bio->bi_io_vec+bio->bi_idx,