aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNeilBrown <neilb@suse.de>2006-01-06 03:20:46 -0500
committerLinus Torvalds <torvalds@g5.osdl.org>2006-01-06 11:34:08 -0500
commit03c902e17f40cfed63cd2494616f35fc9c58571b (patch)
treebfa65142a20a9b424dbd078149cecaa0177086fb
parentc708443c004f2310abdd7f1c353daa372b37f7a2 (diff)
[PATCH] md: fix rdev->pending counts in raid1
When we do a user-requested check/repair, we lose count of the outstanding requests... Also make sure that when anything is written to md/sync_action, the RECOVERY_NEEDED flag is set and the thread is woken up so any changes take effect. Signed-off-by: Neil Brown <neilb@suse.de> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
-rw-r--r--drivers/md/md.c11
-rw-r--r--drivers/md/raid1.c10
2 files changed, 10 insertions, 11 deletions
diff --git a/drivers/md/md.c b/drivers/md/md.c
index 241d514343ce..0b3081aa4d63 100644
--- a/drivers/md/md.c
+++ b/drivers/md/md.c
@@ -1826,13 +1826,10 @@ action_store(mddev_t *mddev, const char *page, size_t len)
1826 mddev->sync_thread = NULL; 1826 mddev->sync_thread = NULL;
1827 mddev->recovery = 0; 1827 mddev->recovery = 0;
1828 } 1828 }
1829 return len; 1829 } else if (test_bit(MD_RECOVERY_RUNNING, &mddev->recovery) ||
1830 } 1830 test_bit(MD_RECOVERY_NEEDED, &mddev->recovery))
1831
1832 if (test_bit(MD_RECOVERY_RUNNING, &mddev->recovery) ||
1833 test_bit(MD_RECOVERY_NEEDED, &mddev->recovery))
1834 return -EBUSY; 1831 return -EBUSY;
1835 if (cmd_match(page, "resync") || cmd_match(page, "recover")) 1832 else if (cmd_match(page, "resync") || cmd_match(page, "recover"))
1836 set_bit(MD_RECOVERY_NEEDED, &mddev->recovery); 1833 set_bit(MD_RECOVERY_NEEDED, &mddev->recovery);
1837 else { 1834 else {
1838 if (cmd_match(page, "check")) 1835 if (cmd_match(page, "check"))
@@ -1841,8 +1838,8 @@ action_store(mddev_t *mddev, const char *page, size_t len)
1841 return -EINVAL; 1838 return -EINVAL;
1842 set_bit(MD_RECOVERY_REQUESTED, &mddev->recovery); 1839 set_bit(MD_RECOVERY_REQUESTED, &mddev->recovery);
1843 set_bit(MD_RECOVERY_SYNC, &mddev->recovery); 1840 set_bit(MD_RECOVERY_SYNC, &mddev->recovery);
1844 set_bit(MD_RECOVERY_NEEDED, &mddev->recovery);
1845 } 1841 }
1842 set_bit(MD_RECOVERY_NEEDED, &mddev->recovery);
1846 md_wakeup_thread(mddev->thread); 1843 md_wakeup_thread(mddev->thread);
1847 return len; 1844 return len;
1848} 1845}
diff --git a/drivers/md/raid1.c b/drivers/md/raid1.c
index feea4eeca1d9..7d4465f93064 100644
--- a/drivers/md/raid1.c
+++ b/drivers/md/raid1.c
@@ -527,7 +527,7 @@ static int read_balance(conf_t *conf, r1bio_t *r1_bio)
527 /* cannot risk returning a device that failed 527 /* cannot risk returning a device that failed
528 * before we inc'ed nr_pending 528 * before we inc'ed nr_pending
529 */ 529 */
530 atomic_dec(&rdev->nr_pending); 530 rdev_dec_pending(rdev, conf->mddev);
531 goto retry; 531 goto retry;
532 } 532 }
533 conf->next_seq_sect = this_sector + sectors; 533 conf->next_seq_sect = this_sector + sectors;
@@ -830,7 +830,7 @@ static int make_request(request_queue_t *q, struct bio * bio)
830 !test_bit(Faulty, &rdev->flags)) { 830 !test_bit(Faulty, &rdev->flags)) {
831 atomic_inc(&rdev->nr_pending); 831 atomic_inc(&rdev->nr_pending);
832 if (test_bit(Faulty, &rdev->flags)) { 832 if (test_bit(Faulty, &rdev->flags)) {
833 atomic_dec(&rdev->nr_pending); 833 rdev_dec_pending(rdev, mddev);
834 r1_bio->bios[i] = NULL; 834 r1_bio->bios[i] = NULL;
835 } else 835 } else
836 r1_bio->bios[i] = bio; 836 r1_bio->bios[i] = bio;
@@ -1176,6 +1176,7 @@ static void sync_request_write(mddev_t *mddev, r1bio_t *r1_bio)
1176 if (r1_bio->bios[primary]->bi_end_io == end_sync_read && 1176 if (r1_bio->bios[primary]->bi_end_io == end_sync_read &&
1177 test_bit(BIO_UPTODATE, &r1_bio->bios[primary]->bi_flags)) { 1177 test_bit(BIO_UPTODATE, &r1_bio->bios[primary]->bi_flags)) {
1178 r1_bio->bios[primary]->bi_end_io = NULL; 1178 r1_bio->bios[primary]->bi_end_io = NULL;
1179 rdev_dec_pending(conf->mirrors[primary].rdev, mddev);
1179 break; 1180 break;
1180 } 1181 }
1181 r1_bio->read_disk = primary; 1182 r1_bio->read_disk = primary;
@@ -1193,9 +1194,10 @@ static void sync_request_write(mddev_t *mddev, r1bio_t *r1_bio)
1193 break; 1194 break;
1194 if (j >= 0) 1195 if (j >= 0)
1195 mddev->resync_mismatches += r1_bio->sectors; 1196 mddev->resync_mismatches += r1_bio->sectors;
1196 if (j < 0 || test_bit(MD_RECOVERY_CHECK, &mddev->recovery)) 1197 if (j < 0 || test_bit(MD_RECOVERY_CHECK, &mddev->recovery)) {
1197 sbio->bi_end_io = NULL; 1198 sbio->bi_end_io = NULL;
1198 else { 1199 rdev_dec_pending(conf->mirrors[i].rdev, mddev);
1200 } else {
1199 /* fixup the bio for reuse */ 1201 /* fixup the bio for reuse */
1200 sbio->bi_vcnt = vcnt; 1202 sbio->bi_vcnt = vcnt;
1201 sbio->bi_size = r1_bio->sectors << 9; 1203 sbio->bi_size = r1_bio->sectors << 9;