]> git.ipfire.org Git - thirdparty/mdadm.git/log
thirdparty/mdadm.git
15 years agoMove recently merged /sys/dev/ lookup into stat2devnum.
NeilBrown [Mon, 3 Nov 2008 23:35:08 +0000 (10:35 +1100)] 
Move recently merged /sys/dev/ lookup into stat2devnum.

But sysfs_init and stat2devnum try to convert stat information
into an md devnum.  Combine all the value of both pieces of code
into stat2devnum and have sysfs_init call that.

Signed-off-by: NeilBrown <neilb@suse.de>
15 years agocleanup an unused call to container2devname
Dan Williams [Mon, 3 Nov 2008 23:34:53 +0000 (10:34 +1100)] 
cleanup an unused call to container2devname

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
15 years agoMerge branch 'master' into scratch-3.0
NeilBrown [Sun, 2 Nov 2008 20:20:54 +0000 (07:20 +1100)] 
Merge branch 'master' into scratch-3.0

15 years agomapfile: fix bug in testing for /var/run/mdadm/
NeilBrown [Sun, 2 Nov 2008 20:19:37 +0000 (07:19 +1100)] 
mapfile:  fix bug in testing for /var/run/mdadm/

There was a bug.  If /var/run/mdadm/ did not exist as a directory,
the map file should have been created in /var/run/mdadm.map, but
due to bug it would never get created.

Signed-off-by: NeilBrown <neilb@suse.de>
15 years agoMerge branch 'master' into scratch-3.0
NeilBrown [Sun, 2 Nov 2008 19:40:12 +0000 (06:40 +1100)] 
Merge branch 'master' into scratch-3.0

15 years agoIncremental: change precedence order for autof setting.
NeilBrown [Sun, 2 Nov 2008 19:39:02 +0000 (06:39 +1100)] 
Incremental:  change precedence order for autof setting.

It doesn't really make sense for the --auto setting to ever over-ride
the setting on an ARRAY line.  That could cause failure if the
ARRAY line has a 'standard' now.  So revert to the array line having
precedence over command line, then CREATE line last.

Signed-off-by: NeilBrown <neilb@suse.de>
15 years agoMerge branch 'master' into devel-3.0
NeilBrown [Thu, 30 Oct 2008 06:02:49 +0000 (17:02 +1100)] 
Merge branch 'master' into devel-3.0

15 years agoAdjust major number testing to allow for extended minor number in 2.6.28
NeilBrown [Thu, 30 Oct 2008 05:37:29 +0000 (16:37 +1100)] 
Adjust major number testing to allow for extended minor number in 2.6.28

From 2.6.28, normal md device will be able to have partitions.  These
partitions will have a different major number.  Sometimes mdadm tests
the major number and so can get confused.
Change these tests to test against get_mdp_major().  mdp does not use
extended minor number and so this test will always be accurate.

Also use /sys/dev links to map major/minor to devnum in sysfs.

Signed-off-by: NeilBrown <neilb@suse.de>
15 years agoMerge branch 'master' into devel-3.0
NeilBrown [Thu, 30 Oct 2008 02:59:11 +0000 (13:59 +1100)] 
Merge branch 'master' into devel-3.0

Conflicts:

Incremental.c
super0.c
super1.c

15 years agoIncremental: allow assembly of foreign array.
NeilBrown [Wed, 29 Oct 2008 22:48:18 +0000 (09:48 +1100)] 
Incremental:  allow assembly of foreign array.

If a foreign (i.e. not known to be local) array is discovered
by --incremental assembly, we now assemble it.  However we ignore
any name information in the array so as not to potentially create
a name that conflict with a 'local' array.
Also, foreign arrays are always assembled 'read-auto' to avoid writing
anything until the array is actually used.

Signed-off-by: NeilBrown <neilb@suse.de>
15 years agoIncremental: fix setting of 'autof' flag.
NeilBrown [Wed, 29 Oct 2008 22:34:06 +0000 (09:34 +1100)] 
Incremental:  fix setting of 'autof' flag.

When doing auto-assembly, the 'autof' flag from array lines
in mdadm.conf was being ignored.

Signed-off-by: NeilBrown <neilb@suse.de>
15 years agoFix --incremental assembly of partitions arrays.
NeilBrown [Wed, 29 Oct 2008 22:34:04 +0000 (09:34 +1100)] 
Fix --incremental assembly of partitions arrays.

If incremental assembly finds an array mentioned in mdadm.conf,
with a 'standard partitioned' name like /dev/md_d0 or /dev/md/d0,
it will not create a partitioned array like it should.
This is because it mishandled the 'devnum' returned by
is_standard.
That is a devnum that does not have the partition-or-not encoded
into it.  So we need to check the actual return value of
is_standard and encode the partition-or-not info into the devnum.

Also fix a couple of comments.

Signed-off-by: NeilBrown <neilb@suse.de>
15 years agoFix NULL pointer oops
Doug Ledford [Wed, 29 Oct 2008 19:05:36 +0000 (15:05 -0400)] 
Fix NULL pointer oops

RAID10 is the only raid level that uses the avail char array pointer
during the enough() operation, so it was the only one that saw this.
The code in incremental assumes unconditionally that count_active will
allocate the avail char array, that it might be used by enough, and that
it will need to be freed afterward.  Once you make count_active actually
do that, then the oops goes away.

Signed-off-by: Doug Ledford <dledford@redhat.com>
Signed-off-by: NeilBrown <neilb@suse.de>
15 years agoFix bad metadata formatting
Doug Ledford [Wed, 29 Oct 2008 19:05:35 +0000 (15:05 -0400)] 
Fix bad metadata formatting

Certain operations (Detail.c mainly) would print out the metadata of
an array in a format that the scan operation in super0.c and super1.c
would later reject as unknown when it was found in the mdadm.conf file.
Use a consistent format, but also modify the super0 and super1 match
methods to accept the other format without complaint.

Signed-off-by: Doug Ledford <dledford@redhat.com>
Signed-off-by: NeilBrown <neilb@suse.de>
15 years agoPreliminary -As support for container member arrays
Dan Williams [Tue, 28 Oct 2008 17:55:31 +0000 (10:55 -0700)] 
Preliminary -As support for container member arrays

Given an mdadm.conf like the following allow /dev/imsm and /dev/md/r1 to be
created by "mdadm -As".

DEVICES partitions
ARRAY /dev/imsm metadata=imsm auto=md UUID=b98f5dbe-aa859e7b-0e369b89-a80986d4
ARRAY /dev/md/r1 container=/dev/imsm member=0 auto=mdp UUID=3538e39c-b397c2e9-1aa031f9-2bc0eca4
   spares=1

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
15 years agoimsm: include members in ->brief_examine
Dan Williams [Tue, 28 Oct 2008 17:55:31 +0000 (10:55 -0700)] 
imsm: include members in ->brief_examine

A prerquisite for getting imsm arrays assembled by mdadm -As.

15 years agoimsm: copy raid device info when associating spares
Dan Williams [Tue, 28 Oct 2008 17:55:31 +0000 (10:55 -0700)] 
imsm: copy raid device info when associating spares

If a spare is included in the list of examined disks we need to copy in at
least enough information to get the uuid of the populated container.

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
15 years agoimsm: return associated uuid for spares
Dan Williams [Tue, 28 Oct 2008 17:55:31 +0000 (10:55 -0700)] 
imsm: return associated uuid for spares

This prevents a uuid of all f's from being displayed when an imsm spare is
listed along with active disks for mdadm -Eb.

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
15 years agoExamine: fix MD_DISK_SYNC is a bit not a flag
Dan Williams [Tue, 28 Oct 2008 17:55:31 +0000 (10:55 -0700)] 
Examine: fix MD_DISK_SYNC is a bit not a flag

Examine() is actually looking at the ACTIVE bit.  This happened to work for
imsm spares but now it needs to be fixed up.

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
15 years agoimsm: update metadata immediately on "add spare" events
Dan Williams [Tue, 28 Oct 2008 17:55:31 +0000 (10:55 -0700)] 
imsm: update metadata immediately on "add spare" events

...without this the spare record is delayed until the next metadata
event.

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
15 years agoupdate copyright headers
Dan Williams [Tue, 28 Oct 2008 17:55:29 +0000 (10:55 -0700)] 
update copyright headers

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
15 years agoMerge branch 'master' into devel-3.0
NeilBrown [Sun, 26 Oct 2008 23:10:08 +0000 (10:10 +1100)] 
Merge branch 'master' into devel-3.0

Conflicts:

Create.c
Manage.c

15 years agoddf: get endian-ness of CRC correct.
NeilBrown [Sun, 26 Oct 2008 23:04:46 +0000 (10:04 +1100)] 
ddf: get endian-ness of CRC correct.

All numeric fields in a DDF header big-endian, including the CRC, so
better fix that.

Signed-off-by: NeilBrown <neilb@suse.de>
15 years agoMakefile: Include bitmap.o in mdmon
NeilBrown [Sun, 26 Oct 2008 22:57:30 +0000 (09:57 +1100)] 
Makefile: Include bitmap.o in mdmon

A recent change causes mdmon to appear to need 'bitmap_sectors', which
is in bitmap.o.

Signed-off-by: NeilBrown <neilb@suse.de>
15 years agoAllow WRITEMOSTLY to be cleared on --readd using --readwrite.
NeilBrown [Sat, 25 Oct 2008 07:20:49 +0000 (18:20 +1100)] 
Allow WRITEMOSTLY to be cleared on --readd using --readwrite.

Previously it was possible to set the WRITEMOSTLY flag when
adding a device to an array, but not to clear the flag when re-adding.
This is now possible with --readwrite.

Signed-off-by: NeilBrown <neilb@suse.de>
15 years agoMerge branch 'master' into devel-3.0
NeilBrown [Fri, 17 Oct 2008 01:46:23 +0000 (12:46 +1100)] 
Merge branch 'master' into devel-3.0

Conflicts:

Manage.c

15 years agoRemove .UR .UE macros from man page because the don't do what we want.
NeilBrown [Fri, 17 Oct 2008 00:52:38 +0000 (11:52 +1100)] 
Remove .UR .UE macros from man page because the don't do what we want.

.UR URL
text
.UE

is meant to create a hyperlink from the 'text' to the 'URL'.
But I wanted just to have the URL, so UR isn't really the right
tool - the URL gets displayed twice.

So just display the URL in bold and assume man2html etc can recognise
it and do the right thing.

Signed-off-by: NeilBrown <neilb@suse.de>
15 years agomdmon: suicide prevention
Dan Williams [Fri, 3 Oct 2008 05:26:00 +0000 (22:26 -0700)] 
mdmon: suicide prevention

mdmon cannot remove the pidfile at shutdown becuase it needs to stay
running across the "mount -o remount,ro /" event.  When it relaunches
after a reboot there is a good chance that the pid will match what was
there previously.  The result is that the "take over for unresponsive
mdmon" logic results in self termination.

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
15 years agoquiet WaitClean()
Dan Williams [Thu, 2 Oct 2008 23:07:21 +0000 (16:07 -0700)] 
quiet WaitClean()

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
15 years agomdmon: --switch-root
Dan Williams [Thu, 2 Oct 2008 22:50:23 +0000 (15:50 -0700)] 
mdmon: --switch-root

For raid rootfs we cannot run the array unmonitored for any length of
time.  At least XFS will not mount/replay the journal if the underlying
block device is readonly (FIXME it also seems that XFS does not always
honor the ro status of the backing device as I was able to hit the
BUG_ON(mddev->ro == 1) in md_write_start... but I digress).

So we need to start mdmon in the initramfs before '/' is mounted and
then restart it after the real rootfs is available.  Upon seeing the
--switch-root option, mdmon will kill any victims in the current
/var/run/mdadm directory and then chroot(2) before continuing.

The option is deliberately called 'switch-root' instead of 'chroot' to
hopefully indicate that this is different than doing "chroot mdmon
/dev/imsm".

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
15 years agomdmon: wait after trying to kill
Dan Williams [Thu, 2 Oct 2008 22:42:57 +0000 (15:42 -0700)] 
mdmon: wait after trying to kill

Now that mdmon handles sigterm if another monitor wants to take over it
should wait until all managed arrays are clean.  So make WaitClean()
available to mdmon and teach try_kill_monitor() to wait on each subarray
in the container.

...since we may be communicating with a dieing process, we need to
block SIGPIPE earlier.

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
15 years agomdmon: terminate clean
Dan Williams [Thu, 2 Oct 2008 13:32:08 +0000 (06:32 -0700)] 
mdmon: terminate clean

We generally don't want mdmon to be terminated, but if a SIGTERM gets
through try to leave the monitored arrays in a clean state, block
attempts to mark the array dirty, and stop servicing the socket.

When we are killed by sigterm don't remove the pidfile let that be
cleaned up by the next monitor.

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
15 years agoTreat all devices at the container level as spares
Dan Williams [Thu, 2 Oct 2008 01:50:44 +0000 (18:50 -0700)] 
Treat all devices at the container level as spares

Raid disk and disk number information is not relevant at the container
level, especially for imsm.  So arrange for getinfo_super_imsm() to
always publish devices as spares and report the number of spares at
Assemble() time.

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
15 years agoAllow a uuid of all f's to always match
Dan Williams [Thu, 2 Oct 2008 01:50:44 +0000 (18:50 -0700)] 
Allow a uuid of all f's to always match

The uuid returned for an imsm spare device will never match the uuid of an
active disk.  So make mdadm interpret a uuid of all f's as "match any".

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
15 years agoimsm: show uuid in ->examine_super()
Dan Williams [Thu, 2 Oct 2008 01:50:43 +0000 (18:50 -0700)] 
imsm: show uuid in ->examine_super()

...and add "auto=md" to the brief output.

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
15 years agofname_as_uuid: print uuids msb first
Dan Williams [Thu, 2 Oct 2008 01:50:43 +0000 (18:50 -0700)] 
fname_as_uuid: print uuids msb first

The sha1 routines store the uuids in little endian byte-order, so always
print from msb to lsb. This allows imsm containers to be assembled with
-As.

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
15 years agomdmon: periodically retry to create the socket
Dan Williams [Thu, 2 Oct 2008 01:50:43 +0000 (18:50 -0700)] 
mdmon: periodically retry to create the socket

If initial socket creation fails, EROFS, set a periodic alarm to wake up
the manager and retry.  Include a kernel patch that will wake us up if
the mount flags are changed.

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
15 years agosysfs_open leaks devnum2devname() result
Dan Williams [Thu, 2 Oct 2008 01:49:53 +0000 (18:49 -0700)] 
sysfs_open leaks devnum2devname() result

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
15 years agonon-trivial warn_unused_result fix, prepare_update
Dan Williams [Sun, 28 Sep 2008 19:12:08 +0000 (12:12 -0700)] 
non-trivial warn_unused_result fix, prepare_update

If an allocation fails in ->prepare_update we need to catch it in
->process_update.

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
15 years agonon-trivial warn_unused_result fixes, activate_spare
Dan Williams [Sun, 28 Sep 2008 19:12:08 +0000 (12:12 -0700)] 
non-trivial warn_unused_result fixes, activate_spare

Both super-ddf and super-intel ignore memory allocation failures during
->activate_spare.  Fix these up by cancelling the activation.

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
15 years agonon-trivial warn_unused_result fixes, write_init_super_ddf
Dan Williams [Sun, 28 Sep 2008 19:12:08 +0000 (12:12 -0700)] 
non-trivial warn_unused_result fixes, write_init_super_ddf

When a write fails just move on to the next disk.

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
15 years agotrivial warn_unused_result squashing
Dan Williams [Sun, 28 Sep 2008 19:12:07 +0000 (12:12 -0700)] 
trivial warn_unused_result squashing

Made the mistake of recompiling the F9 mdadm rpm which has a patch to
remove -Werror and add "-Wp,-D_FORTIFY_SOURCE -O2" which turns on lots
of errors:

config.c:568: warning: ignoring return value of asprintf
Assemble.c:411: warning: ignoring return value of asprintf
Assemble.c:413: warning: ignoring return value of asprintf
super0.c:549: warning: ignoring return value of posix_memalign
super0.c:742: warning: ignoring return value of posix_memalign
super0.c:812: warning: ignoring return value of posix_memalign
super1.c:692: warning: ignoring return value of posix_memalign
super1.c:1039: warning: ignoring return value of posix_memalign
super1.c:1155: warning: ignoring return value of posix_memalign
super-ddf.c:508: warning: ignoring return value of posix_memalign
super-ddf.c:645: warning: ignoring return value of posix_memalign
super-ddf.c:696: warning: ignoring return value of posix_memalign
super-ddf.c:715: warning: ignoring return value of posix_memalign
super-ddf.c:1476: warning: ignoring return value of posix_memalign
super-ddf.c:1603: warning: ignoring return value of posix_memalign
super-ddf.c:1614: warning: ignoring return value of posix_memalign
super-ddf.c:1842: warning: ignoring return value of posix_memalign
super-ddf.c:2013: warning: ignoring return value of posix_memalign
super-ddf.c:2140: warning: ignoring return value of write
super-ddf.c:2143: warning: ignoring return value of write
super-ddf.c:2147: warning: ignoring return value of write
super-ddf.c:2150: warning: ignoring return value of write
super-ddf.c:2162: warning: ignoring return value of write
super-ddf.c:2169: warning: ignoring return value of write
super-ddf.c:2172: warning: ignoring return value of write
super-ddf.c:2176: warning: ignoring return value of write
super-ddf.c:2181: warning: ignoring return value of write
super-ddf.c:2686: warning: ignoring return value of posix_memalign
super-ddf.c:2690: warning: ignoring return value of write
super-ddf.c:3070: warning: ignoring return value of posix_memalign
super-ddf.c:3254: warning: ignoring return value of posix_memalign
bitmap.c:128: warning: ignoring return value of posix_memalign
mdmon.c:94: warning: ignoring return value of write
mdmon.c:221: warning: ignoring return value of pipe
mdmon.c:327: warning: ignoring return value of write
mdmon.c:330: warning: ignoring return value of chdir
mdmon.c:335: warning: ignoring return value of dup
monitor.c:415: warning: rv may be used uninitialized in this function

...some of these like the write() ones are not so trivial so save those
fixes for the next patch.

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
15 years agoimsm: determine failed indexes from the most up-to-date disk
Dan Williams [Sun, 28 Sep 2008 19:12:07 +0000 (12:12 -0700)] 
imsm: determine failed indexes from the most up-to-date disk

load_imsm_disk() currently notices if spares missed their activation
update, but we allow a stale failed disk back in to the array because its
serial number is clobbered in the most up-to-date disk.

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
15 years agoimsm: manage a list of missing disks
Dan Williams [Sun, 28 Sep 2008 19:12:07 +0000 (12:12 -0700)] 
imsm: manage a list of missing disks

If a drive is removed while mdmon is not running we need a way to
identify what is missing and mark that disk as failed in the metadata.
At ->load_super() time create a list of missing disks defined as a disk
that is marked in-sync yet does not appear in super->disks.

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
15 years agoimsm: fix mpb_size calculation in write_super_imsm
Dan Williams [Sun, 28 Sep 2008 19:12:07 +0000 (12:12 -0700)] 
imsm: fix mpb_size calculation in write_super_imsm

Spotted a thinko... raid devices are dynamically sized, disks are not.
The space for disks is always mpb->num_disks * sizeof(struct imsm_disk).

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
15 years agoimsm: enable checkpointing of migration (resync/rebuild)
Dan Williams [Sun, 28 Sep 2008 19:12:06 +0000 (12:12 -0700)] 
imsm: enable checkpointing of migration (resync/rebuild)

When the array is shutdown, or when mdadm --wait-clean is called, any
active resync process will be idled allowing mdmon to record the current
resync position.

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
15 years agoExtend --wait-clean to checkpoint resync
Dan Williams [Sun, 28 Sep 2008 19:12:06 +0000 (12:12 -0700)] 
Extend --wait-clean to checkpoint resync

Root file systems backed by external metadata arrays need to be
explicitly checkpointed near the time the rootfs is marked readonly as
userspace will not have an opportunity to react to the final shutdown of
the array.

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
15 years ago--wait-clean: shorten timeout
Dan Williams [Sun, 28 Sep 2008 19:12:06 +0000 (12:12 -0700)] 
--wait-clean: shorten timeout

Set the safemode timeout to a small value to get the array marked clean as
soon as possible.  We don't write 'clean' directly as it may cause mdmon to
miss a 'write-pending' event.

Include a couple fixes to sysfs_set_safemode():
1/ 0 pad the milliseconds field
2/ workaround input truncation in the kernel

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
15 years agomonitor: protect against CONFIG_LBD=n
Dan Williams [Sun, 28 Sep 2008 19:12:06 +0000 (12:12 -0700)] 
monitor: protect against CONFIG_LBD=n

md/resync_start reports different terminal values depending on kernel
configuration (~0UL versus ~0ULL).  Make detection of the
resync-complete state more robust by comparing against array size.

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
15 years agoimsm: trust sector reservation from metadata
Dan Williams [Sun, 28 Sep 2008 19:12:03 +0000 (12:12 -0700)] 
imsm: trust sector reservation from metadata

On ich6r the option-rom appears to reserve only 432 sectors rather than
the 418+4096 of newer implementations.  For compatibility trust the
metadata in these cases.

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
15 years agosysfs: dprintf when we fail to write a sysfs file
Dan Williams [Wed, 24 Sep 2008 12:58:02 +0000 (05:58 -0700)] 
sysfs: dprintf when we fail to write a sysfs file

When arrays do not startup correctly it would be nice to know why.  Need
to move the dprintf definition to mdadm.h

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
15 years agoimsm: confirm raid10 layout, fix up handling raid10 failures
Dan Williams [Wed, 15 Oct 2008 21:15:47 +0000 (14:15 -0700)] 
imsm: confirm raid10 layout, fix up handling raid10 failures

1/ near-2 indeed matches how the Windows driver lays out the data
2/ update imsm_check_degraded to check for rebuilding disks in the
   raid10 case

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
15 years agoimsm: more serial handling fixups
Dan Williams [Wed, 15 Oct 2008 20:12:17 +0000 (13:12 -0700)] 
imsm: more serial handling fixups

zero-initialize the serial buffer to handle cases where the response is
less than MAX_RAID_SERIAL_LEN.

Tested-by: Jacek Danecki <jacek.danecki@intel.com>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
15 years agoGrow: Fix linear-growth when devices are not all the same size.
NeilBrown [Wed, 15 Oct 2008 03:34:18 +0000 (14:34 +1100)] 
Grow: Fix linear-growth when devices are not all the same size.

If we add a device to a linear array which is a difference size
to the other devices in the array then, for v1.x metadata, we need to
make sure the size is correctly reflected in the superblock.

15 years agoImprove reporting of layout for raid10.
NeilBrown [Mon, 13 Oct 2008 05:15:18 +0000 (16:15 +1100)] 
Improve reporting of layout for raid10.

Showing e.g.

   near=1, far=2

for the 'far2' layout of raid10 is confusing even though there is a
sense in which is it correct.

Make it less confusing by only printing whichever number is not 1.
If both are 1, make that clear too (i.e. no redundancy).

15 years agoManage: allow adding device that is just large enough to v1.x array.
NeilBrown [Mon, 13 Oct 2008 05:15:16 +0000 (16:15 +1100)] 
Manage: allow adding device that is just large enough to v1.x array.

When adding a device to an array, we check that it is large enough.

Currently the check makes sure there is also room for a reasonably
sized bitmap.  But if the array doesn't have a bitmap, then this test
might be too restrictive.
So when adding, only insist there is enough space for the current
bitmap.
When Creating, still require room for the standard sized bitmap.

This resolved Debian Bug 500309

15 years agoUpdates version numbers for 3.0-devel1 release.
NeilBrown [Thu, 18 Sep 2008 07:27:49 +0000 (17:27 +1000)] 
Updates version numbers for 3.0-devel1 release.

15 years agoDon't try to set_array_info when -I find new devices for an array.
NeilBrown [Thu, 18 Sep 2008 07:05:02 +0000 (17:05 +1000)] 
Don't try to set_array_info when -I find new devices for an array.

When -I get a new device for a container and tries to incrementally
assemble the container array, it calls sysfs_set_array to create the
array without first checking if it already exists.  This produces
unpleasant error messages.

So check first.

Signed-off-by: NeilBrown <neilb@suse.de>
15 years agoRemove .sock file when removing .pid file for mdmon
NeilBrown [Thu, 18 Sep 2008 06:43:59 +0000 (16:43 +1000)] 
Remove .sock file when removing .pid file for mdmon

15 years agoAdd support for assembling specific subarrays.
NeilBrown [Thu, 18 Sep 2008 06:21:08 +0000 (16:21 +1000)] 
Add support for assembling specific subarrays.

This normally isn't needed as --incremental does all the work.
But it is needed to recognise member= and container= in mdadm.conf

15 years agoUse common code to report MD_UUID for --detail --export
NeilBrown [Thu, 18 Sep 2008 06:12:28 +0000 (16:12 +1000)] 
Use common code to report MD_UUID for --detail --export

As we need to be able to extract a UUID from any superblock
for matching, use that as the MD_UUID as it will probably be
used for array matching too.

15 years agoReport uuid in --detail --brief for ddf and intel
NeilBrown [Thu, 18 Sep 2008 06:11:40 +0000 (16:11 +1000)] 
Report uuid in --detail --brief for ddf and intel

The uuid is slightly fictitious but needed for array matching.

15 years agoUse uuid as /dev name when assembling array of uncertain origin.
NeilBrown [Thu, 18 Sep 2008 06:08:10 +0000 (16:08 +1000)] 
Use uuid as /dev name when assembling array of uncertain origin.

If we aren't sure that the array belongs to 'this' host, use the
uuid to choose a name to avoid any conflict.

15 years agoAdd uuid support for super-intel.
NeilBrown [Thu, 18 Sep 2008 06:07:32 +0000 (16:07 +1000)] 
Add uuid support for super-intel.

'imsm' does not provide any real uuid, so we synthesise one
from various stable bits of the superblock.

15 years agoAllow metadata handler to report that it doesn't record homehost.
NeilBrown [Thu, 18 Sep 2008 06:06:41 +0000 (16:06 +1000)] 
Allow metadata handler to report that it doesn't record homehost.

For now, this means that the lack of a homehost doesn't always prevent
assembly.
Soon we will allow assembly anyway, but have different messages if
homehost isn't supported.

15 years agoDon't allow spares when creating 'external' arrays.
NeilBrown [Thu, 18 Sep 2008 06:03:08 +0000 (16:03 +1000)] 
Don't allow spares when creating 'external' arrays.

It is meaningless when creating the container, and for
subarrays, the container is responsible for assigning
spares.

Also, don't do the 'spare' fiddle for raid5 as we cannot
set up a spare at this point yet.  Later maybe just create
the array degraded and let the container sort it out.

15 years agoLots of fixes to make incremental assembly of containers work.
NeilBrown [Thu, 18 Sep 2008 06:03:05 +0000 (16:03 +1000)] 
Lots of fixes to make incremental assembly of containers work.

So:
  mdadm -I /dev/whatever

will (if appropriate) add whatever to a container, then start
any arrays inside the container.

15 years agoHandle incremental assembly of containers.
NeilBrown [Thu, 18 Sep 2008 06:01:57 +0000 (16:01 +1000)] 
Handle incremental assembly of containers.

 mdadm -I /dev/part-of-container

should add that to a container, creating if it needed,
and then try to assemble any arrays in the container.

Signed-off-by: NeilBrown <neilb@suse.de>
15 years agoMove calls to SET_ARRAY_INFO to common helper.
NeilBrown [Thu, 18 Sep 2008 06:01:55 +0000 (16:01 +1000)] 
Move calls to SET_ARRAY_INFO to common helper.

When we assemble an array, there are three different approaches
depending on whether metadata is internal or external, and on
kernel version.

Move all this to a common helper instead of duplicating in 3 places.

Signed-off-by: NeilBrown <neilb@suse.de>
15 years agoFactor out add-disk code
NeilBrown [Thu, 18 Sep 2008 05:13:32 +0000 (15:13 +1000)] 
Factor out add-disk code

The variety of approaches to 'add_disk' are factored out into
a separate function, and Incremental mode benefits by being
closer to supporting the assembly of containers.

Also remove the adding-to-array-data-structure out of sysfs_add_disk
and into add_disk.

And add some tests for --incremental mode to make sure we don't break it.

Signed-off-by: NeilBrown <neilb@suse.de>
15 years agoIgnore leading zeros in version number information.
NeilBrown [Thu, 18 Sep 2008 05:07:45 +0000 (15:07 +1000)] 
Ignore leading zeros in version number information.

--detail sometimes generates leading zero which are just noise.

15 years agoAllow --config in --incremental mode.
NeilBrown [Thu, 18 Sep 2008 05:05:46 +0000 (15:05 +1000)] 
Allow --config in --incremental mode.

15 years agoTeach --detail about containers and members there-of.
NeilBrown [Thu, 18 Sep 2008 05:05:20 +0000 (15:05 +1000)] 
Teach --detail about containers and members there-of.

Make --detail on a container more useful by suppressing irrelevant
detail and adding useful detail like a list of member arrays.

Ditto for members of a container: report the name of the container
array.

Signed-off-by: NeilBrown <neilb@suse.de>
15 years agoCompile fixes, particularly moving more stuff under MDASSEMBLE
NeilBrown [Thu, 18 Sep 2008 05:04:47 +0000 (15:04 +1000)] 
Compile fixes, particularly moving more stuff under MDASSEMBLE

Now 'make everything' works again.

15 years agoDisable compilation with diet-libc
NeilBrown [Thu, 18 Sep 2008 04:33:37 +0000 (14:33 +1000)] 
Disable compilation with diet-libc

We need posix_memalign (or something similar) which diet-libc does not
provide.

15 years agoFix compile warning/error.
NeilBrown [Thu, 18 Sep 2008 04:10:42 +0000 (14:10 +1000)] 
Fix compile warning/error.

gcc said:
  error: large integer implicitly truncated to unsigned type

Signed-off-by: NeilBrown <neilb@suse.de>
15 years agomdmon: recreate socket/pid file on SIGHUP
Dan Williams [Tue, 16 Sep 2008 03:58:43 +0000 (20:58 -0700)] 
mdmon: recreate socket/pid file on SIGHUP

Allow mdmon to start while /var/run/mdadm is readonly.  Later a SIGHUP
can trigger mdmon to drop its pid and socket once /var/run/mdadm is
writable.  Of course one needs the pid to send a HUP, that can be stored
in a distribution specific rw-init directory... For now, rely on a
killall -HUP mdmon to get the files dumped.

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
15 years agoping_manager() to prevent 'add' before 'remove' completes
Dan Williams [Tue, 16 Sep 2008 03:58:43 +0000 (20:58 -0700)] 
ping_manager() to prevent 'add' before 'remove' completes

It is currently possible to remove a device and re-add it without the
manager noticing, i.e. without detecting a mdstat->devcnt
container->devcnt mismatch.  Introduce ping_manager() to arrange for
mdmon to run manage_container() prior to mdadm dropping the exclusive
open() on the container.  Despite these precautions sysfs_read() may
still fail.  If this happens invalidate container->devcnt to ensure
manage_container() runs at the next event.

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
15 years agosysfs: detect disks that are in the process of being removed
Dan Williams [Tue, 16 Sep 2008 03:58:43 +0000 (20:58 -0700)] 
sysfs: detect disks that are in the process of being removed

When removing a disk there is a window where the 'slot' attribute of
md/dev-$name will return -EBUSY to read attempts.  When this happens
look at the the 'block' link, if it is removed then we can be sure the
device has been removed, versus some other error.

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
15 years agomonitor: clean up some debug messages
Dan Williams [Tue, 16 Sep 2008 03:58:43 +0000 (20:58 -0700)] 
monitor: clean up some debug messages

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
15 years agomdmon: resume rebuild
Dan Williams [Tue, 16 Sep 2008 03:58:43 +0000 (20:58 -0700)] 
mdmon: resume rebuild

If we started a degraded array that was previously rebuilding we may
have enough information to resume the rebuild without a trip through the
monitor.

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
15 years agoimsm: allow a failed disk to be readded
Dan Williams [Tue, 16 Sep 2008 03:58:42 +0000 (20:58 -0700)] 
imsm: allow a failed disk to be readded

Allow the following sequence to rebuild the array
mdadm --fail /dev/md/r1 /dev/disk
mdadm --remove /dev/imsm /dev/disk
mdadm --add /dev/imsm /dev/disk

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
15 years ago'mdadm --wait-clean' wait for array to be marked clean
Dan Williams [Tue, 16 Sep 2008 03:58:42 +0000 (20:58 -0700)] 
'mdadm --wait-clean' wait for array to be marked clean

For use in distro shutdown scripts with a RAID root file system.
Returns immediately if the array is 'readonly', or not an externally
managed array.  It is up to the distro's scripts to make sure no new
writes hit the device after this returns 'true'.

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
15 years agoAdd ping_monitor() to mdadm --wait
Dan Williams [Tue, 16 Sep 2008 03:58:42 +0000 (20:58 -0700)] 
Add ping_monitor() to mdadm --wait

The action we are waiting for may not be complete until the monitor has
had a chance to take action on the result.

The following script can now remove the device on the first attempt,
versus a few attempts with the original Wait():
#!/bin/bash
#export MDADM_NO_MDMON=1
export IMSM_DEVNAME_AS_SERIAL=1
./mdadm -Ss
./mdadm --zero-superblock /dev/loop[0-3]
echo 2 > /proc/sys/dev/raid/speed_limit_max
./mdadm --create /dev/imsm /dev/loop[0-3] -n 4 -e imsm -a md
./mdadm --create /dev/md/r1 /dev/loop[0-3] -n 4 -l 5 --force -a mdp
./mdadm --fail /dev/md/r1 /dev/loop3
./mdadm --wait /dev/md/r1
x=0
while  ! ./mdadm --remove /dev/imsm /dev/loop3 > /dev/null 2>&1
do
        x=$((x+1))
done
echo "removed after $x attempts"
./mdadm --add /dev/imsm /dev/loop3

Include 2 small cleanups:
* remove the almost open coded fd2devnum() in Wait() by introducing a
  new utility routine stat2devnum()
* teach connect_monitor() to parse the container device from a subarray
  string

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
15 years agomonitor: don't mark dirty on resync complete
Dan Williams [Tue, 16 Sep 2008 03:58:42 +0000 (20:58 -0700)] 
monitor: don't mark dirty on resync complete

...instead look at array state to determine if the array is consistent

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
15 years agomonitor: mark clean on active-idle
Dan Williams [Tue, 16 Sep 2008 03:58:42 +0000 (20:58 -0700)] 
monitor: mark clean on active-idle

This also handles the case where 'clean' is set directly.

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
15 years agoHonor safemode_delay at Create() and Incremental() time
Dan Williams [Tue, 16 Sep 2008 03:58:42 +0000 (20:58 -0700)] 
Honor safemode_delay at Create() and Incremental() time

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
15 years agoimsm: use ->getinfo_super() in ->container_content()
Dan Williams [Tue, 16 Sep 2008 03:58:42 +0000 (20:58 -0700)] 
imsm: use ->getinfo_super() in ->container_content()

* allows container_content() to pick up the safemode_delay
* removes some duplicate code
* fixes an endian bug setting info->array.chunk_size

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
15 years agoAllow metadata handlers to communicate desired safemode delay via mdinfo
Dan Williams [Tue, 16 Sep 2008 03:58:42 +0000 (20:58 -0700)] 
Allow metadata handlers to communicate desired safemode delay via mdinfo

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
15 years agoMakefile: Add mdmon header dependencies
Dan Williams [Tue, 16 Sep 2008 03:58:41 +0000 (20:58 -0700)] 
Makefile: Add mdmon header dependencies

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
15 years agoimsm: fix up serial handling
Dan Williams [Tue, 16 Sep 2008 03:58:41 +0000 (20:58 -0700)] 
imsm: fix up serial handling

* Trim trailing and leading whitespace
* Allow unterminated serial numbers up to MAX_RAID_SERIAL_LEN

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
15 years agoimsm: only use the device name as a fallback when IMSM_DEVNAME_AS_SERIAL=1
Dan Williams [Tue, 16 Sep 2008 03:58:41 +0000 (20:58 -0700)] 
imsm: only use the device name as a fallback when IMSM_DEVNAME_AS_SERIAL=1

Also ensure that the serial buffer is initialized.

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
15 years agoimsm: rectify map handling
Dan Williams [Tue, 16 Sep 2008 03:58:41 +0000 (20:58 -0700)] 
imsm: rectify map handling

The secondary map is used to reflect the migration state of the array
i.e.  from dev->vol.map[1] to dev->vol.map[0].  Ensure a rebuilding /
initializing array is marked in the second map, while normal status is
reflected in the first map.  Also mark rebuilding drives with
IMSM_ORD_REBUILD.

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
15 years agoimsm: fix imsm_delete()
Dan Williams [Tue, 16 Sep 2008 03:58:41 +0000 (20:58 -0700)] 
imsm: fix imsm_delete()

* fix breakage from last merge (infinite loop in imsm_process_update())
* add ability to delete by index

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
15 years agoimsm: use IMSM_ORD_REBUILD instead of USABLE flag
Dan Williams [Tue, 16 Sep 2008 03:58:41 +0000 (20:58 -0700)] 
imsm: use IMSM_ORD_REBUILD instead of USABLE flag

IMSM_ORD_REBUILD is the 'insync' flag in MD terms.  USABLE is a flag to
opt-in disks for use with the Windows driver.

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
15 years agoimsm: introduce set_imsm_ord_tbl_ent()
Dan Williams [Tue, 16 Sep 2008 03:58:41 +0000 (20:58 -0700)] 
imsm: introduce set_imsm_ord_tbl_ent()

Collapse all the open coded occurrences.

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
15 years agoimsm: cleanup arguments to imsm_check_degraded
Dan Williams [Tue, 16 Sep 2008 03:58:41 +0000 (20:58 -0700)] 
imsm: cleanup arguments to imsm_check_degraded

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
15 years agoimsm: cleanup get_imsm_disk_idx(), unify with get_imsm_ord_tbl_ent()
Dan Williams [Tue, 16 Sep 2008 03:58:41 +0000 (20:58 -0700)] 
imsm: cleanup get_imsm_disk_idx(), unify with get_imsm_ord_tbl_ent()

Save some unnecessary calls to get_imsm_map() by teaching
get_imsm_disk_idx() to retrieve the map.

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
15 years agoimsm: fix up compare_super_imsm() to match family_num for populated mpb's
Dan Williams [Tue, 16 Sep 2008 03:58:40 +0000 (20:58 -0700)] 
imsm: fix up compare_super_imsm() to match family_num for populated mpb's

This allows spares to be associated with any family while not allowing
disks from different families to be assembled.

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
15 years agoimsm: fix up spare handling holdover in update_create_array
Dan Williams [Tue, 16 Sep 2008 03:55:40 +0000 (20:55 -0700)] 
imsm: fix up spare handling holdover in update_create_array

We used to leave SPARE_DISK unset to indicate it was available to be
assimilated into other arrays.  Now we explicitly check the size.

Signed-off-by: Dan Williams <dan.j.williams@intel.com>