Commit Graph

2793 Commits

Author SHA1 Message Date
NeilBrown 6f02172d2e Release mdadm-3.3
(and  various cosmetic fixes)

Signed-off-by: NeilBrown <neilb@suse.de>
2013-09-03 14:47:47 +10:00
NeilBrown 2dfb675b94 config: support MDADM_CONF_AUTO= env var.
If a distribution allows the choice between using mdadm and
dmraid for DDF and IMSM to be made by some config file
(/etc/defaults/ /sys/sysconfig/ etc) which is queried by
/etc/init.d scripts, then the fact that mdadm implements this
choce through the config file is not very helpful.

So allow the "AUTO" line to be specified in part using MDADM_CONF_AUTO
in environment.

Signed-off-by: NeilBrown <neilb@suse.de>
2013-09-03 13:25:02 +10:00
NeilBrown 824e57276a config: refactor load_conffile() to have a single exit.
This will make next patch cleaner.
No functional change.

Signed-off-by: NeilBrown <neilb@suse.de>
2013-09-03 10:26:06 +10:00
NeilBrown 3c6e95c1aa Config: multiple occurences of lines is not an error.
As we now support config directories it is helpful if
lines are allowed to occur multiple times with one
over-riding the other.
So stop giving warnings when later lines are ignored.

Signed-off-by: NeilBrown <neilb@suse.de>
2013-09-03 10:05:59 +10:00
NeilBrown 9dc70cbc54 config: read /etc/mdadm.conf.d as well as /etc/mdadm.conf
If a configfile is explicitly given, just that file or directory
is read. Otherwise we now read both a file
  /etc/mdadm.conf
and a directory
  /etc/mdadm.conf.d

This allows a transition to directory based config, which in turn
allows easy control from scripts.

Signed-off-by: NeilBrown  <neilb@suse.de>
2013-09-03 09:29:52 +10:00
NeilBrown 343b7e75e8 Conf: allow conf file to be a directory.
If config file is a directory, process each file within with a name
ending in ".conf" that doesn't start with ".".
Files are processed in lexical order.

Signed-off-by: NeilBrown <neilb@suse.de>
2013-09-03 09:16:33 +10:00
NeilBrown 15af969283 Config: factor reading of file out into separate function.
This will make it easier to read multiple files in a conf.d/

Signed-off-by: NeilBrown <neilb@suse.de>
2013-09-03 08:47:57 +10:00
NeilBrown 4e5e54cf82 mdmon: make sure we set safe_mode on SIGTERM.
Without this, array may not go clean and mdmon will then
not exit.

A safe_mode of '0' (which is the only one that is handled differently
by this patch) means "never switch to 'active_idle'".  We don't want
that when mdmon is stopping.

Signed-off-by: NeilBrown <neilb@suse.de>
2013-09-02 12:08:44 +10:00
NeilBrown a792ece676 Assemble: don't ever consider a 'spare' to be the 'most recent'.
If all devices have the same event count and the first one is a spare,
then that spare will be the 'most_recent'.
However then other devices will think the 'most_recent' has failed
(for v0.90 metadata) and will be rejected from the array.

So never consider a 'spare' to be 'most recent'.

Reported-by: Andreas Baer <synthetic.gods@gmail.com>
Signed-off-by: NeilBrown <neilb@suse.de>
2013-09-02 11:48:06 +10:00
NeilBrown 2f1bcf43d9 Make sure "mdmon" doesn't get called "@dmon".
The Anaconda installer (via its "loader" program) will try to kill
many processes at shutdown, but not "mdmon".

However when mdadm runs mdmon in the Anaconda environment, mdmon
sets argv[0][0] to '@' resulting in "@dmon" which confuses
"loader".

So change mdadm to set argv[0] to a path so that mdmon becomes e.g.
  "@usr/sbin/mdmon"
which "loader" will recognise as being "mdmon".

Reported-by: Martin Wilck <mwilck@arcor.de>
Signed-off-by: NeilBrown <neilb@suse.de>
2013-09-02 11:02:09 +10:00
NeilBrown 2cdd5ce0e7 Grow: fix hang when growing a RAID5.
Since:

commit 84d11e6c6a
Author: NeilBrown <neilb@suse.de>
Date:   Thu Aug 1 11:16:14 2013 +1000

    Grow: exit background thread cleanly on SIGTERM.

removed the setting of "sync_max" from abort_reshape() we need
to do it explicitly here.

Signed-off-by: NeilBrown <neilb@suse.de>
2013-08-28 17:00:53 +10:00
mwilck@arcor.de 7ac5d47e8a in_initrd: fix gcc compiler error
On some systems, this code caused a "comparison between signed
and unsigned" error.

Signed-off-by: Martin Wilck <mwilck@arcor.de>
Signed-off-by: NeilBrown <neilb@suse.de>
2013-08-28 14:58:56 +10:00
mwilck@arcor.de 5684fff6f8 DDF: increase default value for safe_mode_delay to 4000ms
That is the same value that IMSM uses. The current default of 200ms
seems to have been copied from the native MD meta data. That value
appears to be much too low for DDF, given that writing the DDF meta
data means that easily several MB worth of data need to be written to
disk.

Signed-off-by: Martin Wilck <mwilck@arcor.de>
Signed-off-by: NeilBrown <neilb@suse.de>
2013-08-28 14:58:34 +10:00
mwilck@arcor.de 1219c77e72 DDF: container_content_ddf: set safe_mode_delay > 0
Set safe_mode_delay to something >0, otherwise all container subarrays
assembled will have safe_mode_delay=0. That will break the assumption that
meta data becomes clean after running mdadm --wait-clean.

Use the same value as in getinfo_super_ddf_bvd. It would be cleaner
to call that directly from container_content_ddf, but I need to check
possible side effects first.

Signed-off-by: Martin Wilck <mwilck@arcor.de>
Signed-off-by: NeilBrown <neilb@suse.de>
2013-08-28 14:58:15 +10:00
mwilck@arcor.de cc9bfd9ea4 DDF: export_examine_super_ddf: print MD_DEVICES
Have mdadm -E --export print the number of RAID devices,
like other meta data formats do. Anaconda (RHEL/CentOS installer)
depends on it.

Signed-off-by: Martin Wilck <mwilck@arcor.de>
Signed-off-by: NeilBrown <neilb@suse.de>
2013-08-28 14:58:02 +10:00
NeilBrown bb925ff08b DDF: ddf_activate_spare: fix gcc -O2 uninitialized warning
At this point 'di' and 'rv' both have the same value.  gcc doesn't
realise that and a human reader might not either.
'rv' makes more sense too, so use that.

Signed-off-by: Martin Wilck <mwilck@arcor.de>
Signed-off-by: NeilBrown <neilb@suse.de>
2013-08-28 14:41:26 +10:00
NeilBrown 8430855db5 Add ANNOUNCE-3.2.6 from different branch
just for completeness...

Signed-off-by: NeilBrown <neilb@suse.de>
2013-08-26 15:28:43 +10:00
NeilBrown 305ea8b8c3 Add raid6check to .gitignore
Signed-off-by: NeilBrown <neilb@suse.de>
2013-08-26 15:26:54 +10:00
NeilBrown d3786cdcd0 Change "mdadm --run" to use the same code as "mdadm --IRs".
Current "mdadm --run /dev/mdX" will not handle external metadata
properly.  mdmon won't be started etc.

So use the code from "mdadm -IRs" instead - that already does all
the right things.

Reported-by: Francis Moreau <francis.moro@gmail.com>
Signed-off-by: NeilBrown <neilb@suse.de>
2013-08-26 15:24:53 +10:00
NeilBrown 4c0ea7b0d9 super1: fix setting of data_offset for 1.0 metadata.
commit 23bf42cc79
    super1: simplify setting of array size.

removed the setting for sb->data_offset for 1.0 metadata for some reason,
and messed up the size calculation for 1.0 metadata too.

Signed-off-by: NeilBrown <neilb@suse.de>
2013-08-14 17:16:35 +10:00
NeilBrown 632dc30ccf Fix bug with adding to 0.90 array
commit 7ccc4cc4fc
    Manage: remove call to validate_geometry.

used entirely the wrong number for "4TB" !!

Signed-off-by: NeilBrown <neilb@suse.de>
2013-08-14 15:20:02 +10:00
mwilck@arcor.de 5daa35ac1a DDF: ddf_open_new: check device status for new subarray
It is possible that mdadm creates a new subarray containing failed
devices. This may happen if a device has failed, but the meta data
containing that information hasn't been written out yet.

This code tests for this situation, and handles it in the monitor.

Signed-off-by: Martin Wilck <mwilck@arcor.de>
Signed-off-by: NeilBrown <neilb@suse.de>
2013-08-08 10:33:21 +10:00
mwilck@arcor.de 82c8e664cc tests/10ddf-fail-create-race: test handling of fail/create race
If a disk fails and simulaneously a new array is created, a race
condition may arise because the meta data on disk doesn't reflect
the disk failure yet. This is a test for that case.

Signed-off-by: Martin Wilck <mwilck@arcor.de>
Signed-off-by: NeilBrown <neilb@suse.de>
2013-08-08 09:56:13 +10:00
mwilck@arcor.de 2bcf1873d0 tests/10ddf-fail-spare: more sophisticated result checks
This test can succeed two ways, depending on timing.

Signed-off-by: Martin Wilck <mwilck@arcor.de>
Signed-off-by: NeilBrown <neilb@suse.de>
2013-08-08 09:55:33 +10:00
mwilck@arcor.de e7f9c72024 tests/10ddf-fail-two-spares: new unit test
This is one more unit test for failure/recovery, this time with
double redundancy, which isn't covered by the other tests.

Signed-off-by: NeilBrown <neilb@suse.de>
2013-08-08 09:37:12 +10:00
NeilBrown 2538ba2abf Create: fix warning about pre-existing filesystems.
An ext[234] filesystem larger than 2TB was beign reported with
a negative size - which looks odd.

So fix it to use suitably large and unsigned values.

Reported-by: Jan Engelhardt <jengelh@inai.de>
Signed-off-by: NeilBrown <neilb@suse.de>
2013-08-08 09:16:43 +10:00
NeilBrown 3921e41a9d DDF: Write new conf entries with a single write.
The recent change to skip over invalid conf entries was bad because
it could leave garbage on the disk.
But we don't to write each entry separately as the writes a O_DIRECT
and so synchronous so it takes way too long.

So allocate a large buffer (probably the one used to read the config records)
and fill that then write it all at once.

Reported-by: Martin Wilck <mwilck@arcor.de>
Signed-off-by: NeilBrown <neilb@suse.de>
2013-08-07 17:09:24 +10:00
mwilck@arcor.de 7d8a70bf23 test: allow LVM volumes or RAM disks as test devices
Allow other device types for testing; this allows to test on
a larger variety of devices.

Option --dev=[loop|lvm|ram] selects loop device (default), lvm,
and ram disk, respecively. To use RAM disks with DDF,
the kernel parameter ramdisk_size=65536 must be used.
For LVM, use --volgroup=<vg> to specify the name of the volume
group in which the test LVs will be created.

Signed-off-by: Martin Wilck <mwilck@arcor.de>
Signed-off-by: NeilBrown <neilb@suse.de>
2013-08-06 09:56:21 +10:00
mwilck@arcor.de 60056e1c3d DDF: get_extents: don't allocate space on failed disks
We should skip known failed disks when allocating space for
new arrays. This fixes the problem with 10ddf-fail-spare.

Signed-off-by: Martin Wilck <mwilck@arcor.de>
Signed-off-by: NeilBrown <neilb@suse.de>
2013-08-06 09:54:47 +10:00
mwilck@arcor.de 6b924b1e9f tests/10ddf-fail-spare: new unit test
This is Albert Pauw's latest test. Note that this FAILS.

Signed-off-by: Martin Wilck <mwilck@arcor.de>
Signed-off-by: NeilBrown <neilb@suse.de>
2013-08-06 09:54:42 +10:00
mwilck@arcor.de 635ac286c3 tests/10ddf-fail-twice: remove hard-coded assumptions
This test has some randomness because it is not always deterministic
which of the two arrays gets the spare and which remains degraded.
Handle it.

Signed-off-by: Martin Wilck <mwilck@arcor.de>
Signed-off-by: NeilBrown <neilb@suse.de>
2013-08-06 09:52:58 +10:00
mwilck@arcor.de ee7d0c09cd tests/env-ddf-template: some helper functions
helper functions to determine the list of devices in an array,
etc.

Signed-off-by: Martin Wilck <mwilck@arcor.de>
Signed-off-by: NeilBrown <neilb@suse.de>
2013-08-06 09:52:58 +10:00
NeilBrown ebf916c526 Makefile: check that 'run' directory exists.
mdadm default to using /run/mdadm.  However not all distros
provide /run yet.  This can confuse people who build their own
mdadm.
So have "make" complain if the given directory doesn't exist.
This will make it harder to build an mdadm which doesn't work.

Reported-by: Albert Pauw <albert.pauw@gmail.com>
Signed-off-by: NeilBrown <neilb@suse.de>
2013-08-05 16:42:12 +10:00
NeilBrown e49a8a8026 mdmon: don't use 'ghost' values from an inactive array.
It is possible for mdmon to see (in /proc/mdstat) and array
in 'inactive' state, "mdadm -S" has written "inactive" to
"array_state".

In this state values such as "raid_disk" are not meaningful
and so should be ignored by manage_member().

Reported-by: "Dorau, Lukasz" <lukasz.dorau@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
2013-08-05 15:40:16 +10:00
NeilBrown 92939eb291 DDF: fix removal of failed devices.
Commit c7079c84 arrange for DDF to forget about any device
that is failed and not still marked as part of any array.

However such devices could still be part of the container and this
removal and updating of 'pdnum' can result in multiple devices having
the same pdnum.  This in turn easily leads to confusion and
corruption.

So only discard pd entries for devices which are failed, not listed in
any virtual device, and for which we don't have a handle on the
device.

pd entries will not get removed until a new device is added after
the device has been removed from the container, either by
"mdadm --remove" or by assembling without the failed devices.

Reported-by: Albert Pauw <albert.pauw@gmail.com>
Analysed-by: Martin Wilck <mwilck@arcor.de>
Signed-off-by: NeilBrown <neilb@suse.de>
2013-08-05 15:10:05 +10:00
NeilBrown 9540cc244d test: ensure testing uses correct mdmon
When testing we want to run mdmon directly, not use
systemctl to get systemd to run it.

So allow an environment variable to make that choice.

Signed-off-by: NeilBrown <neilb@suse.de>
2013-08-05 14:55:13 +10:00
NeilBrown 4389b648bb managemon: fix typo affecting incrmental assembly.
This clearly should be 'st2'.
As it is the 'raid_disk' value being tested is completely
meaningless in the context of the new device.

Signed-off-by: NeilBrown <neilb@suse.de>
2013-08-05 14:25:15 +10:00
NeilBrown ce45c81986 DDF: fix writing metadata updates.
Recent commit 273989b93a
skipped writing some large blocks of 0xFF, but didn't seek
over the space, so subsequent data was written wrongly.

When we don't write, we need to seek.

Signed-off-by: NeilBrown <neilb@suse.de>
2013-08-05 14:21:10 +10:00
mwilck@arcor.de 57631ca2ff tests/10ddf-fail-twice: New unit test
This is the test by Albert Pauw. Fail 2 disks, and add one.

Signed-off-by: Martin Wilck <mwilck@arcor.de>
Signed-off-by: NeilBrown <neilb@suse.de>
2013-08-05 12:04:56 +10:00
mwilck@arcor.de 9591a2de77 DDF: no need for GET_LAYOUT any more
With the previous patch, mdmon will provide the layout property for us.

Signed-off-by: Martin Wilck <mwilck@arcor.de>
Signed-off-by: NeilBrown <neilb@suse.de>
2013-08-05 11:31:56 +10:00
mwilck@arcor.de 0c5d6054e4 mdmon: always get layout from sysfs
commit 71d68ff62 uses the array layout. It needs to be initialized.

Signed-off-by: Martin Wilck <mwilck@arcor.de>
Signed-off-by: NeilBrown <neilb@suse.de>
2013-08-05 11:31:56 +10:00
NeilBrown a9c1584757 mdmon: don't lie to systemd.
Now that mdmon responds fairly well to SIGTERM, stop lying to
systemd about being started on the initrd.

Note that if mdmon is rerun (--takeover) for some reason, and systemd
chooses to kill processes before remounting / readonly, then the
unmount will hang.

If systemd ever lets us tell it that we don't want to be killed until
root is readonly, then we should do that.

Signed-off-by: NeilBrown <neilb@suse.de>
2013-08-01 15:59:24 +10:00
NeilBrown 2ef219630b mdmon: clear safe_mode_delay on shutdown
When we receive a signal, set the safemode delay to v.small
so that we can ge clean arrays and exit quickly

Signed-off-by: NeilBrown <neilb@suse.de>o
2013-08-01 15:54:24 +10:00
NeilBrown 273989b93a DDF: differentiate between new metadata and metadata updates.
When writing an update, we don't need to overwrite lots of
empty fields.  This makes updates somewhat faster.

Signed-off-by: NeilBrown <neilb@suse.de>
2013-08-01 15:33:19 +10:00
NeilBrown cc83a81972 DDF: use some #defines instead of bare constants.
Signed-off-by: NeilBrown <neilb@suse.de>
2013-08-01 15:21:24 +10:00
NeilBrown bc17158dcc Introduce devid2kname - slightly different to devid2devnm.
The purpose od devid2devnm is to return a kernel name of an
md device, whether that device is a whole device or a partition,
we want the whole device.  md4, never md4p2.

In one place I was using devid2devnm where I really wanted the
partition if there was one ... and wasn't really interested in it
being an md device.
So introduce a new 'devid2kname' for that case.

Signed-off-by: NeilBrown <neilb@suse.de>
2013-08-01 14:32:04 +10:00
NeilBrown 879982efa9 Don't lie to systemd about mdadm's status.
Telling systemd that mdadm was started from the initrd
is often a lie and never necessary.  Now that the reshape monitoring
thread handles SIGTERM gracefully it is OK for system to kill
and mdadm that it finds running.

mdmon still have a bit of a question mark over it so I won't remove
the '@' from there just yet.

Signed-off-by: NeilBrown <neilb@suse.de>
2013-08-01 14:04:07 +10:00
NeilBrown 84d11e6c6a Grow: exit background thread cleanly on SIGTERM.
If the mdadm thread that monitors a reshape gets SIGTERM it should
exit cleanly and clear the 'suspended' region of the array.
However it mustn't clear 'sync_max' as that would allow the
reshape to continue unmonitored.

If the thread ever does get killed, the array should really be
shutdown soon after if possible.

Signed-off-by: NeilBrown <neilb@suse.de>
2013-08-01 13:58:10 +10:00
Martin Wilck d81cc6a72e tests/env-ddf-template: helper for new unit test
I forgot to check in this helper script, similar to the one for IMSM.
It is needed by tests/10ddf-create-fail-rebuild.

Signed-off-by: Martin Wilck <mwilck@arcor.de>
Signed-off-by: NeilBrown <neilb@suse.de>
2013-07-31 16:48:57 +10:00
Martin Wilck 08b0ef8e50 tests/10ddf-create-fail-rebuild: new unit test for DDF
This test adds a new unit test similar to 009imsm-create-fail-rebuild.
With the previous patches, it actually succeeds on my system.

Signed-off-by: Martin Wilck <mwilck@arcor.de>
Signed-off-by: NeilBrown <neilb@suse.de>
2013-07-31 13:04:07 +10:00