From mboxrd@z Thu Jan 1 00:00:00 1970 From: Neil Brown Subject: Re: RAID-1 does not rebuild after hot-add Date: Tue, 5 Aug 2003 16:53:03 +1000 Sender: linux-raid-owner@vger.kernel.org Message-ID: <16175.21583.621336.653083@gargle.gargle.HOWL> References: <3F2D1FAC.9030905@shaolinmicro.com> <16173.43804.617586.906225@gargle.gargle.HOWL> <3F2E8CAE.7090208@shaolinmicro.com> <16175.4992.765886.291774@gargle.gargle.HOWL> <3F2F4F7F.6010801@shaolinmicro.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: message from David Chow on Tuesday August 5 To: David Chow Cc: linux-raid@vger.kernel.org List-Id: linux-raid.ids On Tuesday August 5, davidchow@shaolinmicro.com wrote: > > > > > >Rather than a hex dump, just use > > > > mdadm --examine /dev/XXX > > > >That is the easiest way to view the superblock on the device. > > > >NeilBrown > > > Neil, > > OK, I find out there is a problem in the superblock which is descrbed as > follows. The "Total Devices" is wrong. It should be 2 instead of 3. This > is probably a bug of the mkraid (from raidtools) which when I created > the array with a "failed-disk" in degraded mode. mkraid incorrectly made > a wrong superblock even I put "nr-raid-disk 2" and "nr-spare-disks 0" in > the raidtab. Ok, the superblock is incorrect, but how can I change the > total devices and spare device pramaters without re-initialize the > array? It is actuallt "Active Devices" that is the problem. As this is the same as "Raid Devices", it doesn't bother doing a reconstruction. The following patch adds --update=summaries to mdadm-1.3.0, which updates the various summary fields in the superblock (Total, Active, Working, Failed, Spare - Devices). It is untested but should work. If you patch mdadm-1.3.0 and compile it, then mdadm --assemble /dev/md2 --update=summaries /dev/sda3 /dev/sdb3 then it should update these fields and start the array (you might need a --run as well). Let me know how it goes. NeilBrown ----------- Diffstat output ------------ ./Assemble.c | 25 +++++++++++++++++++++++++ ./ReadMe.c | 4 ++-- ./mdadm.c | 4 +++- 3 files changed, 30 insertions(+), 3 deletions(-) diff ./Assemble.c~current~ ./Assemble.c --- ./Assemble.c~current~ 2003-08-05 16:40:07.000000000 +1000 +++ ./Assemble.c 2003-08-05 16:49:00.000000000 +1000 @@ -292,6 +292,31 @@ int Assemble(char *mddev, int mdfd, fprintf(stderr, Name ": updating superblock of %s with minor number %d\n", devname, super.md_minor); } + if (strcmp(update, "summaries") == 0) { + /* set nr_disks, active_disks, working_disks, + * failed_disks, spare_disks based on disks[] + * array in superblock + */ + super.nr_disks = super.active_disks = + super.working_disks = super.failed_disks = + super.spare_disks = 0; + for (i=0; MD_SB_DISKS ; i++) + if (super.disks[i].major || + super.disks[i].minor) { + int state = super.disks[i].state; + if (state & (1<