aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/md
diff options
context:
space:
mode:
authormajianpeng <majianpeng@gmail.com>2012-04-12 02:04:47 -0400
committerNeilBrown <neilb@suse.de>2012-04-12 02:04:47 -0400
commitf4380a915823dbed0bf8e3cf502ebcf2b7c7f833 (patch)
tree1326179e1f715f33495066b2fe4b99acf1bbdd96 /drivers/md
parent9e41dd35b39c2cf40767332b8f914d7afe25cc40 (diff)
md/raid1,raid10: Fix calculation of 'vcnt' when processing error recovery.
If r1bio->sectors % 8 != 0,then the memcmp and a later memcpy will omit the last bio_vec. This is suitable for any stable kernel since 3.1 when bad-block management was introduced. Cc: stable@vger.kernel.org Signed-off-by: majianpeng <majianpeng@gmail.com> Signed-off-by: NeilBrown <neilb@suse.de>
Diffstat (limited to 'drivers/md')
-rw-r--r--drivers/md/raid1.c3
-rw-r--r--drivers/md/raid10.c4
2 files changed, 4 insertions, 3 deletions
diff --git a/drivers/md/raid1.c b/drivers/md/raid1.c
index d35e4c991e38..15dd59b84e94 100644
--- a/drivers/md/raid1.c
+++ b/drivers/md/raid1.c
@@ -1712,6 +1712,7 @@ static int process_checks(struct r1bio *r1_bio)
1712 struct r1conf *conf = mddev->private; 1712 struct r1conf *conf = mddev->private;
1713 int primary; 1713 int primary;
1714 int i; 1714 int i;
1715 int vcnt;
1715 1716
1716 for (primary = 0; primary < conf->raid_disks * 2; primary++) 1717 for (primary = 0; primary < conf->raid_disks * 2; primary++)
1717 if (r1_bio->bios[primary]->bi_end_io == end_sync_read && 1718 if (r1_bio->bios[primary]->bi_end_io == end_sync_read &&
@@ -1721,9 +1722,9 @@ static int process_checks(struct r1bio *r1_bio)
1721 break; 1722 break;
1722 } 1723 }
1723 r1_bio->read_disk = primary; 1724 r1_bio->read_disk = primary;
1725 vcnt = (r1_bio->sectors + PAGE_SIZE / 512 - 1) >> (PAGE_SHIFT - 9);
1724 for (i = 0; i < conf->raid_disks * 2; i++) { 1726 for (i = 0; i < conf->raid_disks * 2; i++) {
1725 int j; 1727 int j;
1726 int vcnt = r1_bio->sectors >> (PAGE_SHIFT- 9);
1727 struct bio *pbio = r1_bio->bios[primary]; 1728 struct bio *pbio = r1_bio->bios[primary];
1728 struct bio *sbio = r1_bio->bios[i]; 1729 struct bio *sbio = r1_bio->bios[i];
1729 int size; 1730 int size;
diff --git a/drivers/md/raid10.c b/drivers/md/raid10.c
index fff782189e48..c8dbb84d5357 100644
--- a/drivers/md/raid10.c
+++ b/drivers/md/raid10.c
@@ -1788,6 +1788,7 @@ static void sync_request_write(struct mddev *mddev, struct r10bio *r10_bio)
1788 struct r10conf *conf = mddev->private; 1788 struct r10conf *conf = mddev->private;
1789 int i, first; 1789 int i, first;
1790 struct bio *tbio, *fbio; 1790 struct bio *tbio, *fbio;
1791 int vcnt;
1791 1792
1792 atomic_set(&r10_bio->remaining, 1); 1793 atomic_set(&r10_bio->remaining, 1);
1793 1794
@@ -1802,10 +1803,10 @@ static void sync_request_write(struct mddev *mddev, struct r10bio *r10_bio)
1802 first = i; 1803 first = i;
1803 fbio = r10_bio->devs[i].bio; 1804 fbio = r10_bio->devs[i].bio;
1804 1805
1806 vcnt = (r10_bio->sectors + (PAGE_SIZE >> 9) - 1) >> (PAGE_SHIFT - 9);
1805 /* now find blocks with errors */ 1807 /* now find blocks with errors */
1806 for (i=0 ; i < conf->copies ; i++) { 1808 for (i=0 ; i < conf->copies ; i++) {
1807 int j, d; 1809 int j, d;
1808 int vcnt = r10_bio->sectors >> (PAGE_SHIFT-9);
1809 1810
1810 tbio = r10_bio->devs[i].bio; 1811 tbio = r10_bio->devs[i].bio;
1811 1812
@@ -1871,7 +1872,6 @@ static void sync_request_write(struct mddev *mddev, struct r10bio *r10_bio)
1871 */ 1872 */
1872 for (i = 0; i < conf->copies; i++) { 1873 for (i = 0; i < conf->copies; i++) {
1873 int j, d; 1874 int j, d;
1874 int vcnt = r10_bio->sectors >> (PAGE_SHIFT-9);
1875 1875
1876 tbio = r10_bio->devs[i].repl_bio; 1876 tbio = r10_bio->devs[i].repl_bio;
1877 if (!tbio || !tbio->bi_end_io) 1877 if (!tbio || !tbio->bi_end_io)