NeilBrown [Wed, 30 Jun 2010 06:55:17 +0000 (16:55 +1000)]
Add mdstat_by_component
This allows finding the array which contains a given component.
Components are named using the kernel-internal string name such
as "sda1" or "hdb".
Don't return member arrays, only the contain that contains them.
Also tidy up the parsing of 'inactive' arrays in /proc/mdstat.
If we see 'inactive' we need to set 'in_devs' immediately as there
is no level coming.
NeilBrown [Wed, 30 Jun 2010 06:52:54 +0000 (16:52 +1000)]
Correct documentation for --rebuild-map
In some places it is referred to as "--rebuild", and while
that works due to getopt allowing prefixes, it could appear
confusing (rebuild means other things too) and being explicit
is some safeguard if we want to add e.g. --rebuild-foo later.
martin f. krafft [Fri, 28 May 2010 12:12:41 +0000 (14:12 +0200)]
Compile-time switch to enable 0.9 metadata as default
This commit introduces DEFAULT_OLD_METADATA as a preprocessor
definition. If defined, it causes mdadm to assume metadata version 0.9
as default. If not defined, version 1.x (currently 1.2) is used as
default.
The man page mdadm.8 is also modified to reflect the chosen default.
The selftests will not work if the old default is chosen.
This patch was requested by Debian so they could distribute a current
mdadm together with boot loaders that only understand 0.90 metadata
for md-raid.
Preferred usage is simply
make DEFAULT_OLD_METADATA=yes
Signed-off-by: martin f. krafft <madduck@debian.org> Signed-off-by: NeilBrown <neilb@suse.de>
NeilBrown [Mon, 31 May 2010 02:08:02 +0000 (12:08 +1000)]
Revert change to handling of -empty-string- metadata.
If the metadata is an empty string, it means the array in question
does not use metadata. This comes from sysfs_read finding "none" in
"metadata_version", then super_by_fd noticing the vers == -1, and so
just using the ->text_version (which is empty).
In this case we want to use the super0 metadata handler routines
because that is what we always used to do before
* commit '3288b419b988b20a53a2b12eb8e5f9f536228db4':
Revert "Incremental: honor --no-degraded to delay assembly"
Incremental: honor an 'enough' flag from external handlers
Dan Williams [Wed, 26 May 2010 20:33:43 +0000 (13:33 -0700)]
imsm: robustify recovery-start detection
update_recovery_start() assumed that the out-of-sync disk would always be
marked as IMSM_ORD_REBUILD in the disk_ord_tbl, but the segmentation
fault reported by Andy proves otherwise. This might also be explained by
an interrupted rebuild and the disk has not yet been marked missing.
Now that containers can report state for ->container_enough we can
automatically determine when the array can be started, and no longer
need the --no-degraded hammer.
Conflicts:
Incremental.c
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
Dan Williams [Wed, 26 May 2010 20:22:36 +0000 (13:22 -0700)]
Incremental: honor an 'enough' flag from external handlers
This is needed for imsm where:
1/ we want to report raid_disks as zero to allow mdadm -As to
incorporate all spares
2/ we can't determine stale disks by looking at the event counts.
3/ we can't see per-subarray expectations with the info returned from
the container level ->getinfo_super()
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
NeilBrown [Tue, 18 May 2010 02:31:29 +0000 (12:31 +1000)]
Monitor: don't report the disappearance of a faulty device as SpareActive.
Normally Monitor doesn't see faulty devices in active slots - they get
moved away too quickly.
But if it does, it reports the "faulty device disappeared" event (when
it finally does get moved away) as SpareActive due to insufficient
checking.
So add a better check.
Reported-by: Pierre Vignéras <pierre@vigneras.name>
Dan Williams [Thu, 29 Apr 2010 17:50:29 +0000 (10:50 -0700)]
mdmon: fix missing open of md/<dev>/recovery_start
When activating a spare we neglect to open recovery_start and as such do
not see checkpoint events. Move disk initialization to common routine
to mitigate recurrence.
Reported-by: Adam Kwolek <adam.kwolek@intel.com> Signed-off-by: Dan Williams <dan.j.williams@intel.com>
Chunks aren't particularly big, but when you could them in bytes
and multiply them together (as we do for calculating the backup
size for 'grow') they can overflow a 32bit int.
So group the division by 512 more closely with the
chunk size so were would need 30Meg chunks to come close to
overflowing 32bits.
IMSM/DDF: don't recognised these metadata on partitions.
These metadata are not expected on partitions, and they have
no way of differentiation whether which is correct if they
are found both on the device and on the last partition.
So if the device is a partition, refuse to read the metadata.
Dan Williams [Mon, 19 Apr 2010 05:28:07 +0000 (15:28 +1000)]
Create: cleanup after failed create in duplicated array member case
mdadm prevents creation when device names are duplicated on the command
line, but leaves the partially created array intact. Detect this case
in the error code from add_to_super() and cleanup the partially created
array. The imsm handler is updated to report this conflict in
add_to_super_imsm_volume().
Note that since neither mdmon, nor userspace for that matter, ever saw an
active array we only need to perform a subset of the cleanup actions.
So call ioctl(STOP_ARRAY) directly and arrange for Create() to cleanup
the map file rather than calling Manage_runstop().
Reported-by: Krzysztof Wojcik <krzysztof.wojcik@intel.com> Signed-off-by: Dan Williams <dan.j.williams@intel.com>
Doug Ledford [Wed, 17 Mar 2010 03:00:11 +0000 (23:00 -0400)]
Create directory to contain mapfile (Assuming parent exists and
filesystem is writable).
This particularly keeps udev happy if VAR_RUN is set to /dev/md.
NeilBrown [Wed, 10 Mar 2010 04:55:47 +0000 (15:55 +1100)]
ddf/intel: zero out old metadata before creating a container.
Matching the functionality already in super0 and super1, when
we first create a container, remove any other recognisable metadata to
ensure it doesn't cause confusion.
NeilBrown [Wed, 10 Mar 2010 00:21:26 +0000 (11:21 +1100)]
Assemble: fix some recently introduced bugs.
Found during testing:
- cannot check metadata for homehost before loading metadata.
- As 1.x metadata can has a state 'rebuilding' between
'spare' and 'ok', we need to include that in our calculations.
NeilBrown [Wed, 3 Mar 2010 02:16:24 +0000 (13:16 +1100)]
Manage: fix regression on removing detached devices.
If /dev is static, a name may remain there after the
device has been detached from the system.
Using 'mdadm' to remove such a device from the array
should still work (even though "mdadm --remove detached"
might be preferred).
So when processing a device for '-r', don't insist on
being able to open the device.
NeilBrown [Sun, 28 Feb 2010 14:43:40 +0000 (15:43 +0100)]
mdmon: Check both RUN directories to find running mdmon
If mdmon is run without "--takeover", it should still
check both *_RUN directories for a valid 'pid' file
to guard against having two mdmons running at the same time.
NeilBrown [Wed, 24 Feb 2010 01:17:17 +0000 (12:17 +1100)]
Assemble: clean up properly if we cannot add the bitmap file.
If we find we cannot add the requested bitmap file when
assembling the array, then make sure to clean up properly
and don't leave a half-configured array.
NeilBrown [Wed, 24 Feb 2010 01:03:27 +0000 (12:03 +1100)]
Create: change default metadata type to 1.2
Change default - again, sorry.
v1.1 causes problems as the conflicts with a boot sector, whether on
the whole device or in a partition. I guess the rule is they you
aren't allowed to use the first sector in general.
v1.2 is mostly just as good and avoid boot-sector problems so default
to that instead.
NeilBrown [Wed, 24 Feb 2010 00:59:11 +0000 (11:59 +1100)]
Grow: be more relaxed about timestamp mismatches on backup file.
As backup file has a timestamp which is updated quite separately
from the metadata timestamp. They should be largely in-sync but
sometimes are not.
So be more generous in the check, and allow it to be over-ridden
by an environment variable.
NeilBrown [Wed, 24 Feb 2010 00:43:59 +0000 (11:43 +1100)]
Assemble: check inargv before complaining about stray arguments.
If --assemble is given a container and some other devices to assemble
an array from, it complains with an error because that doesn't make
sense.
However it currently also complains if the list of devices was extract
from the config file rather than being given on the command line.
That is not appropriate.
So add an '&& inargv' test to ensure that we are really complaining
about the right thing.
Signed-off-by: NeilBrown <neilb@suse.de> Acked-by: Dan Williams <dan.j.williams@intel.com>
NeilBrown [Wed, 24 Feb 2010 00:31:48 +0000 (11:31 +1100)]
super1: put bitmap on a 4K boundary when possible.
Some devices have 4K sector sizes. So try to align the bitmap
on a 4K boundary.
This isn't possible when hot-adding a bitmap, but will be once
we add support for configuring the bitmap via sysfs.
NeilBrown [Wed, 24 Feb 2010 00:16:41 +0000 (11:16 +1100)]
Assemble: Handle assembling from config file which is out of order.
Currently "mdadm -As" will process the entries in the config
file in order. If any array is a component or member of a preceding
array, that array will not be assembled.
So if there are any failures during assembly, retry those arrays,
and look until everything is assembled, or nothing more can
be assembled.
NeilBrown [Mon, 8 Feb 2010 03:30:46 +0000 (14:30 +1100)]
mdmon: insist on creating .pid file at startup.
Now that we don't "mdadm --takeover" until /var/run is writable
there is no need to continually try to create files in there.
So only create these files at startup and fail if they cannot be
made. This means that to start an array with externally managed
metadata, either /var/run or ALT_RUN (e.g. /lib/init/rw) must be
writable. To 'takeover' from a previous mdmon instance, /var/run
must be writable.
This means we don't need to worry about SIGHUP (which was once used to
tell us it was time to create .pid) and SIGALRM.
NeilBrown [Mon, 8 Feb 2010 03:12:46 +0000 (14:12 +1100)]
mdmon: don't monitor /proc/mounts to decide when to create .pid file.
Monitoring /proc/mounts and creating a .pid file as soon as /var/run
is writable is racy. Most distros clean all non-directories from
/var/run early in boot and if mdmon races with this it could
lose the files as soon as they are created.
Instead require that "mdmon --takeover" be run after /var is writable.
NeilBrown [Mon, 8 Feb 2010 03:08:13 +0000 (14:08 +1100)]
mdmon: remove switch-root functionality.
Using switch-root and then creating files in /var/run once
that location is writable is racing as most distro clean out
/var/run shortly after it is mounted.
This can cause the .pid and .sock files to be deleted shortly
after they are created.
This option doesn't seem to be used at all any, and the alternative
of communicating the pid etc in some preserved directory and then
restarting mdmon once all is settled seems simpler.
So remove the code for supporting switchroot and update man page
accordingly.
NeilBrown [Fri, 29 Jan 2010 01:20:11 +0000 (12:20 +1100)]
mdmon: don't mkdir /var/run
Creating /var/run in mdmon is really not justifiable.
If /var/run doesn't exist, then it is either deliberate and it should
be left that way to make sure the mapfile gets created in /dev, or
it is a configuration error and not our problem to fix.
NeilBrown [Fri, 29 Jan 2010 01:14:17 +0000 (12:14 +1100)]
mdmon: improve switchroot handling.
The change to get mdmon to re-exec itself from the switchroot
filesystem broken switchroot in various ways. This fixes it.
If the switchroot path is not '/', mdmon will find the pid and
socket for the monitor, chroot to the new root, and exec mdmon
passing the pid in argv[2] and the socket in stdin.
If the switchroot path is actually a number, mdmon will not chroot,
but will kill that pid before taking over the array.
NeilBrown [Fri, 29 Jan 2010 00:33:01 +0000 (11:33 +1100)]
mdmon: simplify try_kill_monitor
After we SIGTERM the monitor we need to wait for it to finish up.
Rather than the complexity of waiting for every md array to be clean,
we can simply read from the sock connected to the monitor.
When the monitor dies, we will get EOF. Before then we will block.
NeilBrown [Thu, 28 Jan 2010 23:40:07 +0000 (10:40 +1100)]
mdmon: remove scan variable from mdmon()
It is redundant as each place that it is used, it can only
have one possible value.
Also change the related arg to mdmon() to have a more meaningful
name.
And make mdmon() static.
NeilBrown [Thu, 4 Feb 2010 01:02:09 +0000 (12:02 +1100)]
Assemble: fix --force assembly of v1.x arrays which are recovering.
1.x metadata allows a device to be a member of the array while it
is still recoverying. So it is a working member, but is not
completely in-sync.
mdadm/assemble does not understand this distinction and assumes that a
work member is fully in-sync for the purpose of determining if there
are enough in-sync devices for the array to be functional.
So collect the 'recovery_start' value from the metadata and use it in
assemble when determining how useful a given device is.
Reported-by: Mikael Abrahamsson <swmike@swm.pp.se> Signed-off-by: NeilBrown <neilb@suse.de>
NeilBrown [Sun, 31 Jan 2010 23:37:58 +0000 (10:37 +1100)]
Create: Improve warning message about booting from v1.x
Suggesting that if your boot loaded doesn't support v1.x, then use
--metadata=1.0
doesn't make a lot of sense.
Also, '/', isn't really important, it is /boot that matters.
Hopefully people who have /boot on '/' realise that /boot is
on '/' ....
NeilBrown [Sun, 31 Jan 2010 23:22:38 +0000 (10:22 +1100)]
Add test for "are we running as root".
Most operations require root access. Rather than ensure we generate
the right error message when something fails because we aren't root,
check early.
Note that "--examine" does not necessarily require root, so test
for that first.
NeilBrown [Fri, 29 Jan 2010 05:20:08 +0000 (16:20 +1100)]
mapfile: fix locking.
The current locking uses lockf, and is completely broken.
When you hold a lockf lock, any close of any fd on that file will
release the lock. So map_read() call which is made as soon as we get
the lock, will immediately drop the lock.
So change to flock locking which isn't so badly designed.
NeilBrown [Fri, 29 Jan 2010 04:45:36 +0000 (15:45 +1100)]
Detail: Report state of FAILED when an array has too few devices to work.
We already have a call to 'enough' in Detail which is the check for
"do we have enough devices". We just need to calculate the required
data a bit earlier, then use the same 'enough' call to possibly
print FAILED.
This is motivated by Debian bug 495755.
The other request in that bug is not practical.
It would be very nice if output of `mdadm' is more clear in case of a
broken array.
Currently the only hint you get from `mdadm' that your array is broken
is this:
# mdadm -A /dev/md0 /dev/sdc1 /dev/sdd1 /dev/sde1 /dev/sdf1
mdadm: /dev/md0 assembled from 1 drive and 3 spares - not enough to start the
array.
It could say something like `Your array is broken, you can't use it anymore'
It is not valid to report that array as 'broken' if the user hasn't
listed all the devices, which could be the case here.
NeilBrown [Thu, 28 Jan 2010 00:48:03 +0000 (11:48 +1100)]
Grow: If bitmap interferes with grow, report this.
If a bitmap exists on an array, then current kernels cannot grow
that array.
So when we try to grow an array, test for EBUSY and if a bitmap is
present, report that the bitmap needs to be removed.
NeilBrown [Wed, 27 Jan 2010 22:01:36 +0000 (09:01 +1100)]
Assemble: error-check ->load_super
Once load_super has succeeded, it should continue to succeed. However
devices can disappear etc so it is prudent to always check the return
status of load_super.
Michael Evan [Thu, 10 Dec 2009 05:52:18 +0000 (21:52 -0800)]
Document validity of --assume-clean when all devices are zeroed.
>>
>> When I assemble an array I tend to have checked the devices before
>> hand; it would not be difficult to make the final pass a zeroing pass
>> if I knew I could vastly speed up post-assembly performance. As I
>> stated, it's merely a lack of clarity in the documentation.
>
> If you would like to create a patch against the man page, I would be happy to
> accept it.
>
> NeilBrown
Dan Williams [Tue, 22 Dec 2009 00:54:32 +0000 (17:54 -0700)]
imsm: add support for checkpointing via 'curr_migr_unit'
Unlike native md checkpointing some data about the geometry and type of
the migration process is coded into curr_migr_unit. Provide logic to
convert between md/{resync_start|recovery_start} and imsm/curr_migr_unit.
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
Dan Williams [Mon, 21 Dec 2009 19:51:57 +0000 (12:51 -0700)]
Support external metadata recovery-resume
Minimal changes needed to permit reassembling partially recovered
external metadata arrays. The biggest logical change is that
->container_content() can now surface partially rebuilt members rather
than omitting them from the disk list.
Signed-off-by: Dan Williams <dan.j.williams@intel.com>