Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

[PATCH] md: Remove working_disks from raid1 state data

It is equivalent to conf->raid_disks - conf->mddev->degraded.

Signed-off-by: Neil Brown <neilb@suse.de>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>

authored by

NeilBrown and committed by
Linus Torvalds
11ce99e6 867868fb

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