Skip to content

Commit 4b8b8a4

Browse files
committed
Merge tag 'md-3.11-fixes' of git://neil.brown.name/md
Pull md bug fixes from NeilBrown: "Sorry boss, back at work now boss. Here's them nice shiny patches ya wanted. All nicely tagged and justified for -stable and everyfing: Three bug fixes for md in 3.10 3.10 wasn't a good release for md. The bio changes left a couple of bugs, and an md "fix" created another one. These three patches appear to fix the issues and have been tagged for -stable" * tag 'md-3.11-fixes' of git://neil.brown.name/md: md/raid1: fix bio handling problems in process_checks() md: Remove recent change which allows devices to skip recovery. md/raid10: fix two problems with RAID10 resync.
2 parents 0a693ab + 30bc9b5 commit 4b8b8a4

File tree

3 files changed

+39
-39
lines changed

3 files changed

+39
-39
lines changed

drivers/md/md.c

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -7716,20 +7716,6 @@ static int remove_and_add_spares(struct mddev *mddev,
77167716
continue;
77177717

77187718
rdev->recovery_offset = 0;
7719-
if (rdev->saved_raid_disk >= 0 && mddev->in_sync) {
7720-
spin_lock_irq(&mddev->write_lock);
7721-
if (mddev->in_sync)
7722-
/* OK, this device, which is in_sync,
7723-
* will definitely be noticed before
7724-
* the next write, so recovery isn't
7725-
* needed.
7726-
*/
7727-
rdev->recovery_offset = mddev->recovery_cp;
7728-
spin_unlock_irq(&mddev->write_lock);
7729-
}
7730-
if (mddev->ro && rdev->recovery_offset != MaxSector)
7731-
/* not safe to add this disk now */
7732-
continue;
77337719
if (mddev->pers->
77347720
hot_add_disk(mddev, rdev) == 0) {
77357721
if (sysfs_link_rdev(mddev, rdev))

drivers/md/raid1.c

Lines changed: 30 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1849,6 +1849,36 @@ static int process_checks(struct r1bio *r1_bio)
18491849
int i;
18501850
int vcnt;
18511851

1852+
/* Fix variable parts of all bios */
1853+
vcnt = (r1_bio->sectors + PAGE_SIZE / 512 - 1) >> (PAGE_SHIFT - 9);
1854+
for (i = 0; i < conf->raid_disks * 2; i++) {
1855+
int j;
1856+
int size;
1857+
struct bio *b = r1_bio->bios[i];
1858+
if (b->bi_end_io != end_sync_read)
1859+
continue;
1860+
/* fixup the bio for reuse */
1861+
bio_reset(b);
1862+
b->bi_vcnt = vcnt;
1863+
b->bi_size = r1_bio->sectors << 9;
1864+
b->bi_sector = r1_bio->sector +
1865+
conf->mirrors[i].rdev->data_offset;
1866+
b->bi_bdev = conf->mirrors[i].rdev->bdev;
1867+
b->bi_end_io = end_sync_read;
1868+
b->bi_private = r1_bio;
1869+
1870+
size = b->bi_size;
1871+
for (j = 0; j < vcnt ; j++) {
1872+
struct bio_vec *bi;
1873+
bi = &b->bi_io_vec[j];
1874+
bi->bv_offset = 0;
1875+
if (size > PAGE_SIZE)
1876+
bi->bv_len = PAGE_SIZE;
1877+
else
1878+
bi->bv_len = size;
1879+
size -= PAGE_SIZE;
1880+
}
1881+
}
18521882
for (primary = 0; primary < conf->raid_disks * 2; primary++)
18531883
if (r1_bio->bios[primary]->bi_end_io == end_sync_read &&
18541884
test_bit(BIO_UPTODATE, &r1_bio->bios[primary]->bi_flags)) {
@@ -1857,12 +1887,10 @@ static int process_checks(struct r1bio *r1_bio)
18571887
break;
18581888
}
18591889
r1_bio->read_disk = primary;
1860-
vcnt = (r1_bio->sectors + PAGE_SIZE / 512 - 1) >> (PAGE_SHIFT - 9);
18611890
for (i = 0; i < conf->raid_disks * 2; i++) {
18621891
int j;
18631892
struct bio *pbio = r1_bio->bios[primary];
18641893
struct bio *sbio = r1_bio->bios[i];
1865-
int size;
18661894

18671895
if (sbio->bi_end_io != end_sync_read)
18681896
continue;
@@ -1888,27 +1916,6 @@ static int process_checks(struct r1bio *r1_bio)
18881916
rdev_dec_pending(conf->mirrors[i].rdev, mddev);
18891917
continue;
18901918
}
1891-
/* fixup the bio for reuse */
1892-
bio_reset(sbio);
1893-
sbio->bi_vcnt = vcnt;
1894-
sbio->bi_size = r1_bio->sectors << 9;
1895-
sbio->bi_sector = r1_bio->sector +
1896-
conf->mirrors[i].rdev->data_offset;
1897-
sbio->bi_bdev = conf->mirrors[i].rdev->bdev;
1898-
sbio->bi_end_io = end_sync_read;
1899-
sbio->bi_private = r1_bio;
1900-
1901-
size = sbio->bi_size;
1902-
for (j = 0; j < vcnt ; j++) {
1903-
struct bio_vec *bi;
1904-
bi = &sbio->bi_io_vec[j];
1905-
bi->bv_offset = 0;
1906-
if (size > PAGE_SIZE)
1907-
bi->bv_len = PAGE_SIZE;
1908-
else
1909-
bi->bv_len = size;
1910-
size -= PAGE_SIZE;
1911-
}
19121919

19131920
bio_copy_data(sbio, pbio);
19141921
}

drivers/md/raid10.c

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2097,11 +2097,17 @@ static void sync_request_write(struct mddev *mddev, struct r10bio *r10_bio)
20972097
* both 'first' and 'i', so we just compare them.
20982098
* All vec entries are PAGE_SIZE;
20992099
*/
2100-
for (j = 0; j < vcnt; j++)
2100+
int sectors = r10_bio->sectors;
2101+
for (j = 0; j < vcnt; j++) {
2102+
int len = PAGE_SIZE;
2103+
if (sectors < (len / 512))
2104+
len = sectors * 512;
21012105
if (memcmp(page_address(fbio->bi_io_vec[j].bv_page),
21022106
page_address(tbio->bi_io_vec[j].bv_page),
2103-
fbio->bi_io_vec[j].bv_len))
2107+
len))
21042108
break;
2109+
sectors -= len/512;
2110+
}
21052111
if (j == vcnt)
21062112
continue;
21072113
atomic64_add(r10_bio->sectors, &mddev->resync_mismatches);
@@ -3407,6 +3413,7 @@ static sector_t sync_request(struct mddev *mddev, sector_t sector_nr,
34073413

34083414
if (bio->bi_end_io == end_sync_read) {
34093415
md_sync_acct(bio->bi_bdev, nr_sectors);
3416+
set_bit(BIO_UPTODATE, &bio->bi_flags);
34103417
generic_make_request(bio);
34113418
}
34123419
}

0 commit comments

Comments
 (0)