aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/md/md.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/md/md.c')
-rw-r--r--drivers/md/md.c92
1 files changed, 45 insertions, 47 deletions
diff --git a/drivers/md/md.c b/drivers/md/md.c
index 3fb80397f8aa..9dfa063d1c6a 100644
--- a/drivers/md/md.c
+++ b/drivers/md/md.c
@@ -610,7 +610,7 @@ static int super_90_validate(mddev_t *mddev, mdk_rdev_t *rdev)
610 mdp_super_t *sb = (mdp_super_t *)page_address(rdev->sb_page); 610 mdp_super_t *sb = (mdp_super_t *)page_address(rdev->sb_page);
611 611
612 rdev->raid_disk = -1; 612 rdev->raid_disk = -1;
613 rdev->in_sync = 0; 613 rdev->flags = 0;
614 if (mddev->raid_disks == 0) { 614 if (mddev->raid_disks == 0) {
615 mddev->major_version = 0; 615 mddev->major_version = 0;
616 mddev->minor_version = sb->minor_version; 616 mddev->minor_version = sb->minor_version;
@@ -671,21 +671,19 @@ static int super_90_validate(mddev_t *mddev, mdk_rdev_t *rdev)
671 return 0; 671 return 0;
672 672
673 if (mddev->level != LEVEL_MULTIPATH) { 673 if (mddev->level != LEVEL_MULTIPATH) {
674 rdev->faulty = 0;
675 rdev->flags = 0;
676 desc = sb->disks + rdev->desc_nr; 674 desc = sb->disks + rdev->desc_nr;
677 675
678 if (desc->state & (1<<MD_DISK_FAULTY)) 676 if (desc->state & (1<<MD_DISK_FAULTY))
679 rdev->faulty = 1; 677 set_bit(Faulty, &rdev->flags);
680 else if (desc->state & (1<<MD_DISK_SYNC) && 678 else if (desc->state & (1<<MD_DISK_SYNC) &&
681 desc->raid_disk < mddev->raid_disks) { 679 desc->raid_disk < mddev->raid_disks) {
682 rdev->in_sync = 1; 680 set_bit(In_sync, &rdev->flags);
683 rdev->raid_disk = desc->raid_disk; 681 rdev->raid_disk = desc->raid_disk;
684 } 682 }
685 if (desc->state & (1<<MD_DISK_WRITEMOSTLY)) 683 if (desc->state & (1<<MD_DISK_WRITEMOSTLY))
686 set_bit(WriteMostly, &rdev->flags); 684 set_bit(WriteMostly, &rdev->flags);
687 } else /* MULTIPATH are always insync */ 685 } else /* MULTIPATH are always insync */
688 rdev->in_sync = 1; 686 set_bit(In_sync, &rdev->flags);
689 return 0; 687 return 0;
690} 688}
691 689
@@ -761,7 +759,8 @@ static void super_90_sync(mddev_t *mddev, mdk_rdev_t *rdev)
761 ITERATE_RDEV(mddev,rdev2,tmp) { 759 ITERATE_RDEV(mddev,rdev2,tmp) {
762 mdp_disk_t *d; 760 mdp_disk_t *d;
763 int desc_nr; 761 int desc_nr;
764 if (rdev2->raid_disk >= 0 && rdev2->in_sync && !rdev2->faulty) 762 if (rdev2->raid_disk >= 0 && test_bit(In_sync, &rdev2->flags)
763 && !test_bit(Faulty, &rdev2->flags))
765 desc_nr = rdev2->raid_disk; 764 desc_nr = rdev2->raid_disk;
766 else 765 else
767 desc_nr = next_spare++; 766 desc_nr = next_spare++;
@@ -780,14 +779,15 @@ static void super_90_sync(mddev_t *mddev, mdk_rdev_t *rdev)
780 d->number = rdev2->desc_nr; 779 d->number = rdev2->desc_nr;
781 d->major = MAJOR(rdev2->bdev->bd_dev); 780 d->major = MAJOR(rdev2->bdev->bd_dev);
782 d->minor = MINOR(rdev2->bdev->bd_dev); 781 d->minor = MINOR(rdev2->bdev->bd_dev);
783 if (rdev2->raid_disk >= 0 && rdev2->in_sync && !rdev2->faulty) 782 if (rdev2->raid_disk >= 0 && test_bit(In_sync, &rdev2->flags)
783 && !test_bit(Faulty, &rdev2->flags))
784 d->raid_disk = rdev2->raid_disk; 784 d->raid_disk = rdev2->raid_disk;
785 else 785 else
786 d->raid_disk = rdev2->desc_nr; /* compatibility */ 786 d->raid_disk = rdev2->desc_nr; /* compatibility */
787 if (rdev2->faulty) { 787 if (test_bit(Faulty, &rdev2->flags)) {
788 d->state = (1<<MD_DISK_FAULTY); 788 d->state = (1<<MD_DISK_FAULTY);
789 failed++; 789 failed++;
790 } else if (rdev2->in_sync) { 790 } else if (test_bit(In_sync, &rdev2->flags)) {
791 d->state = (1<<MD_DISK_ACTIVE); 791 d->state = (1<<MD_DISK_ACTIVE);
792 d->state |= (1<<MD_DISK_SYNC); 792 d->state |= (1<<MD_DISK_SYNC);
793 active++; 793 active++;
@@ -975,7 +975,7 @@ static int super_1_validate(mddev_t *mddev, mdk_rdev_t *rdev)
975 struct mdp_superblock_1 *sb = (struct mdp_superblock_1*)page_address(rdev->sb_page); 975 struct mdp_superblock_1 *sb = (struct mdp_superblock_1*)page_address(rdev->sb_page);
976 976
977 rdev->raid_disk = -1; 977 rdev->raid_disk = -1;
978 rdev->in_sync = 0; 978 rdev->flags = 0;
979 if (mddev->raid_disks == 0) { 979 if (mddev->raid_disks == 0) {
980 mddev->major_version = 1; 980 mddev->major_version = 1;
981 mddev->patch_version = 0; 981 mddev->patch_version = 0;
@@ -1027,22 +1027,19 @@ static int super_1_validate(mddev_t *mddev, mdk_rdev_t *rdev)
1027 role = le16_to_cpu(sb->dev_roles[rdev->desc_nr]); 1027 role = le16_to_cpu(sb->dev_roles[rdev->desc_nr]);
1028 switch(role) { 1028 switch(role) {
1029 case 0xffff: /* spare */ 1029 case 0xffff: /* spare */
1030 rdev->faulty = 0;
1031 break; 1030 break;
1032 case 0xfffe: /* faulty */ 1031 case 0xfffe: /* faulty */
1033 rdev->faulty = 1; 1032 set_bit(Faulty, &rdev->flags);
1034 break; 1033 break;
1035 default: 1034 default:
1036 rdev->in_sync = 1; 1035 set_bit(In_sync, &rdev->flags);
1037 rdev->faulty = 0;
1038 rdev->raid_disk = role; 1036 rdev->raid_disk = role;
1039 break; 1037 break;
1040 } 1038 }
1041 rdev->flags = 0;
1042 if (sb->devflags & WriteMostly1) 1039 if (sb->devflags & WriteMostly1)
1043 set_bit(WriteMostly, &rdev->flags); 1040 set_bit(WriteMostly, &rdev->flags);
1044 } else /* MULTIPATH are always insync */ 1041 } else /* MULTIPATH are always insync */
1045 rdev->in_sync = 1; 1042 set_bit(In_sync, &rdev->flags);
1046 1043
1047 return 0; 1044 return 0;
1048} 1045}
@@ -1086,9 +1083,9 @@ static void super_1_sync(mddev_t *mddev, mdk_rdev_t *rdev)
1086 1083
1087 ITERATE_RDEV(mddev,rdev2,tmp) { 1084 ITERATE_RDEV(mddev,rdev2,tmp) {
1088 i = rdev2->desc_nr; 1085 i = rdev2->desc_nr;
1089 if (rdev2->faulty) 1086 if (test_bit(Faulty, &rdev2->flags))
1090 sb->dev_roles[i] = cpu_to_le16(0xfffe); 1087 sb->dev_roles[i] = cpu_to_le16(0xfffe);
1091 else if (rdev2->in_sync) 1088 else if (test_bit(In_sync, &rdev2->flags))
1092 sb->dev_roles[i] = cpu_to_le16(rdev2->raid_disk); 1089 sb->dev_roles[i] = cpu_to_le16(rdev2->raid_disk);
1093 else 1090 else
1094 sb->dev_roles[i] = cpu_to_le16(0xffff); 1091 sb->dev_roles[i] = cpu_to_le16(0xffff);
@@ -1327,7 +1324,8 @@ static void print_rdev(mdk_rdev_t *rdev)
1327 char b[BDEVNAME_SIZE]; 1324 char b[BDEVNAME_SIZE];
1328 printk(KERN_INFO "md: rdev %s, SZ:%08llu F:%d S:%d DN:%u\n", 1325 printk(KERN_INFO "md: rdev %s, SZ:%08llu F:%d S:%d DN:%u\n",
1329 bdevname(rdev->bdev,b), (unsigned long long)rdev->size, 1326 bdevname(rdev->bdev,b), (unsigned long long)rdev->size,
1330 rdev->faulty, rdev->in_sync, rdev->desc_nr); 1327 test_bit(Faulty, &rdev->flags), test_bit(In_sync, &rdev->flags),
1328 rdev->desc_nr);
1331 if (rdev->sb_loaded) { 1329 if (rdev->sb_loaded) {
1332 printk(KERN_INFO "md: rdev superblock:\n"); 1330 printk(KERN_INFO "md: rdev superblock:\n");
1333 print_sb((mdp_super_t*)page_address(rdev->sb_page)); 1331 print_sb((mdp_super_t*)page_address(rdev->sb_page));
@@ -1421,11 +1419,11 @@ repeat:
1421 ITERATE_RDEV(mddev,rdev,tmp) { 1419 ITERATE_RDEV(mddev,rdev,tmp) {
1422 char b[BDEVNAME_SIZE]; 1420 char b[BDEVNAME_SIZE];
1423 dprintk(KERN_INFO "md: "); 1421 dprintk(KERN_INFO "md: ");
1424 if (rdev->faulty) 1422 if (test_bit(Faulty, &rdev->flags))
1425 dprintk("(skipping faulty "); 1423 dprintk("(skipping faulty ");
1426 1424
1427 dprintk("%s ", bdevname(rdev->bdev,b)); 1425 dprintk("%s ", bdevname(rdev->bdev,b));
1428 if (!rdev->faulty) { 1426 if (!test_bit(Faulty, &rdev->flags)) {
1429 md_super_write(mddev,rdev, 1427 md_super_write(mddev,rdev,
1430 rdev->sb_offset<<1, rdev->sb_size, 1428 rdev->sb_offset<<1, rdev->sb_size,
1431 rdev->sb_page); 1429 rdev->sb_page);
@@ -1466,15 +1464,16 @@ rdev_show_state(mdk_rdev_t *rdev, char *page)
1466 char *sep = ""; 1464 char *sep = "";
1467 int len=0; 1465 int len=0;
1468 1466
1469 if (rdev->faulty) { 1467 if (test_bit(Faulty, &rdev->flags)) {
1470 len+= sprintf(page+len, "%sfaulty",sep); 1468 len+= sprintf(page+len, "%sfaulty",sep);
1471 sep = ","; 1469 sep = ",";
1472 } 1470 }
1473 if (rdev->in_sync) { 1471 if (test_bit(In_sync, &rdev->flags)) {
1474 len += sprintf(page+len, "%sin_sync",sep); 1472 len += sprintf(page+len, "%sin_sync",sep);
1475 sep = ","; 1473 sep = ",";
1476 } 1474 }
1477 if (!rdev->faulty && !rdev->in_sync) { 1475 if (!test_bit(Faulty, &rdev->flags) &&
1476 !test_bit(In_sync, &rdev->flags)) {
1478 len += sprintf(page+len, "%sspare", sep); 1477 len += sprintf(page+len, "%sspare", sep);
1479 sep = ","; 1478 sep = ",";
1480 } 1479 }
@@ -1578,8 +1577,7 @@ static mdk_rdev_t *md_import_device(dev_t newdev, int super_format, int super_mi
1578 kobject_init(&rdev->kobj); 1577 kobject_init(&rdev->kobj);
1579 1578
1580 rdev->desc_nr = -1; 1579 rdev->desc_nr = -1;
1581 rdev->faulty = 0; 1580 rdev->flags = 0;
1582 rdev->in_sync = 0;
1583 rdev->data_offset = 0; 1581 rdev->data_offset = 0;
1584 atomic_set(&rdev->nr_pending, 0); 1582 atomic_set(&rdev->nr_pending, 0);
1585 atomic_set(&rdev->read_errors, 0); 1583 atomic_set(&rdev->read_errors, 0);
@@ -1670,7 +1668,7 @@ static void analyze_sbs(mddev_t * mddev)
1670 if (mddev->level == LEVEL_MULTIPATH) { 1668 if (mddev->level == LEVEL_MULTIPATH) {
1671 rdev->desc_nr = i++; 1669 rdev->desc_nr = i++;
1672 rdev->raid_disk = rdev->desc_nr; 1670 rdev->raid_disk = rdev->desc_nr;
1673 rdev->in_sync = 1; 1671 set_bit(In_sync, &rdev->flags);
1674 } 1672 }
1675 } 1673 }
1676 1674
@@ -1939,7 +1937,7 @@ static int do_md_run(mddev_t * mddev)
1939 1937
1940 /* devices must have minimum size of one chunk */ 1938 /* devices must have minimum size of one chunk */
1941 ITERATE_RDEV(mddev,rdev,tmp) { 1939 ITERATE_RDEV(mddev,rdev,tmp) {
1942 if (rdev->faulty) 1940 if (test_bit(Faulty, &rdev->flags))
1943 continue; 1941 continue;
1944 if (rdev->size < chunk_size / 1024) { 1942 if (rdev->size < chunk_size / 1024) {
1945 printk(KERN_WARNING 1943 printk(KERN_WARNING
@@ -1967,7 +1965,7 @@ static int do_md_run(mddev_t * mddev)
1967 * Also find largest hardsector size 1965 * Also find largest hardsector size
1968 */ 1966 */
1969 ITERATE_RDEV(mddev,rdev,tmp) { 1967 ITERATE_RDEV(mddev,rdev,tmp) {
1970 if (rdev->faulty) 1968 if (test_bit(Faulty, &rdev->flags))
1971 continue; 1969 continue;
1972 sync_blockdev(rdev->bdev); 1970 sync_blockdev(rdev->bdev);
1973 invalidate_bdev(rdev->bdev, 0); 1971 invalidate_bdev(rdev->bdev, 0);
@@ -2304,7 +2302,7 @@ static int autostart_array(dev_t startdev)
2304 return err; 2302 return err;
2305 } 2303 }
2306 2304
2307 if (start_rdev->faulty) { 2305 if (test_bit(Faulty, &start_rdev->flags)) {
2308 printk(KERN_WARNING 2306 printk(KERN_WARNING
2309 "md: can not autostart based on faulty %s!\n", 2307 "md: can not autostart based on faulty %s!\n",
2310 bdevname(start_rdev->bdev,b)); 2308 bdevname(start_rdev->bdev,b));
@@ -2363,11 +2361,11 @@ static int get_array_info(mddev_t * mddev, void __user * arg)
2363 nr=working=active=failed=spare=0; 2361 nr=working=active=failed=spare=0;
2364 ITERATE_RDEV(mddev,rdev,tmp) { 2362 ITERATE_RDEV(mddev,rdev,tmp) {
2365 nr++; 2363 nr++;
2366 if (rdev->faulty) 2364 if (test_bit(Faulty, &rdev->flags))
2367 failed++; 2365 failed++;
2368 else { 2366 else {
2369 working++; 2367 working++;
2370 if (rdev->in_sync) 2368 if (test_bit(In_sync, &rdev->flags))
2371 active++; 2369 active++;
2372 else 2370 else
2373 spare++; 2371 spare++;
@@ -2458,9 +2456,9 @@ static int get_disk_info(mddev_t * mddev, void __user * arg)
2458 info.minor = MINOR(rdev->bdev->bd_dev); 2456 info.minor = MINOR(rdev->bdev->bd_dev);
2459 info.raid_disk = rdev->raid_disk; 2457 info.raid_disk = rdev->raid_disk;
2460 info.state = 0; 2458 info.state = 0;
2461 if (rdev->faulty) 2459 if (test_bit(Faulty, &rdev->flags))
2462 info.state |= (1<<MD_DISK_FAULTY); 2460 info.state |= (1<<MD_DISK_FAULTY);
2463 else if (rdev->in_sync) { 2461 else if (test_bit(In_sync, &rdev->flags)) {
2464 info.state |= (1<<MD_DISK_ACTIVE); 2462 info.state |= (1<<MD_DISK_ACTIVE);
2465 info.state |= (1<<MD_DISK_SYNC); 2463 info.state |= (1<<MD_DISK_SYNC);
2466 } 2464 }
@@ -2553,7 +2551,7 @@ static int add_new_disk(mddev_t * mddev, mdu_disk_info_t *info)
2553 validate_super(mddev, rdev); 2551 validate_super(mddev, rdev);
2554 rdev->saved_raid_disk = rdev->raid_disk; 2552 rdev->saved_raid_disk = rdev->raid_disk;
2555 2553
2556 rdev->in_sync = 0; /* just to be sure */ 2554 clear_bit(In_sync, &rdev->flags); /* just to be sure */
2557 if (info->state & (1<<MD_DISK_WRITEMOSTLY)) 2555 if (info->state & (1<<MD_DISK_WRITEMOSTLY))
2558 set_bit(WriteMostly, &rdev->flags); 2556 set_bit(WriteMostly, &rdev->flags);
2559 2557
@@ -2591,11 +2589,11 @@ static int add_new_disk(mddev_t * mddev, mdu_disk_info_t *info)
2591 else 2589 else
2592 rdev->raid_disk = -1; 2590 rdev->raid_disk = -1;
2593 2591
2594 rdev->faulty = 0; 2592 rdev->flags = 0;
2593
2595 if (rdev->raid_disk < mddev->raid_disks) 2594 if (rdev->raid_disk < mddev->raid_disks)
2596 rdev->in_sync = (info->state & (1<<MD_DISK_SYNC)); 2595 if (info->state & (1<<MD_DISK_SYNC))
2597 else 2596 set_bit(In_sync, &rdev->flags);
2598 rdev->in_sync = 0;
2599 2597
2600 if (info->state & (1<<MD_DISK_WRITEMOSTLY)) 2598 if (info->state & (1<<MD_DISK_WRITEMOSTLY))
2601 set_bit(WriteMostly, &rdev->flags); 2599 set_bit(WriteMostly, &rdev->flags);
@@ -2694,14 +2692,14 @@ static int hot_add_disk(mddev_t * mddev, dev_t dev)
2694 goto abort_export; 2692 goto abort_export;
2695 } 2693 }
2696 2694
2697 if (rdev->faulty) { 2695 if (test_bit(Faulty, &rdev->flags)) {
2698 printk(KERN_WARNING 2696 printk(KERN_WARNING
2699 "md: can not hot-add faulty %s disk to %s!\n", 2697 "md: can not hot-add faulty %s disk to %s!\n",
2700 bdevname(rdev->bdev,b), mdname(mddev)); 2698 bdevname(rdev->bdev,b), mdname(mddev));
2701 err = -EINVAL; 2699 err = -EINVAL;
2702 goto abort_export; 2700 goto abort_export;
2703 } 2701 }
2704 rdev->in_sync = 0; 2702 clear_bit(In_sync, &rdev->flags);
2705 rdev->desc_nr = -1; 2703 rdev->desc_nr = -1;
2706 bind_rdev_to_array(rdev, mddev); 2704 bind_rdev_to_array(rdev, mddev);
2707 2705
@@ -3428,7 +3426,7 @@ void md_error(mddev_t *mddev, mdk_rdev_t *rdev)
3428 return; 3426 return;
3429 } 3427 }
3430 3428
3431 if (!rdev || rdev->faulty) 3429 if (!rdev || test_bit(Faulty, &rdev->flags))
3432 return; 3430 return;
3433/* 3431/*
3434 dprintk("md_error dev:%s, rdev:(%d:%d), (caller: %p,%p,%p,%p).\n", 3432 dprintk("md_error dev:%s, rdev:(%d:%d), (caller: %p,%p,%p,%p).\n",
@@ -3626,7 +3624,7 @@ static int md_seq_show(struct seq_file *seq, void *v)
3626 bdevname(rdev->bdev,b), rdev->desc_nr); 3624 bdevname(rdev->bdev,b), rdev->desc_nr);
3627 if (test_bit(WriteMostly, &rdev->flags)) 3625 if (test_bit(WriteMostly, &rdev->flags))
3628 seq_printf(seq, "(W)"); 3626 seq_printf(seq, "(W)");
3629 if (rdev->faulty) { 3627 if (test_bit(Faulty, &rdev->flags)) {
3630 seq_printf(seq, "(F)"); 3628 seq_printf(seq, "(F)");
3631 continue; 3629 continue;
3632 } else if (rdev->raid_disk < 0) 3630 } else if (rdev->raid_disk < 0)
@@ -4174,7 +4172,7 @@ void md_check_recovery(mddev_t *mddev)
4174 */ 4172 */
4175 ITERATE_RDEV(mddev,rdev,rtmp) 4173 ITERATE_RDEV(mddev,rdev,rtmp)
4176 if (rdev->raid_disk >= 0 && 4174 if (rdev->raid_disk >= 0 &&
4177 (rdev->faulty || ! rdev->in_sync) && 4175 (test_bit(Faulty, &rdev->flags) || ! test_bit(In_sync, &rdev->flags)) &&
4178 atomic_read(&rdev->nr_pending)==0) { 4176 atomic_read(&rdev->nr_pending)==0) {
4179 if (mddev->pers->hot_remove_disk(mddev, rdev->raid_disk)==0) { 4177 if (mddev->pers->hot_remove_disk(mddev, rdev->raid_disk)==0) {
4180 char nm[20]; 4178 char nm[20];
@@ -4187,7 +4185,7 @@ void md_check_recovery(mddev_t *mddev)
4187 if (mddev->degraded) { 4185 if (mddev->degraded) {
4188 ITERATE_RDEV(mddev,rdev,rtmp) 4186 ITERATE_RDEV(mddev,rdev,rtmp)
4189 if (rdev->raid_disk < 0 4187 if (rdev->raid_disk < 0
4190 && !rdev->faulty) { 4188 && !test_bit(Faulty, &rdev->flags)) {
4191 if (mddev->pers->hot_add_disk(mddev,rdev)) { 4189 if (mddev->pers->hot_add_disk(mddev,rdev)) {
4192 char nm[20]; 4190 char nm[20];
4193 sprintf(nm, "rd%d", rdev->raid_disk); 4191 sprintf(nm, "rd%d", rdev->raid_disk);
@@ -4347,7 +4345,7 @@ static void autostart_arrays(int part)
4347 if (IS_ERR(rdev)) 4345 if (IS_ERR(rdev))
4348 continue; 4346 continue;
4349 4347
4350 if (rdev->faulty) { 4348 if (test_bit(Faulty, &rdev->flags)) {
4351 MD_BUG(); 4349 MD_BUG();
4352 continue; 4350 continue;
4353 } 4351 }