Commit 8be185f2 authored by Kent Overstreet's avatar Kent Overstreet

raid10: Use bio_reset()

More prep work for immutable bio vecs, mainly getting rid of references
to bi_idx.

bio_reset was being open coded in a few places. The one in sync_request
was a bit nontrivial to convert, so could use some extra eyeballs.
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 9e882242
...@@ -2077,13 +2077,10 @@ static void sync_request_write(struct mddev *mddev, struct r10bio *r10_bio) ...@@ -2077,13 +2077,10 @@ static void sync_request_write(struct mddev *mddev, struct r10bio *r10_bio)
* First we need to fixup bv_offset, bv_len and * First we need to fixup bv_offset, bv_len and
* bi_vecs, as the read request might have corrupted these * bi_vecs, as the read request might have corrupted these
*/ */
bio_reset(tbio);
tbio->bi_vcnt = vcnt; tbio->bi_vcnt = vcnt;
tbio->bi_size = r10_bio->sectors << 9; tbio->bi_size = r10_bio->sectors << 9;
tbio->bi_idx = 0;
tbio->bi_phys_segments = 0;
tbio->bi_flags &= ~(BIO_POOL_MASK - 1);
tbio->bi_flags |= 1 << BIO_UPTODATE;
tbio->bi_next = NULL;
tbio->bi_rw = WRITE; tbio->bi_rw = WRITE;
tbio->bi_private = r10_bio; tbio->bi_private = r10_bio;
tbio->bi_sector = r10_bio->devs[i].addr; tbio->bi_sector = r10_bio->devs[i].addr;
...@@ -3090,6 +3087,7 @@ static sector_t sync_request(struct mddev *mddev, sector_t sector_nr, ...@@ -3090,6 +3087,7 @@ static sector_t sync_request(struct mddev *mddev, sector_t sector_nr,
} }
} }
bio = r10_bio->devs[0].bio; bio = r10_bio->devs[0].bio;
bio_reset(bio);
bio->bi_next = biolist; bio->bi_next = biolist;
biolist = bio; biolist = bio;
bio->bi_private = r10_bio; bio->bi_private = r10_bio;
...@@ -3114,6 +3112,7 @@ static sector_t sync_request(struct mddev *mddev, sector_t sector_nr, ...@@ -3114,6 +3112,7 @@ static sector_t sync_request(struct mddev *mddev, sector_t sector_nr,
rdev = mirror->rdev; rdev = mirror->rdev;
if (!test_bit(In_sync, &rdev->flags)) { if (!test_bit(In_sync, &rdev->flags)) {
bio = r10_bio->devs[1].bio; bio = r10_bio->devs[1].bio;
bio_reset(bio);
bio->bi_next = biolist; bio->bi_next = biolist;
biolist = bio; biolist = bio;
bio->bi_private = r10_bio; bio->bi_private = r10_bio;
...@@ -3142,6 +3141,7 @@ static sector_t sync_request(struct mddev *mddev, sector_t sector_nr, ...@@ -3142,6 +3141,7 @@ static sector_t sync_request(struct mddev *mddev, sector_t sector_nr,
if (rdev == NULL || bio == NULL || if (rdev == NULL || bio == NULL ||
test_bit(Faulty, &rdev->flags)) test_bit(Faulty, &rdev->flags))
break; break;
bio_reset(bio);
bio->bi_next = biolist; bio->bi_next = biolist;
biolist = bio; biolist = bio;
bio->bi_private = r10_bio; bio->bi_private = r10_bio;
...@@ -3240,7 +3240,7 @@ static sector_t sync_request(struct mddev *mddev, sector_t sector_nr, ...@@ -3240,7 +3240,7 @@ static sector_t sync_request(struct mddev *mddev, sector_t sector_nr,
r10_bio->devs[i].repl_bio->bi_end_io = NULL; r10_bio->devs[i].repl_bio->bi_end_io = NULL;
bio = r10_bio->devs[i].bio; bio = r10_bio->devs[i].bio;
bio->bi_end_io = NULL; bio_reset(bio);
clear_bit(BIO_UPTODATE, &bio->bi_flags); clear_bit(BIO_UPTODATE, &bio->bi_flags);
if (conf->mirrors[d].rdev == NULL || if (conf->mirrors[d].rdev == NULL ||
test_bit(Faulty, &conf->mirrors[d].rdev->flags)) test_bit(Faulty, &conf->mirrors[d].rdev->flags))
...@@ -3277,6 +3277,7 @@ static sector_t sync_request(struct mddev *mddev, sector_t sector_nr, ...@@ -3277,6 +3277,7 @@ static sector_t sync_request(struct mddev *mddev, sector_t sector_nr,
/* Need to set up for writing to the replacement */ /* Need to set up for writing to the replacement */
bio = r10_bio->devs[i].repl_bio; bio = r10_bio->devs[i].repl_bio;
bio_reset(bio);
clear_bit(BIO_UPTODATE, &bio->bi_flags); clear_bit(BIO_UPTODATE, &bio->bi_flags);
sector = r10_bio->devs[i].addr; sector = r10_bio->devs[i].addr;
...@@ -3310,17 +3311,6 @@ static sector_t sync_request(struct mddev *mddev, sector_t sector_nr, ...@@ -3310,17 +3311,6 @@ static sector_t sync_request(struct mddev *mddev, sector_t sector_nr,
} }
} }
for (bio = biolist; bio ; bio=bio->bi_next) {
bio->bi_flags &= ~(BIO_POOL_MASK - 1);
if (bio->bi_end_io)
bio->bi_flags |= 1 << BIO_UPTODATE;
bio->bi_vcnt = 0;
bio->bi_idx = 0;
bio->bi_phys_segments = 0;
bio->bi_size = 0;
}
nr_sectors = 0; nr_sectors = 0;
if (sector_nr + max_sync < max_sector) if (sector_nr + max_sync < max_sector)
max_sector = sector_nr + max_sync; max_sector = sector_nr + max_sync;
...@@ -4390,17 +4380,14 @@ static sector_t reshape_request(struct mddev *mddev, sector_t sector_nr, ...@@ -4390,17 +4380,14 @@ static sector_t reshape_request(struct mddev *mddev, sector_t sector_nr,
} }
if (!rdev2 || test_bit(Faulty, &rdev2->flags)) if (!rdev2 || test_bit(Faulty, &rdev2->flags))
continue; continue;
bio_reset(b);
b->bi_bdev = rdev2->bdev; b->bi_bdev = rdev2->bdev;
b->bi_sector = r10_bio->devs[s/2].addr + rdev2->new_data_offset; b->bi_sector = r10_bio->devs[s/2].addr + rdev2->new_data_offset;
b->bi_private = r10_bio; b->bi_private = r10_bio;
b->bi_end_io = end_reshape_write; b->bi_end_io = end_reshape_write;
b->bi_rw = WRITE; b->bi_rw = WRITE;
b->bi_flags &= ~(BIO_POOL_MASK - 1);
b->bi_flags |= 1 << BIO_UPTODATE;
b->bi_next = blist; b->bi_next = blist;
b->bi_vcnt = 0;
b->bi_idx = 0;
b->bi_size = 0;
blist = b; blist = b;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment