diff options
-rw-r--r-- | drivers/md/raid1.c | 28 | ||||
-rw-r--r-- | include/linux/raid/raid1.h | 1 |
2 files changed, 12 insertions, 17 deletions
diff --git a/drivers/md/raid1.c b/drivers/md/raid1.c index 13b59e6a6acb..3fc9ec239478 100644 --- a/drivers/md/raid1.c +++ b/drivers/md/raid1.c | |||
@@ -271,7 +271,7 @@ static int raid1_end_read_request(struct bio *bio, unsigned int bytes_done, int | |||
271 | */ | 271 | */ |
272 | update_head_pos(mirror, r1_bio); | 272 | update_head_pos(mirror, r1_bio); |
273 | 273 | ||
274 | if (uptodate || conf->working_disks <= 1) { | 274 | if (uptodate || (conf->raid_disks - conf->mddev->degraded) <= 1) { |
275 | /* | 275 | /* |
276 | * Set R1BIO_Uptodate in our master bio, so that | 276 | * Set R1BIO_Uptodate in our master bio, so that |
277 | * we will return a good error code for to the higher | 277 | * we will return a good error code for to the higher |
@@ -929,7 +929,7 @@ static void status(struct seq_file *seq, mddev_t *mddev) | |||
929 | int i; | 929 | int i; |
930 | 930 | ||
931 | seq_printf(seq, " [%d/%d] [", conf->raid_disks, | 931 | seq_printf(seq, " [%d/%d] [", conf->raid_disks, |
932 | conf->working_disks); | 932 | conf->raid_disks - mddev->degraded); |
933 | rcu_read_lock(); | 933 | rcu_read_lock(); |
934 | for (i = 0; i < conf->raid_disks; i++) { | 934 | for (i = 0; i < conf->raid_disks; i++) { |
935 | mdk_rdev_t *rdev = rcu_dereference(conf->mirrors[i].rdev); | 935 | mdk_rdev_t *rdev = rcu_dereference(conf->mirrors[i].rdev); |
@@ -953,7 +953,7 @@ static void error(mddev_t *mddev, mdk_rdev_t *rdev) | |||
953 | * else mark the drive as failed | 953 | * else mark the drive as failed |
954 | */ | 954 | */ |
955 | if (test_bit(In_sync, &rdev->flags) | 955 | if (test_bit(In_sync, &rdev->flags) |
956 | && conf->working_disks == 1) | 956 | && (conf->raid_disks - mddev->degraded) == 1) |
957 | /* | 957 | /* |
958 | * Don't fail the drive, act as though we were just a | 958 | * Don't fail the drive, act as though we were just a |
959 | * normal single drive | 959 | * normal single drive |
@@ -961,7 +961,6 @@ static void error(mddev_t *mddev, mdk_rdev_t *rdev) | |||
961 | return; | 961 | return; |
962 | if (test_bit(In_sync, &rdev->flags)) { | 962 | if (test_bit(In_sync, &rdev->flags)) { |
963 | mddev->degraded++; | 963 | mddev->degraded++; |
964 | conf->working_disks--; | ||
965 | /* | 964 | /* |
966 | * if recovery is running, make sure it aborts. | 965 | * if recovery is running, make sure it aborts. |
967 | */ | 966 | */ |
@@ -972,7 +971,7 @@ static void error(mddev_t *mddev, mdk_rdev_t *rdev) | |||
972 | set_bit(MD_CHANGE_DEVS, &mddev->flags); | 971 | set_bit(MD_CHANGE_DEVS, &mddev->flags); |
973 | printk(KERN_ALERT "raid1: Disk failure on %s, disabling device. \n" | 972 | printk(KERN_ALERT "raid1: Disk failure on %s, disabling device. \n" |
974 | " Operation continuing on %d devices\n", | 973 | " Operation continuing on %d devices\n", |
975 | bdevname(rdev->bdev,b), conf->working_disks); | 974 | bdevname(rdev->bdev,b), conf->raid_disks - mddev->degraded); |
976 | } | 975 | } |
977 | 976 | ||
978 | static void print_conf(conf_t *conf) | 977 | static void print_conf(conf_t *conf) |
@@ -984,7 +983,7 @@ static void print_conf(conf_t *conf) | |||
984 | printk("(!conf)\n"); | 983 | printk("(!conf)\n"); |
985 | return; | 984 | return; |
986 | } | 985 | } |
987 | printk(" --- wd:%d rd:%d\n", conf->working_disks, | 986 | printk(" --- wd:%d rd:%d\n", conf->raid_disks - conf->mddev->degraded, |
988 | conf->raid_disks); | 987 | conf->raid_disks); |
989 | 988 | ||
990 | rcu_read_lock(); | 989 | rcu_read_lock(); |
@@ -1024,7 +1023,6 @@ static int raid1_spare_active(mddev_t *mddev) | |||
1024 | if (rdev | 1023 | if (rdev |
1025 | && !test_bit(Faulty, &rdev->flags) | 1024 | && !test_bit(Faulty, &rdev->flags) |
1026 | && !test_bit(In_sync, &rdev->flags)) { | 1025 | && !test_bit(In_sync, &rdev->flags)) { |
1027 | conf->working_disks++; | ||
1028 | mddev->degraded--; | 1026 | mddev->degraded--; |
1029 | set_bit(In_sync, &rdev->flags); | 1027 | set_bit(In_sync, &rdev->flags); |
1030 | } | 1028 | } |
@@ -1901,15 +1899,11 @@ static int run(mddev_t *mddev) | |||
1901 | blk_queue_max_sectors(mddev->queue, PAGE_SIZE>>9); | 1899 | blk_queue_max_sectors(mddev->queue, PAGE_SIZE>>9); |
1902 | 1900 | ||
1903 | disk->head_position = 0; | 1901 | disk->head_position = 0; |
1904 | if (!test_bit(Faulty, &rdev->flags) && test_bit(In_sync, &rdev->flags)) | ||
1905 | conf->working_disks++; | ||
1906 | } | 1902 | } |
1907 | conf->raid_disks = mddev->raid_disks; | 1903 | conf->raid_disks = mddev->raid_disks; |
1908 | conf->mddev = mddev; | 1904 | conf->mddev = mddev; |
1909 | spin_lock_init(&conf->device_lock); | 1905 | spin_lock_init(&conf->device_lock); |
1910 | INIT_LIST_HEAD(&conf->retry_list); | 1906 | INIT_LIST_HEAD(&conf->retry_list); |
1911 | if (conf->working_disks == 1) | ||
1912 | mddev->recovery_cp = MaxSector; | ||
1913 | 1907 | ||
1914 | spin_lock_init(&conf->resync_lock); | 1908 | spin_lock_init(&conf->resync_lock); |
1915 | init_waitqueue_head(&conf->wait_barrier); | 1909 | init_waitqueue_head(&conf->wait_barrier); |
@@ -1917,11 +1911,6 @@ static int run(mddev_t *mddev) | |||
1917 | bio_list_init(&conf->pending_bio_list); | 1911 | bio_list_init(&conf->pending_bio_list); |
1918 | bio_list_init(&conf->flushing_bio_list); | 1912 | bio_list_init(&conf->flushing_bio_list); |
1919 | 1913 | ||
1920 | if (!conf->working_disks) { | ||
1921 | printk(KERN_ERR "raid1: no operational mirrors for %s\n", | ||
1922 | mdname(mddev)); | ||
1923 | goto out_free_conf; | ||
1924 | } | ||
1925 | 1914 | ||
1926 | mddev->degraded = 0; | 1915 | mddev->degraded = 0; |
1927 | for (i = 0; i < conf->raid_disks; i++) { | 1916 | for (i = 0; i < conf->raid_disks; i++) { |
@@ -1934,6 +1923,13 @@ static int run(mddev_t *mddev) | |||
1934 | mddev->degraded++; | 1923 | mddev->degraded++; |
1935 | } | 1924 | } |
1936 | } | 1925 | } |
1926 | if (mddev->degraded == conf->raid_disks) { | ||
1927 | printk(KERN_ERR "raid1: no operational mirrors for %s\n", | ||
1928 | mdname(mddev)); | ||
1929 | goto out_free_conf; | ||
1930 | } | ||
1931 | if (conf->raid_disks - mddev->degraded == 1) | ||
1932 | mddev->recovery_cp = MaxSector; | ||
1937 | 1933 | ||
1938 | /* | 1934 | /* |
1939 | * find the first working one and use it as a starting point | 1935 | * find the first working one and use it as a starting point |
diff --git a/include/linux/raid/raid1.h b/include/linux/raid/raid1.h index 3009c813d83d..0a9ba7c3302e 100644 --- a/include/linux/raid/raid1.h +++ b/include/linux/raid/raid1.h | |||
@@ -30,7 +30,6 @@ struct r1_private_data_s { | |||
30 | mddev_t *mddev; | 30 | mddev_t *mddev; |
31 | mirror_info_t *mirrors; | 31 | mirror_info_t *mirrors; |
32 | int raid_disks; | 32 | int raid_disks; |
33 | int working_disks; | ||
34 | int last_used; | 33 | int last_used; |
35 | sector_t next_seq_sect; | 34 | sector_t next_seq_sect; |
36 | spinlock_t device_lock; | 35 | spinlock_t device_lock; |