md: raid1/raid10: initialize bvec table via bio_add_page()
We will support multipage bvec soon, so initialize bvec table using the standardy way instead of writing the talbe directly. Otherwise it won't work any more once multipage bvec is enabled. Acked-by: Guoqing Jiang <gqjiang@suse.com> Signed-off-by: Ming Lei <ming.lei@redhat.com> Signed-off-by: Shaohua Li <shli@fb.com>
This commit is contained in:
parent
022e510fcb
commit
fb0eb5df09
3 changed files with 27 additions and 16 deletions
19
drivers/md/raid1-10.c
Normal file
19
drivers/md/raid1-10.c
Normal file
|
@ -0,0 +1,19 @@
|
|||
/* generally called after bio_reset() for reseting bvec */
|
||||
static void md_bio_reset_resync_pages(struct bio *bio, struct resync_pages *rp,
|
||||
int size)
|
||||
{
|
||||
int idx = 0;
|
||||
|
||||
/* initialize bvec table again */
|
||||
do {
|
||||
struct page *page = resync_fetch_page(rp, idx);
|
||||
int len = min_t(int, size, PAGE_SIZE);
|
||||
|
||||
/*
|
||||
* won't fail because the vec table is big
|
||||
* enough to hold all these pages
|
||||
*/
|
||||
bio_add_page(bio, page, len, 0);
|
||||
size -= len;
|
||||
} while (idx++ < RESYNC_PAGES && size > 0);
|
||||
}
|
|
@ -81,6 +81,8 @@ static void lower_barrier(struct r1conf *conf, sector_t sector_nr);
|
|||
#define raid1_log(md, fmt, args...) \
|
||||
do { if ((md)->queue) blk_add_trace_msg((md)->queue, "raid1 " fmt, ##args); } while (0)
|
||||
|
||||
#include "raid1-10.c"
|
||||
|
||||
/*
|
||||
* 'strct resync_pages' stores actual pages used for doing the resync
|
||||
* IO, and it is per-bio, so make .bi_private points to it.
|
||||
|
@ -2085,10 +2087,7 @@ static void process_checks(struct r1bio *r1_bio)
|
|||
/* Fix variable parts of all bios */
|
||||
vcnt = (r1_bio->sectors + PAGE_SIZE / 512 - 1) >> (PAGE_SHIFT - 9);
|
||||
for (i = 0; i < conf->raid_disks * 2; i++) {
|
||||
int j;
|
||||
int size;
|
||||
blk_status_t status;
|
||||
struct bio_vec *bi;
|
||||
struct bio *b = r1_bio->bios[i];
|
||||
struct resync_pages *rp = get_resync_pages(b);
|
||||
if (b->bi_end_io != end_sync_read)
|
||||
|
@ -2097,8 +2096,6 @@ static void process_checks(struct r1bio *r1_bio)
|
|||
status = b->bi_status;
|
||||
bio_reset(b);
|
||||
b->bi_status = status;
|
||||
b->bi_vcnt = vcnt;
|
||||
b->bi_iter.bi_size = r1_bio->sectors << 9;
|
||||
b->bi_iter.bi_sector = r1_bio->sector +
|
||||
conf->mirrors[i].rdev->data_offset;
|
||||
b->bi_bdev = conf->mirrors[i].rdev->bdev;
|
||||
|
@ -2106,15 +2103,8 @@ static void process_checks(struct r1bio *r1_bio)
|
|||
rp->raid_bio = r1_bio;
|
||||
b->bi_private = rp;
|
||||
|
||||
size = b->bi_iter.bi_size;
|
||||
bio_for_each_segment_all(bi, b, j) {
|
||||
bi->bv_offset = 0;
|
||||
if (size > PAGE_SIZE)
|
||||
bi->bv_len = PAGE_SIZE;
|
||||
else
|
||||
bi->bv_len = size;
|
||||
size -= PAGE_SIZE;
|
||||
}
|
||||
/* initialize bvec table again */
|
||||
md_bio_reset_resync_pages(b, rp, r1_bio->sectors << 9);
|
||||
}
|
||||
for (primary = 0; primary < conf->raid_disks * 2; primary++)
|
||||
if (r1_bio->bios[primary]->bi_end_io == end_sync_read &&
|
||||
|
|
|
@ -110,6 +110,8 @@ static void end_reshape(struct r10conf *conf);
|
|||
#define raid10_log(md, fmt, args...) \
|
||||
do { if ((md)->queue) blk_add_trace_msg((md)->queue, "raid10 " fmt, ##args); } while (0)
|
||||
|
||||
#include "raid1-10.c"
|
||||
|
||||
/*
|
||||
* 'strct resync_pages' stores actual pages used for doing the resync
|
||||
* IO, and it is per-bio, so make .bi_private points to it.
|
||||
|
@ -2086,8 +2088,8 @@ static void sync_request_write(struct mddev *mddev, struct r10bio *r10_bio)
|
|||
rp = get_resync_pages(tbio);
|
||||
bio_reset(tbio);
|
||||
|
||||
tbio->bi_vcnt = vcnt;
|
||||
tbio->bi_iter.bi_size = fbio->bi_iter.bi_size;
|
||||
md_bio_reset_resync_pages(tbio, rp, fbio->bi_iter.bi_size);
|
||||
|
||||
rp->raid_bio = r10_bio;
|
||||
tbio->bi_private = rp;
|
||||
tbio->bi_iter.bi_sector = r10_bio->devs[i].addr;
|
||||
|
|
Loading…
Reference in a new issue