diff options
author | Kent Overstreet <koverstreet@google.com> | 2012-09-10 18:17:11 -0400 |
---|---|---|
committer | Kent Overstreet <koverstreet@google.com> | 2013-03-23 17:15:36 -0400 |
commit | b783863f68c26c5411c50002f98a047a40b94e8e (patch) | |
tree | c5543888aaf568704188da8c955d435a6fd1d2d7 /drivers/md/raid1.c | |
parent | 2f6db2a7073452b123726e2baab1f37d511bf86d (diff) |
raid1: Refactor narrow_write_error() to not use bi_idx
More bi_idx removal. This code was just open coding bio_clone(). This
could probably be further improved by using bio_advance() instead of
skipping over null pages, but that'd be a larger rework.
Signed-off-by: Kent Overstreet <koverstreet@google.com>
CC: Jens Axboe <axboe@kernel.dk>
CC: NeilBrown <neilb@suse.de>
Diffstat (limited to 'drivers/md/raid1.c')
-rw-r--r-- | drivers/md/raid1.c | 36 |
1 files changed, 18 insertions, 18 deletions
diff --git a/drivers/md/raid1.c b/drivers/md/raid1.c index bb5ec7710c00..b36231866336 100644 --- a/drivers/md/raid1.c +++ b/drivers/md/raid1.c | |||
@@ -2063,8 +2063,6 @@ static int narrow_write_error(struct r1bio *r1_bio, int i) | |||
2063 | struct mddev *mddev = r1_bio->mddev; | 2063 | struct mddev *mddev = r1_bio->mddev; |
2064 | struct r1conf *conf = mddev->private; | 2064 | struct r1conf *conf = mddev->private; |
2065 | struct md_rdev *rdev = conf->mirrors[i].rdev; | 2065 | struct md_rdev *rdev = conf->mirrors[i].rdev; |
2066 | int vcnt, idx; | ||
2067 | struct bio_vec *vec; | ||
2068 | 2066 | ||
2069 | /* bio has the data to be written to device 'i' where | 2067 | /* bio has the data to be written to device 'i' where |
2070 | * we just recently had a write error. | 2068 | * we just recently had a write error. |
@@ -2092,30 +2090,32 @@ static int narrow_write_error(struct r1bio *r1_bio, int i) | |||
2092 | & ~(sector_t)(block_sectors - 1)) | 2090 | & ~(sector_t)(block_sectors - 1)) |
2093 | - sector; | 2091 | - sector; |
2094 | 2092 | ||
2095 | if (test_bit(R1BIO_BehindIO, &r1_bio->state)) { | ||
2096 | vcnt = r1_bio->behind_page_count; | ||
2097 | vec = r1_bio->behind_bvecs; | ||
2098 | idx = 0; | ||
2099 | while (vec[idx].bv_page == NULL) | ||
2100 | idx++; | ||
2101 | } else { | ||
2102 | vcnt = r1_bio->master_bio->bi_vcnt; | ||
2103 | vec = r1_bio->master_bio->bi_io_vec; | ||
2104 | idx = r1_bio->master_bio->bi_idx; | ||
2105 | } | ||
2106 | while (sect_to_write) { | 2093 | while (sect_to_write) { |
2107 | struct bio *wbio; | 2094 | struct bio *wbio; |
2108 | if (sectors > sect_to_write) | 2095 | if (sectors > sect_to_write) |
2109 | sectors = sect_to_write; | 2096 | sectors = sect_to_write; |
2110 | /* Write at 'sector' for 'sectors'*/ | 2097 | /* Write at 'sector' for 'sectors'*/ |
2111 | 2098 | ||
2112 | wbio = bio_alloc_mddev(GFP_NOIO, vcnt, mddev); | 2099 | if (test_bit(R1BIO_BehindIO, &r1_bio->state)) { |
2113 | memcpy(wbio->bi_io_vec, vec, vcnt * sizeof(struct bio_vec)); | 2100 | unsigned vcnt = r1_bio->behind_page_count; |
2114 | wbio->bi_sector = r1_bio->sector; | 2101 | struct bio_vec *vec = r1_bio->behind_bvecs; |
2102 | |||
2103 | while (!vec->bv_page) { | ||
2104 | vec++; | ||
2105 | vcnt--; | ||
2106 | } | ||
2107 | |||
2108 | wbio = bio_alloc_mddev(GFP_NOIO, vcnt, mddev); | ||
2109 | memcpy(wbio->bi_io_vec, vec, vcnt * sizeof(struct bio_vec)); | ||
2110 | |||
2111 | wbio->bi_vcnt = vcnt; | ||
2112 | } else { | ||
2113 | wbio = bio_clone_mddev(r1_bio->master_bio, GFP_NOIO, mddev); | ||
2114 | } | ||
2115 | |||
2115 | wbio->bi_rw = WRITE; | 2116 | wbio->bi_rw = WRITE; |
2116 | wbio->bi_vcnt = vcnt; | 2117 | wbio->bi_sector = r1_bio->sector; |
2117 | wbio->bi_size = r1_bio->sectors << 9; | 2118 | wbio->bi_size = r1_bio->sectors << 9; |
2118 | wbio->bi_idx = idx; | ||
2119 | 2119 | ||
2120 | md_trim_bio(wbio, sector - r1_bio->sector, sectors); | 2120 | md_trim_bio(wbio, sector - r1_bio->sector, sectors); |
2121 | wbio->bi_sector += rdev->data_offset; | 2121 | wbio->bi_sector += rdev->data_offset; |