aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorNeilBrown <neilb@suse.de>2006-01-06 03:20:14 -0500
committerLinus Torvalds <torvalds@g5.osdl.org>2006-01-06 11:34:02 -0500
commit14f8d26b8ea3413b28f2cac208c9a93600fe3a80 (patch)
treec52409db0f8c457683add609367976dfef645b8f /drivers
parent0a27ec96b6fb1abf867e36d7b0b681d67588767a (diff)
[PATCH] md: small cleanups for raid5
Resync code: A test that isn't needed, a 'compute_block' that makes more sense elsewhere (And then doesn't need a test), a couple of BUG_ONs to confirm the change makes sense. Printks: A few were missing KERN_* Also fix a typo in a comment.. Signed-off-by: Neil Brown <neilb@suse.de> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/md/raid5.c41
1 files changed, 21 insertions, 20 deletions
diff --git a/drivers/md/raid5.c b/drivers/md/raid5.c
index fafc4bc045f7..334ff7a07283 100644
--- a/drivers/md/raid5.c
+++ b/drivers/md/raid5.c
@@ -417,7 +417,7 @@ static int raid5_end_read_request(struct bio * bi, unsigned int bytes_done,
417 set_bit(R5_UPTODATE, &sh->dev[i].flags); 417 set_bit(R5_UPTODATE, &sh->dev[i].flags);
418#endif 418#endif
419 if (test_bit(R5_ReadError, &sh->dev[i].flags)) { 419 if (test_bit(R5_ReadError, &sh->dev[i].flags)) {
420 printk("R5: read error corrected!!\n"); 420 printk(KERN_INFO "raid5: read error corrected!!\n");
421 clear_bit(R5_ReadError, &sh->dev[i].flags); 421 clear_bit(R5_ReadError, &sh->dev[i].flags);
422 clear_bit(R5_ReWrite, &sh->dev[i].flags); 422 clear_bit(R5_ReWrite, &sh->dev[i].flags);
423 } 423 }
@@ -428,13 +428,14 @@ static int raid5_end_read_request(struct bio * bi, unsigned int bytes_done,
428 clear_bit(R5_UPTODATE, &sh->dev[i].flags); 428 clear_bit(R5_UPTODATE, &sh->dev[i].flags);
429 atomic_inc(&conf->disks[i].rdev->read_errors); 429 atomic_inc(&conf->disks[i].rdev->read_errors);
430 if (conf->mddev->degraded) 430 if (conf->mddev->degraded)
431 printk("R5: read error not correctable.\n"); 431 printk(KERN_WARNING "raid5: read error not correctable.\n");
432 else if (test_bit(R5_ReWrite, &sh->dev[i].flags)) 432 else if (test_bit(R5_ReWrite, &sh->dev[i].flags))
433 /* Oh, no!!! */ 433 /* Oh, no!!! */
434 printk("R5: read error NOT corrected!!\n"); 434 printk(KERN_WARNING "raid5: read error NOT corrected!!\n");
435 else if (atomic_read(&conf->disks[i].rdev->read_errors) 435 else if (atomic_read(&conf->disks[i].rdev->read_errors)
436 > conf->max_nr_stripes) 436 > conf->max_nr_stripes)
437 printk("raid5: Too many read errors, failing device.\n"); 437 printk(KERN_WARNING
438 "raid5: Too many read errors, failing device.\n");
438 else 439 else
439 retry = 1; 440 retry = 1;
440 if (retry) 441 if (retry)
@@ -604,7 +605,7 @@ static sector_t raid5_compute_sector(sector_t r_sector, unsigned int raid_disks,
604 *dd_idx = (*pd_idx + 1 + *dd_idx) % raid_disks; 605 *dd_idx = (*pd_idx + 1 + *dd_idx) % raid_disks;
605 break; 606 break;
606 default: 607 default:
607 printk("raid5: unsupported algorithm %d\n", 608 printk(KERN_ERR "raid5: unsupported algorithm %d\n",
608 conf->algorithm); 609 conf->algorithm);
609 } 610 }
610 611
@@ -645,7 +646,7 @@ static sector_t compute_blocknr(struct stripe_head *sh, int i)
645 i -= (sh->pd_idx + 1); 646 i -= (sh->pd_idx + 1);
646 break; 647 break;
647 default: 648 default:
648 printk("raid5: unsupported algorithm %d\n", 649 printk(KERN_ERR "raid5: unsupported algorithm %d\n",
649 conf->algorithm); 650 conf->algorithm);
650 } 651 }
651 652
@@ -654,7 +655,7 @@ static sector_t compute_blocknr(struct stripe_head *sh, int i)
654 655
655 check = raid5_compute_sector (r_sector, raid_disks, data_disks, &dummy1, &dummy2, conf); 656 check = raid5_compute_sector (r_sector, raid_disks, data_disks, &dummy1, &dummy2, conf);
656 if (check != sh->sector || dummy1 != dd_idx || dummy2 != sh->pd_idx) { 657 if (check != sh->sector || dummy1 != dd_idx || dummy2 != sh->pd_idx) {
657 printk("compute_blocknr: map not correct\n"); 658 printk(KERN_ERR "compute_blocknr: map not correct\n");
658 return 0; 659 return 0;
659 } 660 }
660 return r_sector; 661 return r_sector;
@@ -737,7 +738,7 @@ static void compute_block(struct stripe_head *sh, int dd_idx)
737 if (test_bit(R5_UPTODATE, &sh->dev[i].flags)) 738 if (test_bit(R5_UPTODATE, &sh->dev[i].flags))
738 ptr[count++] = p; 739 ptr[count++] = p;
739 else 740 else
740 printk("compute_block() %d, stripe %llu, %d" 741 printk(KERN_ERR "compute_block() %d, stripe %llu, %d"
741 " not present\n", dd_idx, 742 " not present\n", dd_idx,
742 (unsigned long long)sh->sector, i); 743 (unsigned long long)sh->sector, i);
743 744
@@ -1005,7 +1006,7 @@ static void handle_stripe(struct stripe_head *sh)
1005 if (dev->written) written++; 1006 if (dev->written) written++;
1006 rdev = conf->disks[i].rdev; /* FIXME, should I be looking rdev */ 1007 rdev = conf->disks[i].rdev; /* FIXME, should I be looking rdev */
1007 if (!rdev || !test_bit(In_sync, &rdev->flags)) { 1008 if (!rdev || !test_bit(In_sync, &rdev->flags)) {
1008 /* The ReadError flag wil just be confusing now */ 1009 /* The ReadError flag will just be confusing now */
1009 clear_bit(R5_ReadError, &dev->flags); 1010 clear_bit(R5_ReadError, &dev->flags);
1010 clear_bit(R5_ReWrite, &dev->flags); 1011 clear_bit(R5_ReWrite, &dev->flags);
1011 } 1012 }
@@ -1288,7 +1289,7 @@ static void handle_stripe(struct stripe_head *sh)
1288 * is available 1289 * is available
1289 */ 1290 */
1290 if (syncing && locked == 0 && 1291 if (syncing && locked == 0 &&
1291 !test_bit(STRIPE_INSYNC, &sh->state) && failed <= 1) { 1292 !test_bit(STRIPE_INSYNC, &sh->state)) {
1292 set_bit(STRIPE_HANDLE, &sh->state); 1293 set_bit(STRIPE_HANDLE, &sh->state);
1293 if (failed == 0) { 1294 if (failed == 0) {
1294 char *pagea; 1295 char *pagea;
@@ -1306,21 +1307,20 @@ static void handle_stripe(struct stripe_head *sh)
1306 if (test_bit(MD_RECOVERY_CHECK, &conf->mddev->recovery)) 1307 if (test_bit(MD_RECOVERY_CHECK, &conf->mddev->recovery))
1307 /* don't try to repair!! */ 1308 /* don't try to repair!! */
1308 set_bit(STRIPE_INSYNC, &sh->state); 1309 set_bit(STRIPE_INSYNC, &sh->state);
1310 else {
1311 compute_block(sh, sh->pd_idx);
1312 uptodate++;
1313 }
1309 } 1314 }
1310 } 1315 }
1311 if (!test_bit(STRIPE_INSYNC, &sh->state)) { 1316 if (!test_bit(STRIPE_INSYNC, &sh->state)) {
1317 /* either failed parity check, or recovery is happening */
1312 if (failed==0) 1318 if (failed==0)
1313 failed_num = sh->pd_idx; 1319 failed_num = sh->pd_idx;
1314 /* should be able to compute the missing block and write it to spare */
1315 if (!test_bit(R5_UPTODATE, &sh->dev[failed_num].flags)) {
1316 if (uptodate+1 != disks)
1317 BUG();
1318 compute_block(sh, failed_num);
1319 uptodate++;
1320 }
1321 if (uptodate != disks)
1322 BUG();
1323 dev = &sh->dev[failed_num]; 1320 dev = &sh->dev[failed_num];
1321 BUG_ON(!test_bit(R5_UPTODATE, &dev->flags));
1322 BUG_ON(uptodate != disks);
1323
1324 set_bit(R5_LOCKED, &dev->flags); 1324 set_bit(R5_LOCKED, &dev->flags);
1325 set_bit(R5_Wantwrite, &dev->flags); 1325 set_bit(R5_Wantwrite, &dev->flags);
1326 clear_bit(STRIPE_DEGRADED, &sh->state); 1326 clear_bit(STRIPE_DEGRADED, &sh->state);
@@ -1822,7 +1822,8 @@ static int run(mddev_t *mddev)
1822 struct list_head *tmp; 1822 struct list_head *tmp;
1823 1823
1824 if (mddev->level != 5 && mddev->level != 4) { 1824 if (mddev->level != 5 && mddev->level != 4) {
1825 printk("raid5: %s: raid level not set to 4/5 (%d)\n", mdname(mddev), mddev->level); 1825 printk(KERN_ERR "raid5: %s: raid level not set to 4/5 (%d)\n",
1826 mdname(mddev), mddev->level);
1826 return -EIO; 1827 return -EIO;
1827 } 1828 }
1828 1829