aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/md
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/md')
-rw-r--r--drivers/md/bitmap.c6
-rw-r--r--drivers/md/md.c92
-rw-r--r--drivers/md/multipath.c23
-rw-r--r--drivers/md/raid1.c52
-rw-r--r--drivers/md/raid10.c41
-rw-r--r--drivers/md/raid5.c36
-rw-r--r--drivers/md/raid6main.c32
7 files changed, 142 insertions, 140 deletions
diff --git a/drivers/md/bitmap.c b/drivers/md/bitmap.c
index e59694bc5758..c5fa4c2a5af1 100644
--- a/drivers/md/bitmap.c
+++ b/drivers/md/bitmap.c
@@ -271,7 +271,8 @@ static struct page *read_sb_page(mddev_t *mddev, long offset, unsigned long inde
271 return ERR_PTR(-ENOMEM); 271 return ERR_PTR(-ENOMEM);
272 272
273 ITERATE_RDEV(mddev, rdev, tmp) { 273 ITERATE_RDEV(mddev, rdev, tmp) {
274 if (! rdev->in_sync || rdev->faulty) 274 if (! test_bit(In_sync, &rdev->flags)
275 || test_bit(Faulty, &rdev->flags))
275 continue; 276 continue;
276 277
277 target = (rdev->sb_offset << 1) + offset + index * (PAGE_SIZE/512); 278 target = (rdev->sb_offset << 1) + offset + index * (PAGE_SIZE/512);
@@ -291,7 +292,8 @@ static int write_sb_page(mddev_t *mddev, long offset, struct page *page, int wai
291 struct list_head *tmp; 292 struct list_head *tmp;
292 293
293 ITERATE_RDEV(mddev, rdev, tmp) 294 ITERATE_RDEV(mddev, rdev, tmp)
294 if (rdev->in_sync && !rdev->faulty) 295 if (test_bit(In_sync, &rdev->flags)
296 && !test_bit(Faulty, &rdev->flags))
295 md_super_write(mddev, rdev, 297 md_super_write(mddev, rdev,
296 (rdev->sb_offset<<1) + offset 298 (rdev->sb_offset<<1) + offset
297 + page->index * (PAGE_SIZE/512), 299 + page->index * (PAGE_SIZE/512),
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 }
diff --git a/drivers/md/multipath.c b/drivers/md/multipath.c
index ae2c5fd6105d..145cdc5ad008 100644
--- a/drivers/md/multipath.c
+++ b/drivers/md/multipath.c
@@ -64,7 +64,7 @@ static int multipath_map (multipath_conf_t *conf)
64 rcu_read_lock(); 64 rcu_read_lock();
65 for (i = 0; i < disks; i++) { 65 for (i = 0; i < disks; i++) {
66 mdk_rdev_t *rdev = rcu_dereference(conf->multipaths[i].rdev); 66 mdk_rdev_t *rdev = rcu_dereference(conf->multipaths[i].rdev);
67 if (rdev && rdev->in_sync) { 67 if (rdev && test_bit(In_sync, &rdev->flags)) {
68 atomic_inc(&rdev->nr_pending); 68 atomic_inc(&rdev->nr_pending);
69 rcu_read_unlock(); 69 rcu_read_unlock();
70 return i; 70 return i;
@@ -140,7 +140,8 @@ static void unplug_slaves(mddev_t *mddev)
140 rcu_read_lock(); 140 rcu_read_lock();
141 for (i=0; i<mddev->raid_disks; i++) { 141 for (i=0; i<mddev->raid_disks; i++) {
142 mdk_rdev_t *rdev = rcu_dereference(conf->multipaths[i].rdev); 142 mdk_rdev_t *rdev = rcu_dereference(conf->multipaths[i].rdev);
143 if (rdev && !rdev->faulty && atomic_read(&rdev->nr_pending)) { 143 if (rdev && !test_bit(Faulty, &rdev->flags)
144 && atomic_read(&rdev->nr_pending)) {
144 request_queue_t *r_queue = bdev_get_queue(rdev->bdev); 145 request_queue_t *r_queue = bdev_get_queue(rdev->bdev);
145 146
146 atomic_inc(&rdev->nr_pending); 147 atomic_inc(&rdev->nr_pending);
@@ -211,7 +212,7 @@ static void multipath_status (struct seq_file *seq, mddev_t *mddev)
211 for (i = 0; i < conf->raid_disks; i++) 212 for (i = 0; i < conf->raid_disks; i++)
212 seq_printf (seq, "%s", 213 seq_printf (seq, "%s",
213 conf->multipaths[i].rdev && 214 conf->multipaths[i].rdev &&
214 conf->multipaths[i].rdev->in_sync ? "U" : "_"); 215 test_bit(In_sync, &conf->multipaths[i].rdev->flags) ? "U" : "_");
215 seq_printf (seq, "]"); 216 seq_printf (seq, "]");
216} 217}
217 218
@@ -225,7 +226,7 @@ static int multipath_issue_flush(request_queue_t *q, struct gendisk *disk,
225 rcu_read_lock(); 226 rcu_read_lock();
226 for (i=0; i<mddev->raid_disks && ret == 0; i++) { 227 for (i=0; i<mddev->raid_disks && ret == 0; i++) {
227 mdk_rdev_t *rdev = rcu_dereference(conf->multipaths[i].rdev); 228 mdk_rdev_t *rdev = rcu_dereference(conf->multipaths[i].rdev);
228 if (rdev && !rdev->faulty) { 229 if (rdev && !test_bit(Faulty, &rdev->flags)) {
229 struct block_device *bdev = rdev->bdev; 230 struct block_device *bdev = rdev->bdev;
230 request_queue_t *r_queue = bdev_get_queue(bdev); 231 request_queue_t *r_queue = bdev_get_queue(bdev);
231 232
@@ -265,10 +266,10 @@ static void multipath_error (mddev_t *mddev, mdk_rdev_t *rdev)
265 /* 266 /*
266 * Mark disk as unusable 267 * Mark disk as unusable
267 */ 268 */
268 if (!rdev->faulty) { 269 if (!test_bit(Faulty, &rdev->flags)) {
269 char b[BDEVNAME_SIZE]; 270 char b[BDEVNAME_SIZE];
270 rdev->in_sync = 0; 271 clear_bit(In_sync, &rdev->flags);
271 rdev->faulty = 1; 272 set_bit(Faulty, &rdev->flags);
272 mddev->sb_dirty = 1; 273 mddev->sb_dirty = 1;
273 conf->working_disks--; 274 conf->working_disks--;
274 printk(KERN_ALERT "multipath: IO failure on %s," 275 printk(KERN_ALERT "multipath: IO failure on %s,"
@@ -298,7 +299,7 @@ static void print_multipath_conf (multipath_conf_t *conf)
298 tmp = conf->multipaths + i; 299 tmp = conf->multipaths + i;
299 if (tmp->rdev) 300 if (tmp->rdev)
300 printk(" disk%d, o:%d, dev:%s\n", 301 printk(" disk%d, o:%d, dev:%s\n",
301 i,!tmp->rdev->faulty, 302 i,!test_bit(Faulty, &tmp->rdev->flags),
302 bdevname(tmp->rdev->bdev,b)); 303 bdevname(tmp->rdev->bdev,b));
303 } 304 }
304} 305}
@@ -330,7 +331,7 @@ static int multipath_add_disk(mddev_t *mddev, mdk_rdev_t *rdev)
330 331
331 conf->working_disks++; 332 conf->working_disks++;
332 rdev->raid_disk = path; 333 rdev->raid_disk = path;
333 rdev->in_sync = 1; 334 set_bit(In_sync, &rdev->flags);
334 rcu_assign_pointer(p->rdev, rdev); 335 rcu_assign_pointer(p->rdev, rdev);
335 found = 1; 336 found = 1;
336 } 337 }
@@ -350,7 +351,7 @@ static int multipath_remove_disk(mddev_t *mddev, int number)
350 351
351 rdev = p->rdev; 352 rdev = p->rdev;
352 if (rdev) { 353 if (rdev) {
353 if (rdev->in_sync || 354 if (test_bit(In_sync, &rdev->flags) ||
354 atomic_read(&rdev->nr_pending)) { 355 atomic_read(&rdev->nr_pending)) {
355 printk(KERN_ERR "hot-remove-disk, slot %d is identified" " but is still operational!\n", number); 356 printk(KERN_ERR "hot-remove-disk, slot %d is identified" " but is still operational!\n", number);
356 err = -EBUSY; 357 err = -EBUSY;
@@ -482,7 +483,7 @@ static int multipath_run (mddev_t *mddev)
482 mddev->queue->max_sectors > (PAGE_SIZE>>9)) 483 mddev->queue->max_sectors > (PAGE_SIZE>>9))
483 blk_queue_max_sectors(mddev->queue, PAGE_SIZE>>9); 484 blk_queue_max_sectors(mddev->queue, PAGE_SIZE>>9);
484 485
485 if (!rdev->faulty) 486 if (!test_bit(Faulty, &rdev->flags))
486 conf->working_disks++; 487 conf->working_disks++;
487 } 488 }
488 489
diff --git a/drivers/md/raid1.c b/drivers/md/raid1.c
index f12fc288f25d..fb6b866c28f5 100644
--- a/drivers/md/raid1.c
+++ b/drivers/md/raid1.c
@@ -417,11 +417,11 @@ static int read_balance(conf_t *conf, r1bio_t *r1_bio)
417 new_disk = 0; 417 new_disk = 0;
418 418
419 for (rdev = rcu_dereference(conf->mirrors[new_disk].rdev); 419 for (rdev = rcu_dereference(conf->mirrors[new_disk].rdev);
420 !rdev || !rdev->in_sync 420 !rdev || !test_bit(In_sync, &rdev->flags)
421 || test_bit(WriteMostly, &rdev->flags); 421 || test_bit(WriteMostly, &rdev->flags);
422 rdev = rcu_dereference(conf->mirrors[++new_disk].rdev)) { 422 rdev = rcu_dereference(conf->mirrors[++new_disk].rdev)) {
423 423
424 if (rdev && rdev->in_sync) 424 if (rdev && test_bit(In_sync, &rdev->flags))
425 wonly_disk = new_disk; 425 wonly_disk = new_disk;
426 426
427 if (new_disk == conf->raid_disks - 1) { 427 if (new_disk == conf->raid_disks - 1) {
@@ -435,11 +435,11 @@ static int read_balance(conf_t *conf, r1bio_t *r1_bio)
435 435
436 /* make sure the disk is operational */ 436 /* make sure the disk is operational */
437 for (rdev = rcu_dereference(conf->mirrors[new_disk].rdev); 437 for (rdev = rcu_dereference(conf->mirrors[new_disk].rdev);
438 !rdev || !rdev->in_sync || 438 !rdev || !test_bit(In_sync, &rdev->flags) ||
439 test_bit(WriteMostly, &rdev->flags); 439 test_bit(WriteMostly, &rdev->flags);
440 rdev = rcu_dereference(conf->mirrors[new_disk].rdev)) { 440 rdev = rcu_dereference(conf->mirrors[new_disk].rdev)) {
441 441
442 if (rdev && rdev->in_sync) 442 if (rdev && test_bit(In_sync, &rdev->flags))
443 wonly_disk = new_disk; 443 wonly_disk = new_disk;
444 444
445 if (new_disk <= 0) 445 if (new_disk <= 0)
@@ -477,7 +477,7 @@ static int read_balance(conf_t *conf, r1bio_t *r1_bio)
477 rdev = rcu_dereference(conf->mirrors[disk].rdev); 477 rdev = rcu_dereference(conf->mirrors[disk].rdev);
478 478
479 if (!rdev || 479 if (!rdev ||
480 !rdev->in_sync || 480 !test_bit(In_sync, &rdev->flags) ||
481 test_bit(WriteMostly, &rdev->flags)) 481 test_bit(WriteMostly, &rdev->flags))
482 continue; 482 continue;
483 483
@@ -500,7 +500,7 @@ static int read_balance(conf_t *conf, r1bio_t *r1_bio)
500 if (!rdev) 500 if (!rdev)
501 goto retry; 501 goto retry;
502 atomic_inc(&rdev->nr_pending); 502 atomic_inc(&rdev->nr_pending);
503 if (!rdev->in_sync) { 503 if (!test_bit(In_sync, &rdev->flags)) {
504 /* cannot risk returning a device that failed 504 /* cannot risk returning a device that failed
505 * before we inc'ed nr_pending 505 * before we inc'ed nr_pending
506 */ 506 */
@@ -523,7 +523,7 @@ static void unplug_slaves(mddev_t *mddev)
523 rcu_read_lock(); 523 rcu_read_lock();
524 for (i=0; i<mddev->raid_disks; i++) { 524 for (i=0; i<mddev->raid_disks; i++) {
525 mdk_rdev_t *rdev = rcu_dereference(conf->mirrors[i].rdev); 525 mdk_rdev_t *rdev = rcu_dereference(conf->mirrors[i].rdev);
526 if (rdev && !rdev->faulty && atomic_read(&rdev->nr_pending)) { 526 if (rdev && !test_bit(Faulty, &rdev->flags) && atomic_read(&rdev->nr_pending)) {
527 request_queue_t *r_queue = bdev_get_queue(rdev->bdev); 527 request_queue_t *r_queue = bdev_get_queue(rdev->bdev);
528 528
529 atomic_inc(&rdev->nr_pending); 529 atomic_inc(&rdev->nr_pending);
@@ -557,7 +557,7 @@ static int raid1_issue_flush(request_queue_t *q, struct gendisk *disk,
557 rcu_read_lock(); 557 rcu_read_lock();
558 for (i=0; i<mddev->raid_disks && ret == 0; i++) { 558 for (i=0; i<mddev->raid_disks && ret == 0; i++) {
559 mdk_rdev_t *rdev = rcu_dereference(conf->mirrors[i].rdev); 559 mdk_rdev_t *rdev = rcu_dereference(conf->mirrors[i].rdev);
560 if (rdev && !rdev->faulty) { 560 if (rdev && !test_bit(Faulty, &rdev->flags)) {
561 struct block_device *bdev = rdev->bdev; 561 struct block_device *bdev = rdev->bdev;
562 request_queue_t *r_queue = bdev_get_queue(bdev); 562 request_queue_t *r_queue = bdev_get_queue(bdev);
563 563
@@ -729,9 +729,9 @@ static int make_request(request_queue_t *q, struct bio * bio)
729 rcu_read_lock(); 729 rcu_read_lock();
730 for (i = 0; i < disks; i++) { 730 for (i = 0; i < disks; i++) {
731 if ((rdev=rcu_dereference(conf->mirrors[i].rdev)) != NULL && 731 if ((rdev=rcu_dereference(conf->mirrors[i].rdev)) != NULL &&
732 !rdev->faulty) { 732 !test_bit(Faulty, &rdev->flags)) {
733 atomic_inc(&rdev->nr_pending); 733 atomic_inc(&rdev->nr_pending);
734 if (rdev->faulty) { 734 if (test_bit(Faulty, &rdev->flags)) {
735 atomic_dec(&rdev->nr_pending); 735 atomic_dec(&rdev->nr_pending);
736 r1_bio->bios[i] = NULL; 736 r1_bio->bios[i] = NULL;
737 } else 737 } else
@@ -824,7 +824,7 @@ static void status(struct seq_file *seq, mddev_t *mddev)
824 for (i = 0; i < conf->raid_disks; i++) 824 for (i = 0; i < conf->raid_disks; i++)
825 seq_printf(seq, "%s", 825 seq_printf(seq, "%s",
826 conf->mirrors[i].rdev && 826 conf->mirrors[i].rdev &&
827 conf->mirrors[i].rdev->in_sync ? "U" : "_"); 827 test_bit(In_sync, &conf->mirrors[i].rdev->flags) ? "U" : "_");
828 seq_printf(seq, "]"); 828 seq_printf(seq, "]");
829} 829}
830 830
@@ -840,14 +840,14 @@ static void error(mddev_t *mddev, mdk_rdev_t *rdev)
840 * next level up know. 840 * next level up know.
841 * else mark the drive as failed 841 * else mark the drive as failed
842 */ 842 */
843 if (rdev->in_sync 843 if (test_bit(In_sync, &rdev->flags)
844 && conf->working_disks == 1) 844 && conf->working_disks == 1)
845 /* 845 /*
846 * Don't fail the drive, act as though we were just a 846 * Don't fail the drive, act as though we were just a
847 * normal single drive 847 * normal single drive
848 */ 848 */
849 return; 849 return;
850 if (rdev->in_sync) { 850 if (test_bit(In_sync, &rdev->flags)) {
851 mddev->degraded++; 851 mddev->degraded++;
852 conf->working_disks--; 852 conf->working_disks--;
853 /* 853 /*
@@ -855,8 +855,8 @@ static void error(mddev_t *mddev, mdk_rdev_t *rdev)
855 */ 855 */
856 set_bit(MD_RECOVERY_ERR, &mddev->recovery); 856 set_bit(MD_RECOVERY_ERR, &mddev->recovery);
857 } 857 }
858 rdev->in_sync = 0; 858 clear_bit(In_sync, &rdev->flags);
859 rdev->faulty = 1; 859 set_bit(Faulty, &rdev->flags);
860 mddev->sb_dirty = 1; 860 mddev->sb_dirty = 1;
861 printk(KERN_ALERT "raid1: Disk failure on %s, disabling device. \n" 861 printk(KERN_ALERT "raid1: Disk failure on %s, disabling device. \n"
862 " Operation continuing on %d devices\n", 862 " Operation continuing on %d devices\n",
@@ -881,7 +881,7 @@ static void print_conf(conf_t *conf)
881 tmp = conf->mirrors + i; 881 tmp = conf->mirrors + i;
882 if (tmp->rdev) 882 if (tmp->rdev)
883 printk(" disk %d, wo:%d, o:%d, dev:%s\n", 883 printk(" disk %d, wo:%d, o:%d, dev:%s\n",
884 i, !tmp->rdev->in_sync, !tmp->rdev->faulty, 884 i, !test_bit(In_sync, &tmp->rdev->flags), !test_bit(Faulty, &tmp->rdev->flags),
885 bdevname(tmp->rdev->bdev,b)); 885 bdevname(tmp->rdev->bdev,b));
886 } 886 }
887} 887}
@@ -913,11 +913,11 @@ static int raid1_spare_active(mddev_t *mddev)
913 for (i = 0; i < conf->raid_disks; i++) { 913 for (i = 0; i < conf->raid_disks; i++) {
914 tmp = conf->mirrors + i; 914 tmp = conf->mirrors + i;
915 if (tmp->rdev 915 if (tmp->rdev
916 && !tmp->rdev->faulty 916 && !test_bit(Faulty, &tmp->rdev->flags)
917 && !tmp->rdev->in_sync) { 917 && !test_bit(In_sync, &tmp->rdev->flags)) {
918 conf->working_disks++; 918 conf->working_disks++;
919 mddev->degraded--; 919 mddev->degraded--;
920 tmp->rdev->in_sync = 1; 920 set_bit(In_sync, &tmp->rdev->flags);
921 } 921 }
922 } 922 }
923 923
@@ -972,7 +972,7 @@ static int raid1_remove_disk(mddev_t *mddev, int number)
972 print_conf(conf); 972 print_conf(conf);
973 rdev = p->rdev; 973 rdev = p->rdev;
974 if (rdev) { 974 if (rdev) {
975 if (rdev->in_sync || 975 if (test_bit(In_sync, &rdev->flags) ||
976 atomic_read(&rdev->nr_pending)) { 976 atomic_read(&rdev->nr_pending)) {
977 err = -EBUSY; 977 err = -EBUSY;
978 goto abort; 978 goto abort;
@@ -1282,11 +1282,11 @@ static sector_t sync_request(mddev_t *mddev, sector_t sector_nr, int *skipped, i
1282 /* make sure disk is operational */ 1282 /* make sure disk is operational */
1283 wonly = disk; 1283 wonly = disk;
1284 while (conf->mirrors[disk].rdev == NULL || 1284 while (conf->mirrors[disk].rdev == NULL ||
1285 !conf->mirrors[disk].rdev->in_sync || 1285 !test_bit(In_sync, &conf->mirrors[disk].rdev->flags) ||
1286 test_bit(WriteMostly, &conf->mirrors[disk].rdev->flags) 1286 test_bit(WriteMostly, &conf->mirrors[disk].rdev->flags)
1287 ) { 1287 ) {
1288 if (conf->mirrors[disk].rdev && 1288 if (conf->mirrors[disk].rdev &&
1289 conf->mirrors[disk].rdev->in_sync) 1289 test_bit(In_sync, &conf->mirrors[disk].rdev->flags))
1290 wonly = disk; 1290 wonly = disk;
1291 if (disk <= 0) 1291 if (disk <= 0)
1292 disk = conf->raid_disks; 1292 disk = conf->raid_disks;
@@ -1333,10 +1333,10 @@ static sector_t sync_request(mddev_t *mddev, sector_t sector_nr, int *skipped, i
1333 bio->bi_rw = READ; 1333 bio->bi_rw = READ;
1334 bio->bi_end_io = end_sync_read; 1334 bio->bi_end_io = end_sync_read;
1335 } else if (conf->mirrors[i].rdev == NULL || 1335 } else if (conf->mirrors[i].rdev == NULL ||
1336 conf->mirrors[i].rdev->faulty) { 1336 test_bit(Faulty, &conf->mirrors[i].rdev->flags)) {
1337 still_degraded = 1; 1337 still_degraded = 1;
1338 continue; 1338 continue;
1339 } else if (!conf->mirrors[i].rdev->in_sync || 1339 } else if (!test_bit(In_sync, &conf->mirrors[i].rdev->flags) ||
1340 sector_nr + RESYNC_SECTORS > mddev->recovery_cp) { 1340 sector_nr + RESYNC_SECTORS > mddev->recovery_cp) {
1341 bio->bi_rw = WRITE; 1341 bio->bi_rw = WRITE;
1342 bio->bi_end_io = end_sync_write; 1342 bio->bi_end_io = end_sync_write;
@@ -1478,7 +1478,7 @@ static int run(mddev_t *mddev)
1478 blk_queue_max_sectors(mddev->queue, PAGE_SIZE>>9); 1478 blk_queue_max_sectors(mddev->queue, PAGE_SIZE>>9);
1479 1479
1480 disk->head_position = 0; 1480 disk->head_position = 0;
1481 if (!rdev->faulty && rdev->in_sync) 1481 if (!test_bit(Faulty, &rdev->flags) && test_bit(In_sync, &rdev->flags))
1482 conf->working_disks++; 1482 conf->working_disks++;
1483 } 1483 }
1484 conf->raid_disks = mddev->raid_disks; 1484 conf->raid_disks = mddev->raid_disks;
@@ -1518,7 +1518,7 @@ static int run(mddev_t *mddev)
1518 */ 1518 */
1519 for (j = 0; j < conf->raid_disks && 1519 for (j = 0; j < conf->raid_disks &&
1520 (!conf->mirrors[j].rdev || 1520 (!conf->mirrors[j].rdev ||
1521 !conf->mirrors[j].rdev->in_sync) ; j++) 1521 !test_bit(In_sync, &conf->mirrors[j].rdev->flags)) ; j++)
1522 /* nothing */; 1522 /* nothing */;
1523 conf->last_used = j; 1523 conf->last_used = j;
1524 1524
diff --git a/drivers/md/raid10.c b/drivers/md/raid10.c
index 26114f40bde6..867f06ae33d9 100644
--- a/drivers/md/raid10.c
+++ b/drivers/md/raid10.c
@@ -512,7 +512,7 @@ static int read_balance(conf_t *conf, r10bio_t *r10_bio)
512 disk = r10_bio->devs[slot].devnum; 512 disk = r10_bio->devs[slot].devnum;
513 513
514 while ((rdev = rcu_dereference(conf->mirrors[disk].rdev)) == NULL || 514 while ((rdev = rcu_dereference(conf->mirrors[disk].rdev)) == NULL ||
515 !rdev->in_sync) { 515 !test_bit(In_sync, &rdev->flags)) {
516 slot++; 516 slot++;
517 if (slot == conf->copies) { 517 if (slot == conf->copies) {
518 slot = 0; 518 slot = 0;
@@ -529,7 +529,7 @@ static int read_balance(conf_t *conf, r10bio_t *r10_bio)
529 slot = 0; 529 slot = 0;
530 disk = r10_bio->devs[slot].devnum; 530 disk = r10_bio->devs[slot].devnum;
531 while ((rdev=rcu_dereference(conf->mirrors[disk].rdev)) == NULL || 531 while ((rdev=rcu_dereference(conf->mirrors[disk].rdev)) == NULL ||
532 !rdev->in_sync) { 532 !test_bit(In_sync, &rdev->flags)) {
533 slot ++; 533 slot ++;
534 if (slot == conf->copies) { 534 if (slot == conf->copies) {
535 disk = -1; 535 disk = -1;
@@ -549,7 +549,7 @@ static int read_balance(conf_t *conf, r10bio_t *r10_bio)
549 549
550 550
551 if ((rdev=rcu_dereference(conf->mirrors[ndisk].rdev)) == NULL || 551 if ((rdev=rcu_dereference(conf->mirrors[ndisk].rdev)) == NULL ||
552 !rdev->in_sync) 552 !test_bit(In_sync, &rdev->flags))
553 continue; 553 continue;
554 554
555 if (!atomic_read(&rdev->nr_pending)) { 555 if (!atomic_read(&rdev->nr_pending)) {
@@ -585,7 +585,7 @@ static void unplug_slaves(mddev_t *mddev)
585 rcu_read_lock(); 585 rcu_read_lock();
586 for (i=0; i<mddev->raid_disks; i++) { 586 for (i=0; i<mddev->raid_disks; i++) {
587 mdk_rdev_t *rdev = rcu_dereference(conf->mirrors[i].rdev); 587 mdk_rdev_t *rdev = rcu_dereference(conf->mirrors[i].rdev);
588 if (rdev && !rdev->faulty && atomic_read(&rdev->nr_pending)) { 588 if (rdev && !test_bit(Faulty, &rdev->flags) && atomic_read(&rdev->nr_pending)) {
589 request_queue_t *r_queue = bdev_get_queue(rdev->bdev); 589 request_queue_t *r_queue = bdev_get_queue(rdev->bdev);
590 590
591 atomic_inc(&rdev->nr_pending); 591 atomic_inc(&rdev->nr_pending);
@@ -616,7 +616,7 @@ static int raid10_issue_flush(request_queue_t *q, struct gendisk *disk,
616 rcu_read_lock(); 616 rcu_read_lock();
617 for (i=0; i<mddev->raid_disks && ret == 0; i++) { 617 for (i=0; i<mddev->raid_disks && ret == 0; i++) {
618 mdk_rdev_t *rdev = rcu_dereference(conf->mirrors[i].rdev); 618 mdk_rdev_t *rdev = rcu_dereference(conf->mirrors[i].rdev);
619 if (rdev && !rdev->faulty) { 619 if (rdev && !test_bit(Faulty, &rdev->flags)) {
620 struct block_device *bdev = rdev->bdev; 620 struct block_device *bdev = rdev->bdev;
621 request_queue_t *r_queue = bdev_get_queue(bdev); 621 request_queue_t *r_queue = bdev_get_queue(bdev);
622 622
@@ -771,7 +771,7 @@ static int make_request(request_queue_t *q, struct bio * bio)
771 int d = r10_bio->devs[i].devnum; 771 int d = r10_bio->devs[i].devnum;
772 mdk_rdev_t *rdev = rcu_dereference(conf->mirrors[d].rdev); 772 mdk_rdev_t *rdev = rcu_dereference(conf->mirrors[d].rdev);
773 if (rdev && 773 if (rdev &&
774 !rdev->faulty) { 774 !test_bit(Faulty, &rdev->flags)) {
775 atomic_inc(&rdev->nr_pending); 775 atomic_inc(&rdev->nr_pending);
776 r10_bio->devs[i].bio = bio; 776 r10_bio->devs[i].bio = bio;
777 } else 777 } else
@@ -826,7 +826,7 @@ static void status(struct seq_file *seq, mddev_t *mddev)
826 for (i = 0; i < conf->raid_disks; i++) 826 for (i = 0; i < conf->raid_disks; i++)
827 seq_printf(seq, "%s", 827 seq_printf(seq, "%s",
828 conf->mirrors[i].rdev && 828 conf->mirrors[i].rdev &&
829 conf->mirrors[i].rdev->in_sync ? "U" : "_"); 829 test_bit(In_sync, &conf->mirrors[i].rdev->flags) ? "U" : "_");
830 seq_printf(seq, "]"); 830 seq_printf(seq, "]");
831} 831}
832 832
@@ -841,7 +841,7 @@ static void error(mddev_t *mddev, mdk_rdev_t *rdev)
841 * next level up know. 841 * next level up know.
842 * else mark the drive as failed 842 * else mark the drive as failed
843 */ 843 */
844 if (rdev->in_sync 844 if (test_bit(In_sync, &rdev->flags)
845 && conf->working_disks == 1) 845 && conf->working_disks == 1)
846 /* 846 /*
847 * Don't fail the drive, just return an IO error. 847 * Don't fail the drive, just return an IO error.
@@ -851,7 +851,7 @@ static void error(mddev_t *mddev, mdk_rdev_t *rdev)
851 * really dead" tests... 851 * really dead" tests...
852 */ 852 */
853 return; 853 return;
854 if (rdev->in_sync) { 854 if (test_bit(In_sync, &rdev->flags)) {
855 mddev->degraded++; 855 mddev->degraded++;
856 conf->working_disks--; 856 conf->working_disks--;
857 /* 857 /*
@@ -859,8 +859,8 @@ static void error(mddev_t *mddev, mdk_rdev_t *rdev)
859 */ 859 */
860 set_bit(MD_RECOVERY_ERR, &mddev->recovery); 860 set_bit(MD_RECOVERY_ERR, &mddev->recovery);
861 } 861 }
862 rdev->in_sync = 0; 862 clear_bit(In_sync, &rdev->flags);
863 rdev->faulty = 1; 863 set_bit(Faulty, &rdev->flags);
864 mddev->sb_dirty = 1; 864 mddev->sb_dirty = 1;
865 printk(KERN_ALERT "raid10: Disk failure on %s, disabling device. \n" 865 printk(KERN_ALERT "raid10: Disk failure on %s, disabling device. \n"
866 " Operation continuing on %d devices\n", 866 " Operation continuing on %d devices\n",
@@ -885,7 +885,8 @@ static void print_conf(conf_t *conf)
885 tmp = conf->mirrors + i; 885 tmp = conf->mirrors + i;
886 if (tmp->rdev) 886 if (tmp->rdev)
887 printk(" disk %d, wo:%d, o:%d, dev:%s\n", 887 printk(" disk %d, wo:%d, o:%d, dev:%s\n",
888 i, !tmp->rdev->in_sync, !tmp->rdev->faulty, 888 i, !test_bit(In_sync, &tmp->rdev->flags),
889 !test_bit(Faulty, &tmp->rdev->flags),
889 bdevname(tmp->rdev->bdev,b)); 890 bdevname(tmp->rdev->bdev,b));
890 } 891 }
891} 892}
@@ -938,11 +939,11 @@ static int raid10_spare_active(mddev_t *mddev)
938 for (i = 0; i < conf->raid_disks; i++) { 939 for (i = 0; i < conf->raid_disks; i++) {
939 tmp = conf->mirrors + i; 940 tmp = conf->mirrors + i;
940 if (tmp->rdev 941 if (tmp->rdev
941 && !tmp->rdev->faulty 942 && !test_bit(Faulty, &tmp->rdev->flags)
942 && !tmp->rdev->in_sync) { 943 && !test_bit(In_sync, &tmp->rdev->flags)) {
943 conf->working_disks++; 944 conf->working_disks++;
944 mddev->degraded--; 945 mddev->degraded--;
945 tmp->rdev->in_sync = 1; 946 set_bit(In_sync, &tmp->rdev->flags);
946 } 947 }
947 } 948 }
948 949
@@ -1000,7 +1001,7 @@ static int raid10_remove_disk(mddev_t *mddev, int number)
1000 print_conf(conf); 1001 print_conf(conf);
1001 rdev = p->rdev; 1002 rdev = p->rdev;
1002 if (rdev) { 1003 if (rdev) {
1003 if (rdev->in_sync || 1004 if (test_bit(In_sync, &rdev->flags) ||
1004 atomic_read(&rdev->nr_pending)) { 1005 atomic_read(&rdev->nr_pending)) {
1005 err = -EBUSY; 1006 err = -EBUSY;
1006 goto abort; 1007 goto abort;
@@ -1416,7 +1417,7 @@ static sector_t sync_request(mddev_t *mddev, sector_t sector_nr, int *skipped, i
1416 1417
1417 for (i=0 ; i<conf->raid_disks; i++) 1418 for (i=0 ; i<conf->raid_disks; i++)
1418 if (conf->mirrors[i].rdev && 1419 if (conf->mirrors[i].rdev &&
1419 !conf->mirrors[i].rdev->in_sync) { 1420 !test_bit(In_sync, &conf->mirrors[i].rdev->flags)) {
1420 /* want to reconstruct this device */ 1421 /* want to reconstruct this device */
1421 r10bio_t *rb2 = r10_bio; 1422 r10bio_t *rb2 = r10_bio;
1422 1423
@@ -1437,7 +1438,7 @@ static sector_t sync_request(mddev_t *mddev, sector_t sector_nr, int *skipped, i
1437 for (j=0; j<conf->copies;j++) { 1438 for (j=0; j<conf->copies;j++) {
1438 int d = r10_bio->devs[j].devnum; 1439 int d = r10_bio->devs[j].devnum;
1439 if (conf->mirrors[d].rdev && 1440 if (conf->mirrors[d].rdev &&
1440 conf->mirrors[d].rdev->in_sync) { 1441 test_bit(In_sync, &conf->mirrors[d].rdev->flags)) {
1441 /* This is where we read from */ 1442 /* This is where we read from */
1442 bio = r10_bio->devs[0].bio; 1443 bio = r10_bio->devs[0].bio;
1443 bio->bi_next = biolist; 1444 bio->bi_next = biolist;
@@ -1513,7 +1514,7 @@ static sector_t sync_request(mddev_t *mddev, sector_t sector_nr, int *skipped, i
1513 bio = r10_bio->devs[i].bio; 1514 bio = r10_bio->devs[i].bio;
1514 bio->bi_end_io = NULL; 1515 bio->bi_end_io = NULL;
1515 if (conf->mirrors[d].rdev == NULL || 1516 if (conf->mirrors[d].rdev == NULL ||
1516 conf->mirrors[d].rdev->faulty) 1517 test_bit(Faulty, &conf->mirrors[d].rdev->flags))
1517 continue; 1518 continue;
1518 atomic_inc(&conf->mirrors[d].rdev->nr_pending); 1519 atomic_inc(&conf->mirrors[d].rdev->nr_pending);
1519 atomic_inc(&r10_bio->remaining); 1520 atomic_inc(&r10_bio->remaining);
@@ -1699,7 +1700,7 @@ static int run(mddev_t *mddev)
1699 mddev->queue->max_sectors = (PAGE_SIZE>>9); 1700 mddev->queue->max_sectors = (PAGE_SIZE>>9);
1700 1701
1701 disk->head_position = 0; 1702 disk->head_position = 0;
1702 if (!rdev->faulty && rdev->in_sync) 1703 if (!test_bit(Faulty, &rdev->flags) && test_bit(In_sync, &rdev->flags))
1703 conf->working_disks++; 1704 conf->working_disks++;
1704 } 1705 }
1705 conf->raid_disks = mddev->raid_disks; 1706 conf->raid_disks = mddev->raid_disks;
diff --git a/drivers/md/raid5.c b/drivers/md/raid5.c
index 77610b98d4e0..d1c488b008af 100644
--- a/drivers/md/raid5.c
+++ b/drivers/md/raid5.c
@@ -525,19 +525,19 @@ static void error(mddev_t *mddev, mdk_rdev_t *rdev)
525 raid5_conf_t *conf = (raid5_conf_t *) mddev->private; 525 raid5_conf_t *conf = (raid5_conf_t *) mddev->private;
526 PRINTK("raid5: error called\n"); 526 PRINTK("raid5: error called\n");
527 527
528 if (!rdev->faulty) { 528 if (!test_bit(Faulty, &rdev->flags)) {
529 mddev->sb_dirty = 1; 529 mddev->sb_dirty = 1;
530 if (rdev->in_sync) { 530 if (test_bit(In_sync, &rdev->flags)) {
531 conf->working_disks--; 531 conf->working_disks--;
532 mddev->degraded++; 532 mddev->degraded++;
533 conf->failed_disks++; 533 conf->failed_disks++;
534 rdev->in_sync = 0; 534 clear_bit(In_sync, &rdev->flags);
535 /* 535 /*
536 * if recovery was running, make sure it aborts. 536 * if recovery was running, make sure it aborts.
537 */ 537 */
538 set_bit(MD_RECOVERY_ERR, &mddev->recovery); 538 set_bit(MD_RECOVERY_ERR, &mddev->recovery);
539 } 539 }
540 rdev->faulty = 1; 540 set_bit(Faulty, &rdev->flags);
541 printk (KERN_ALERT 541 printk (KERN_ALERT
542 "raid5: Disk failure on %s, disabling device." 542 "raid5: Disk failure on %s, disabling device."
543 " Operation continuing on %d devices\n", 543 " Operation continuing on %d devices\n",
@@ -1003,12 +1003,12 @@ static void handle_stripe(struct stripe_head *sh)
1003 } 1003 }
1004 if (dev->written) written++; 1004 if (dev->written) written++;
1005 rdev = conf->disks[i].rdev; /* FIXME, should I be looking rdev */ 1005 rdev = conf->disks[i].rdev; /* FIXME, should I be looking rdev */
1006 if (!rdev || !rdev->in_sync) { 1006 if (!rdev || !test_bit(In_sync, &rdev->flags)) {
1007 /* The ReadError flag wil just be confusing now */ 1007 /* The ReadError flag wil just be confusing now */
1008 clear_bit(R5_ReadError, &dev->flags); 1008 clear_bit(R5_ReadError, &dev->flags);
1009 clear_bit(R5_ReWrite, &dev->flags); 1009 clear_bit(R5_ReWrite, &dev->flags);
1010 } 1010 }
1011 if (!rdev || !rdev->in_sync 1011 if (!rdev || !test_bit(In_sync, &rdev->flags)
1012 || test_bit(R5_ReadError, &dev->flags)) { 1012 || test_bit(R5_ReadError, &dev->flags)) {
1013 failed++; 1013 failed++;
1014 failed_num = i; 1014 failed_num = i;
@@ -1027,7 +1027,7 @@ static void handle_stripe(struct stripe_head *sh)
1027 1027
1028 if (test_bit(R5_ReadError, &sh->dev[i].flags)) { 1028 if (test_bit(R5_ReadError, &sh->dev[i].flags)) {
1029 mdk_rdev_t *rdev = conf->disks[i].rdev; 1029 mdk_rdev_t *rdev = conf->disks[i].rdev;
1030 if (rdev && rdev->in_sync) 1030 if (rdev && test_bit(In_sync, &rdev->flags))
1031 /* multiple read failures in one stripe */ 1031 /* multiple read failures in one stripe */
1032 md_error(conf->mddev, rdev); 1032 md_error(conf->mddev, rdev);
1033 } 1033 }
@@ -1384,7 +1384,7 @@ static void handle_stripe(struct stripe_head *sh)
1384 1384
1385 rcu_read_lock(); 1385 rcu_read_lock();
1386 rdev = rcu_dereference(conf->disks[i].rdev); 1386 rdev = rcu_dereference(conf->disks[i].rdev);
1387 if (rdev && rdev->faulty) 1387 if (rdev && test_bit(Faulty, &rdev->flags))
1388 rdev = NULL; 1388 rdev = NULL;
1389 if (rdev) 1389 if (rdev)
1390 atomic_inc(&rdev->nr_pending); 1390 atomic_inc(&rdev->nr_pending);
@@ -1458,7 +1458,7 @@ static void unplug_slaves(mddev_t *mddev)
1458 rcu_read_lock(); 1458 rcu_read_lock();
1459 for (i=0; i<mddev->raid_disks; i++) { 1459 for (i=0; i<mddev->raid_disks; i++) {
1460 mdk_rdev_t *rdev = rcu_dereference(conf->disks[i].rdev); 1460 mdk_rdev_t *rdev = rcu_dereference(conf->disks[i].rdev);
1461 if (rdev && !rdev->faulty && atomic_read(&rdev->nr_pending)) { 1461 if (rdev && !test_bit(Faulty, &rdev->flags) && atomic_read(&rdev->nr_pending)) {
1462 request_queue_t *r_queue = bdev_get_queue(rdev->bdev); 1462 request_queue_t *r_queue = bdev_get_queue(rdev->bdev);
1463 1463
1464 atomic_inc(&rdev->nr_pending); 1464 atomic_inc(&rdev->nr_pending);
@@ -1503,7 +1503,7 @@ static int raid5_issue_flush(request_queue_t *q, struct gendisk *disk,
1503 rcu_read_lock(); 1503 rcu_read_lock();
1504 for (i=0; i<mddev->raid_disks && ret == 0; i++) { 1504 for (i=0; i<mddev->raid_disks && ret == 0; i++) {
1505 mdk_rdev_t *rdev = rcu_dereference(conf->disks[i].rdev); 1505 mdk_rdev_t *rdev = rcu_dereference(conf->disks[i].rdev);
1506 if (rdev && !rdev->faulty) { 1506 if (rdev && !test_bit(Faulty, &rdev->flags)) {
1507 struct block_device *bdev = rdev->bdev; 1507 struct block_device *bdev = rdev->bdev;
1508 request_queue_t *r_queue = bdev_get_queue(bdev); 1508 request_queue_t *r_queue = bdev_get_queue(bdev);
1509 1509
@@ -1850,7 +1850,7 @@ static int run(mddev_t *mddev)
1850 1850
1851 disk->rdev = rdev; 1851 disk->rdev = rdev;
1852 1852
1853 if (rdev->in_sync) { 1853 if (test_bit(In_sync, &rdev->flags)) {
1854 char b[BDEVNAME_SIZE]; 1854 char b[BDEVNAME_SIZE];
1855 printk(KERN_INFO "raid5: device %s operational as raid" 1855 printk(KERN_INFO "raid5: device %s operational as raid"
1856 " disk %d\n", bdevname(rdev->bdev,b), 1856 " disk %d\n", bdevname(rdev->bdev,b),
@@ -2029,7 +2029,7 @@ static void status (struct seq_file *seq, mddev_t *mddev)
2029 for (i = 0; i < conf->raid_disks; i++) 2029 for (i = 0; i < conf->raid_disks; i++)
2030 seq_printf (seq, "%s", 2030 seq_printf (seq, "%s",
2031 conf->disks[i].rdev && 2031 conf->disks[i].rdev &&
2032 conf->disks[i].rdev->in_sync ? "U" : "_"); 2032 test_bit(In_sync, &conf->disks[i].rdev->flags) ? "U" : "_");
2033 seq_printf (seq, "]"); 2033 seq_printf (seq, "]");
2034#if RAID5_DEBUG 2034#if RAID5_DEBUG
2035#define D(x) \ 2035#define D(x) \
@@ -2056,7 +2056,7 @@ static void print_raid5_conf (raid5_conf_t *conf)
2056 tmp = conf->disks + i; 2056 tmp = conf->disks + i;
2057 if (tmp->rdev) 2057 if (tmp->rdev)
2058 printk(" disk %d, o:%d, dev:%s\n", 2058 printk(" disk %d, o:%d, dev:%s\n",
2059 i, !tmp->rdev->faulty, 2059 i, !test_bit(Faulty, &tmp->rdev->flags),
2060 bdevname(tmp->rdev->bdev,b)); 2060 bdevname(tmp->rdev->bdev,b));
2061 } 2061 }
2062} 2062}
@@ -2070,12 +2070,12 @@ static int raid5_spare_active(mddev_t *mddev)
2070 for (i = 0; i < conf->raid_disks; i++) { 2070 for (i = 0; i < conf->raid_disks; i++) {
2071 tmp = conf->disks + i; 2071 tmp = conf->disks + i;
2072 if (tmp->rdev 2072 if (tmp->rdev
2073 && !tmp->rdev->faulty 2073 && !test_bit(Faulty, &tmp->rdev->flags)
2074 && !tmp->rdev->in_sync) { 2074 && !test_bit(In_sync, &tmp->rdev->flags)) {
2075 mddev->degraded--; 2075 mddev->degraded--;
2076 conf->failed_disks--; 2076 conf->failed_disks--;
2077 conf->working_disks++; 2077 conf->working_disks++;
2078 tmp->rdev->in_sync = 1; 2078 set_bit(In_sync, &tmp->rdev->flags);
2079 } 2079 }
2080 } 2080 }
2081 print_raid5_conf(conf); 2081 print_raid5_conf(conf);
@@ -2092,7 +2092,7 @@ static int raid5_remove_disk(mddev_t *mddev, int number)
2092 print_raid5_conf(conf); 2092 print_raid5_conf(conf);
2093 rdev = p->rdev; 2093 rdev = p->rdev;
2094 if (rdev) { 2094 if (rdev) {
2095 if (rdev->in_sync || 2095 if (test_bit(In_sync, &rdev->flags) ||
2096 atomic_read(&rdev->nr_pending)) { 2096 atomic_read(&rdev->nr_pending)) {
2097 err = -EBUSY; 2097 err = -EBUSY;
2098 goto abort; 2098 goto abort;
@@ -2127,7 +2127,7 @@ static int raid5_add_disk(mddev_t *mddev, mdk_rdev_t *rdev)
2127 */ 2127 */
2128 for (disk=0; disk < mddev->raid_disks; disk++) 2128 for (disk=0; disk < mddev->raid_disks; disk++)
2129 if ((p=conf->disks + disk)->rdev == NULL) { 2129 if ((p=conf->disks + disk)->rdev == NULL) {
2130 rdev->in_sync = 0; 2130 clear_bit(In_sync, &rdev->flags);
2131 rdev->raid_disk = disk; 2131 rdev->raid_disk = disk;
2132 found = 1; 2132 found = 1;
2133 if (rdev->saved_raid_disk != disk) 2133 if (rdev->saved_raid_disk != disk)
diff --git a/drivers/md/raid6main.c b/drivers/md/raid6main.c
index 84f3ee01e4c8..eae5a35629c5 100644
--- a/drivers/md/raid6main.c
+++ b/drivers/md/raid6main.c
@@ -507,19 +507,19 @@ static void error(mddev_t *mddev, mdk_rdev_t *rdev)
507 raid6_conf_t *conf = (raid6_conf_t *) mddev->private; 507 raid6_conf_t *conf = (raid6_conf_t *) mddev->private;
508 PRINTK("raid6: error called\n"); 508 PRINTK("raid6: error called\n");
509 509
510 if (!rdev->faulty) { 510 if (!test_bit(Faulty, &rdev->flags)) {
511 mddev->sb_dirty = 1; 511 mddev->sb_dirty = 1;
512 if (rdev->in_sync) { 512 if (test_bit(In_sync, &rdev->flags)) {
513 conf->working_disks--; 513 conf->working_disks--;
514 mddev->degraded++; 514 mddev->degraded++;
515 conf->failed_disks++; 515 conf->failed_disks++;
516 rdev->in_sync = 0; 516 clear_bit(In_sync, &rdev->flags);
517 /* 517 /*
518 * if recovery was running, make sure it aborts. 518 * if recovery was running, make sure it aborts.
519 */ 519 */
520 set_bit(MD_RECOVERY_ERR, &mddev->recovery); 520 set_bit(MD_RECOVERY_ERR, &mddev->recovery);
521 } 521 }
522 rdev->faulty = 1; 522 set_bit(Faulty, &rdev->flags);
523 printk (KERN_ALERT 523 printk (KERN_ALERT
524 "raid6: Disk failure on %s, disabling device." 524 "raid6: Disk failure on %s, disabling device."
525 " Operation continuing on %d devices\n", 525 " Operation continuing on %d devices\n",
@@ -1071,7 +1071,7 @@ static void handle_stripe(struct stripe_head *sh)
1071 } 1071 }
1072 if (dev->written) written++; 1072 if (dev->written) written++;
1073 rdev = conf->disks[i].rdev; /* FIXME, should I be looking rdev */ 1073 rdev = conf->disks[i].rdev; /* FIXME, should I be looking rdev */
1074 if (!rdev || !rdev->in_sync) { 1074 if (!rdev || !test_bit(In_sync, &rdev->flags)) {
1075 if ( failed < 2 ) 1075 if ( failed < 2 )
1076 failed_num[failed] = i; 1076 failed_num[failed] = i;
1077 failed++; 1077 failed++;
@@ -1465,7 +1465,7 @@ static void handle_stripe(struct stripe_head *sh)
1465 1465
1466 rcu_read_lock(); 1466 rcu_read_lock();
1467 rdev = rcu_dereference(conf->disks[i].rdev); 1467 rdev = rcu_dereference(conf->disks[i].rdev);
1468 if (rdev && rdev->faulty) 1468 if (rdev && test_bit(Faulty, &rdev->flags))
1469 rdev = NULL; 1469 rdev = NULL;
1470 if (rdev) 1470 if (rdev)
1471 atomic_inc(&rdev->nr_pending); 1471 atomic_inc(&rdev->nr_pending);
@@ -1539,7 +1539,7 @@ static void unplug_slaves(mddev_t *mddev)
1539 rcu_read_lock(); 1539 rcu_read_lock();
1540 for (i=0; i<mddev->raid_disks; i++) { 1540 for (i=0; i<mddev->raid_disks; i++) {
1541 mdk_rdev_t *rdev = rcu_dereference(conf->disks[i].rdev); 1541 mdk_rdev_t *rdev = rcu_dereference(conf->disks[i].rdev);
1542 if (rdev && !rdev->faulty && atomic_read(&rdev->nr_pending)) { 1542 if (rdev && !test_bit(Faulty, &rdev->flags) && atomic_read(&rdev->nr_pending)) {
1543 request_queue_t *r_queue = bdev_get_queue(rdev->bdev); 1543 request_queue_t *r_queue = bdev_get_queue(rdev->bdev);
1544 1544
1545 atomic_inc(&rdev->nr_pending); 1545 atomic_inc(&rdev->nr_pending);
@@ -1584,7 +1584,7 @@ static int raid6_issue_flush(request_queue_t *q, struct gendisk *disk,
1584 rcu_read_lock(); 1584 rcu_read_lock();
1585 for (i=0; i<mddev->raid_disks && ret == 0; i++) { 1585 for (i=0; i<mddev->raid_disks && ret == 0; i++) {
1586 mdk_rdev_t *rdev = rcu_dereference(conf->disks[i].rdev); 1586 mdk_rdev_t *rdev = rcu_dereference(conf->disks[i].rdev);
1587 if (rdev && !rdev->faulty) { 1587 if (rdev && !test_bit(Faulty, &rdev->flags)) {
1588 struct block_device *bdev = rdev->bdev; 1588 struct block_device *bdev = rdev->bdev;
1589 request_queue_t *r_queue = bdev_get_queue(bdev); 1589 request_queue_t *r_queue = bdev_get_queue(bdev);
1590 1590
@@ -1868,7 +1868,7 @@ static int run(mddev_t *mddev)
1868 1868
1869 disk->rdev = rdev; 1869 disk->rdev = rdev;
1870 1870
1871 if (rdev->in_sync) { 1871 if (test_bit(In_sync, &rdev->flags)) {
1872 char b[BDEVNAME_SIZE]; 1872 char b[BDEVNAME_SIZE];
1873 printk(KERN_INFO "raid6: device %s operational as raid" 1873 printk(KERN_INFO "raid6: device %s operational as raid"
1874 " disk %d\n", bdevname(rdev->bdev,b), 1874 " disk %d\n", bdevname(rdev->bdev,b),
@@ -2052,7 +2052,7 @@ static void status (struct seq_file *seq, mddev_t *mddev)
2052 for (i = 0; i < conf->raid_disks; i++) 2052 for (i = 0; i < conf->raid_disks; i++)
2053 seq_printf (seq, "%s", 2053 seq_printf (seq, "%s",
2054 conf->disks[i].rdev && 2054 conf->disks[i].rdev &&
2055 conf->disks[i].rdev->in_sync ? "U" : "_"); 2055 test_bit(In_sync, &conf->disks[i].rdev->flags) ? "U" : "_");
2056 seq_printf (seq, "]"); 2056 seq_printf (seq, "]");
2057#if RAID6_DUMPSTATE 2057#if RAID6_DUMPSTATE
2058 seq_printf (seq, "\n"); 2058 seq_printf (seq, "\n");
@@ -2078,7 +2078,7 @@ static void print_raid6_conf (raid6_conf_t *conf)
2078 tmp = conf->disks + i; 2078 tmp = conf->disks + i;
2079 if (tmp->rdev) 2079 if (tmp->rdev)
2080 printk(" disk %d, o:%d, dev:%s\n", 2080 printk(" disk %d, o:%d, dev:%s\n",
2081 i, !tmp->rdev->faulty, 2081 i, !test_bit(Faulty, &tmp->rdev->flags),
2082 bdevname(tmp->rdev->bdev,b)); 2082 bdevname(tmp->rdev->bdev,b));
2083 } 2083 }
2084} 2084}
@@ -2092,12 +2092,12 @@ static int raid6_spare_active(mddev_t *mddev)
2092 for (i = 0; i < conf->raid_disks; i++) { 2092 for (i = 0; i < conf->raid_disks; i++) {
2093 tmp = conf->disks + i; 2093 tmp = conf->disks + i;
2094 if (tmp->rdev 2094 if (tmp->rdev
2095 && !tmp->rdev->faulty 2095 && !test_bit(Faulty, &tmp->rdev->flags)
2096 && !tmp->rdev->in_sync) { 2096 && !test_bit(In_sync, &tmp->rdev->flags)) {
2097 mddev->degraded--; 2097 mddev->degraded--;
2098 conf->failed_disks--; 2098 conf->failed_disks--;
2099 conf->working_disks++; 2099 conf->working_disks++;
2100 tmp->rdev->in_sync = 1; 2100 set_bit(In_sync, &tmp->rdev->flags);
2101 } 2101 }
2102 } 2102 }
2103 print_raid6_conf(conf); 2103 print_raid6_conf(conf);
@@ -2114,7 +2114,7 @@ static int raid6_remove_disk(mddev_t *mddev, int number)
2114 print_raid6_conf(conf); 2114 print_raid6_conf(conf);
2115 rdev = p->rdev; 2115 rdev = p->rdev;
2116 if (rdev) { 2116 if (rdev) {
2117 if (rdev->in_sync || 2117 if (test_bit(In_sync, &rdev->flags) ||
2118 atomic_read(&rdev->nr_pending)) { 2118 atomic_read(&rdev->nr_pending)) {
2119 err = -EBUSY; 2119 err = -EBUSY;
2120 goto abort; 2120 goto abort;
@@ -2149,7 +2149,7 @@ static int raid6_add_disk(mddev_t *mddev, mdk_rdev_t *rdev)
2149 */ 2149 */
2150 for (disk=0; disk < mddev->raid_disks; disk++) 2150 for (disk=0; disk < mddev->raid_disks; disk++)
2151 if ((p=conf->disks + disk)->rdev == NULL) { 2151 if ((p=conf->disks + disk)->rdev == NULL) {
2152 rdev->in_sync = 0; 2152 clear_bit(In_sync, &rdev->flags);
2153 rdev->raid_disk = disk; 2153 rdev->raid_disk = disk;
2154 found = 1; 2154 found = 1;
2155 if (rdev->saved_raid_disk != disk) 2155 if (rdev->saved_raid_disk != disk)