Hi,

While testing raid1 (raidsetfaulty, raidhotremove, raidhotadd, repeat),
I managed to get one raid set in a state where nr_disks was incorrect.
This became a problem when trying to use lilo, because it would only write
to one of the disks (since nr_disks was 1).

With one disk in the set nr_disks was 0:

Aug  2 13:15:00 hotbox kernel: RAID1 conf printout: 
Aug  2 13:15:00 hotbox kernel:  --- wd:1 rd:2 nd:0 
Aug  2 13:15:00 hotbox kernel:  disk 0, s:0, o:0, n:0 rd:0 us:0 dev:[dev 00:00] 
Aug  2 13:15:00 hotbox kernel:  disk 1, s:0, o:1, n:1 rd:1 us:1 dev:sda1 
Aug  2 13:15:00 hotbox kernel:  disk 2, s:0, o:0, n:0 rd:0 us:0 dev:[dev 00:00] 
Aug  2 13:15:00 hotbox kernel:  disk 3, s:0, o:0, n:0 rd:0 us:0 dev:[dev 00:00] 

After adding a disk nr_disks was 1:

Aug  2 13:15:01 hotbox kernel: RAID1 conf printout: 
Aug  2 13:15:01 hotbox kernel:  --- wd:1 rd:2 nd:1 
Aug  2 13:15:01 hotbox kernel:  disk 0, s:0, o:0, n:0 rd:0 us:0 dev:[dev 00:00] 
Aug  2 13:15:01 hotbox kernel:  disk 1, s:0, o:1, n:1 rd:1 us:1 dev:sda1 
Aug  2 13:15:01 hotbox kernel:  disk 2, s:1, o:0, n:2 rd:2 us:1 dev:sdb1 
Aug  2 13:15:01 hotbox kernel:  disk 3, s:0, o:0, n:0 rd:0 us:0 dev:[dev 00:00] 

I wrote the following hack so it would fix this.

Anton


--- linux/drivers/block/raid1.c Thu Jul 27 12:47:48 2000
+++ ../linux-2.4.0-test4-pre4/drivers/block/raid1.c     Wed Aug  2 13:43:46 2000
@@ -1690,8 +1692,14 @@
                        disk->head_position = 0;
                }
        }
+
+       if (sb->raid_disks > sb->nr_disks)
+               sb->nr_disks = sb->raid_disks;
+
        conf->raid_disks = sb->raid_disks;
        conf->nr_disks = sb->nr_disks;

Reply via email to