Commit Graph

3057 Commits

Author SHA1 Message Date
NeilBrown 56bbc588f7 Assemble: change load_devices to return most_recent 'st' value.
This means that

	st->ss->getinfo_super(st, content, NULL);
	clean = content->array.state & 1;

will get an up-to-date value for 'clean'.  This fix allows
  tests/03r5assem-failed
to work.

Signed-off-by: NeilBrown <neilb@suse.de>
2014-02-25 15:04:16 +11:00
NeilBrown 9ee314dab9 Assemble: re-arrange freeing of 'tst' in load_devices().
When we return in error, we need to free(tst), and ->free_super(tst);
Sometimes we didn't.

Also the final ->free_super(tst) should be followed by free(tst)
but wasn't.

Move that file free forward in the code a bit as we will want to use
the tst there in the next patch.

Signed-off-by: NeilBrown <neilb@suse.de>
2014-02-25 14:59:12 +11:00
NeilBrown df842e69a3 Assemble: allow load_devices to change the 'st' which is passed in.
The given 'st' might not be best.  Making this interface change
will allow load_devices to return a better 'st'.

Signed-off-by: NeilBrown <neilb@suse.de>
2014-02-25 14:54:34 +11:00
NeilBrown 06f3dae93a New test: 03r5assem-failed
This test currently fails, confirming a bug which was recently
reported.

Signed-off-by: NeilBrown <neilb@suse.de>
2014-02-25 14:52:14 +11:00
Piergiorgio Sartor 237e40cef2 raid6check.c: reduce verbosity
This patch will remove some legacy code.
It is part of the verbosity "cleanup".
In any case, if information about the P
and Q parity mismatches is required, it
should go inside the code handling page
size blocks, not full stripe size.

Signed-off-by: NeilBrown <neilb@suse.de>
2014-02-06 09:28:24 +11:00
Piergiorgio Sartor e645b3417c raid6check.c: add O_SYNC to open
It could be better to make sure the
data reaches the disks, so open the
drives with O_SYNC flag.

Signed off: piergiorgio.sartor@nexgo.de

Signed-off-by: NeilBrown <neilb@suse.de>
2014-02-04 16:06:46 +11:00
Piergiorgio Sartor 21d648132a raid6check.c: fix Q parity generation
In the transition to 4K page processing,
the Q parity generation had a wrong offset
in the buffer.
This patche fix this.

Signed off: piergiorgio.sartor@nexgo.de

Signed-off-by: NeilBrown <neilb@suse.de>
2014-02-04 16:06:46 +11:00
Piergiorgio Sartor afc755e9a6 raid6check.c: fix position printout
This patch make a bit more clear
the position, in the disk, where
an error is found.

Signed off: piergiorgio.sartor@nexgo.de

Signed-off-by: NeilBrown <neilb@suse.de>
2014-02-04 16:06:46 +11:00
Piergiorgio Sartor 15c1bfb34c raid6check.c: reduce verbosity
This patch removes some printouts, which
are not really useful here.
These could be re-added later, in case a
verbosity parameter will be provided.

Signed off: piergiorgio.sartor@nexgo.de

Signed-off-by: NeilBrown <neilb@suse.de>
2014-02-04 16:06:46 +11:00
Piergiorgio Sartor 3b9c96032c raid6check.c add page size check and repair
raid6check current performs checks and repair on a whole chunk at a
time.  This is often not ideal as corruption can happen with smaller
granularity.

This patches changes raid6check to use a page-size (4K) granularity.

We still process a chunk at a time, but within each chunk we process a
page at a time.

Signed-off-by: NeilBrown <neilb@suse.de>
2014-01-23 12:18:35 +11:00
NeilBrown 1f6b069494 mdmon@.service: remove over-ride of Standard IO.
Redirecting output to /dev/null is unnecessary and hides any error
messages there might be.  So leave as defaults which are none,
journal, inherit.

Signed-off-by: NeilBrown <neilb@suse.de>
2014-01-22 12:53:31 +11:00
NeilBrown 67ee238316 systemd/mdmon: set IMSM_NO_PLATFORM=1
As mdmon doesn't inherit environment from mdadm when it is started
by system, it cannot inherit IMSM_NO_PLATFORM.
But if an imsm array as assembled then mdmon really should handle it
whether there is a platform present or not.
So always set this var.

Signed-off-by: NeilBrown <neilb@suse.de>
2014-01-21 09:46:07 +11:00
NeilBrown 5e57245e3f mdmon: don't complain about notifying parent when there is no need
When run with --foreground mdmon has no need to notify any
parent, so it shouldn't even try, let alone complain when it fails.

Also close an end of a pipe which is no longer used.

Signed-off-by: NeilBrown <neilb@suse.de>
2014-01-21 09:43:31 +11:00
NeilBrown 1ca5c8e0c7 IMSM: don't crash when creating an array with missing devices.
'missing' devices are in a different list so when collection the
serial numbers of all devices we need to check both lists.

Signed-off-by: NeilBrown <neilb@suse.de>
2014-01-21 09:40:02 +11:00
NeilBrown 5e7be83894 Grow: fix problems with prematurely aborting of reshapes.
1/ when unfreezing, make sure the array is frozen first.
   If it isn't we might end up interrupting a reshape.
2/ When the child finishes, don't call abort_reshape() as that
   will interrupt the reshape.  Just set suspend_* etc
   explicitly.

Signed-off-by: NeilBrown <neilb@suse.de>
2014-01-20 15:31:45 +11:00
NeilBrown f0e876ce03 DDF: fix detection of failed devices during assembly.
When we call "getinfo_super", we report the working/failed status
of the particular device, and also (via the 'map') the working/failed
status of every other device that this metadata is aware of.

It is important that the way we calculate "working or failed" is
consistent.
As it is, getinfo_super_ddf() will report a spare as "working", but
every other device will see it as "failed", which leads to failure to
assemble arrays with spares.

For getinfo_super_ddf (i.e. for the container), a device is assumed
"working" unless flagged as DDF_Failed.
For getinfo_super_ddf_bvd (for a member array), a device is assumed
"failed" unless DDF_Online is set, and DDF_Failed is not set.

Reported-by: "David F." <df7729@gmail.com>
Signed-off-by: NeilBrown <neilb@suse.de>
2014-01-20 15:27:29 +11:00
NeilBrown 284546ef89 Assemble: avoid infinite loop when auto-assembling partial container.
When auto-assembling we loop until we get no successes.

If a device is found that look like it is part of an already-existing
container, but we subsequently fail to add that device, then the fact
that the container is running looks like a success.  This can result
in infinite looping.
So if a container was already partially assemble, and is still only
partially assembled after we try to add devices, then don't treat that
as success.

Signed-off-by: NeilBrown  <neilb@suse.de>
2014-01-20 15:23:31 +11:00
NeilBrown a34fea0eae DDF - really ignore DDF metadata on partitions.
See commit 357ac10678
which made a similar change for super-intel, and really should have
fixed DDF at the same time.

Signed-off-by: NeilBrown <neilb@suse.de>
2014-01-20 12:25:23 +11:00
Lukasz Dorau 75a721fd7d policy: NULL path isn't really acceptable - use the devname
According to:
	commit b451aa4846
	Fix handling for "auto" line in mdadm.conf

a NULL path isn't really acceptable and the devname should be used instead.

Signed-off-by: Lukasz Dorau <lukasz.dorau@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
2014-01-06 17:09:19 +11:00
Jan Ceuleers 2ca20929fa Clarify scope of Rebuild events in mdadm manpage
To date, the manpage did not make it clear under which circumstances
Rebuild events are generated, leading to a question on the mailing
list as to whether it is normal for these events to be generated
while checking an array.
So clarify that all operations that act on the entire array are in
scope. The list is given as "e.g.", because it might grow in the
future as other full-array operations are added.

Reported-by: Mark Knecht <markknecht@gmail.com>
Signed-off-by: Jan Ceuleers <jan.ceuleers@computer.org>
Signed-off-by: NeilBrown <neilb@suse.de>
2013-12-12 13:25:29 +11:00
NeilBrown 79d8213f29 mdamd-last-resort: add a Conflicts line to stop the timer.
When the md device actually appears we want to stop the timer and not
bother with the mdadm-last-resort@.server.  In particular, running
that causes confusing messages and is in general best avoided.

Fortuantely this can simply be achieved with a Conflicts= line

Signed-off-by: NeilBrown <neilb@suse.de>
2013-12-12 13:20:32 +11:00
NeilBrown 25392f5fc5 udev rules: try "mdadm -I" on "change" events.
We need to attempt "mdadm -I" on "change" events as well as "add" events,
as the "change" make make a device ready to be part of an array.
This is particularly important for stacked md devices. When the
member devices are "add"ed they don't have any content visible yet.
That doesn't happen until a "change".

Idea taken from Fedora udev file.

Signed-off-by: NeilBrown <neilb@suse.de>
2013-12-11 12:29:22 +11:00
NeilBrown 05ec50a57b udev rules: add some by-pass rules from Fedora
1/ If ANACONDA is running, don't -I assemble any arrays, ANACONDA
   needs to be in control
2/ honour "noiswmd" and "nodmraid" kernel command line options.

Signed-off-by: NeilBrown <neilb@suse.de>
2013-12-11 12:25:02 +11:00
NeilBrown 61c0947158 Add mdmonitor.service systemd unit file.
This systemd unit file runs mdadm in --monitor mode.
It is started by a SYSTEMD_WANTS signal from udev whenever
an md array is started that would benefit from mdadm --monitor.

Commandline arguments can be provided by a script
  /usr/lib/systemd/scripts/mdadm_env.sh
which should write an
  MDADM_MONITOR_ARGS=....
line to /run/sysconfig/mdadm

A script to extra args from SUSE's /etc/sysconfig/mdadm file
is provided.
If no mdadm_env.sh is provided, then args are "--scan" which
requires "mail" or "program" to be set in /etc/mdadm.conf.
I believe this is suitable for Fedora.

Signed-off-by: NeilBrown <neilb@suse.de>
2013-12-11 10:47:54 +11:00
NeilBrown 8832342d3a Assemble/Incremental: don't hold O_EXCL on mddev after assembly.
As soon as the array is assembled, udev or systemd might run
fsck and mount it.  So we need to drop O_EXCL promptly.

Signed-off-by: NeilBrown <neilb@suse.de>
2013-12-05 10:35:16 +11:00
NeilBrown 5dd29dafa2 Two small fixes related to enough()
1/ enough_fd doesn't use avail_disks any more, so discard it.

2/ Manage_Add increments 'found' at the wrong place, so it can
   waste time before calling enough().

Signed-off-by: NeilBrown <neilb@suse.de>
2013-12-05 08:58:21 +11:00
NeilBrown b11fe74db0 Incremental: improve support for "DEVICE" based restriction in mdadm.conf
--incremental currently fails if the device name passed does not
textually match the names permitted by the DEVICE line in mdadm.conf.
This is problematic when "mdadm -I" is run by udev as the name given
can be a temp name.

This patch makes two improvements:
1/ We generate a list of all existing devices that match the names
  in mdadm.conf, and allow rdev based matching
2/ We allows extra aliases to be provided on the command line, and
  perform textual matching on those.  This is particularly suitable
  for udev usages as ${DEVLINKS} can be provided even though the links
  make not yet be created.

Signed-off-by: NeilBrown <neilb@suse.de>
2013-12-03 14:01:24 +11:00
NeilBrown 169ffac7ad Systemd integration for starting newly-degraded arrays.
Normally "mdadm -I" will not start an array if it has reason to
expect further devices.
This means that if a device is removed while the host is shut down,
"mdadm -I" will never start the device.

If  the array is know to the host, it make sense to start the array
anyway after a reasonable timeout.

This patch adds systemd/udev infrastructure so that 30 seconds after
a known array first becomes able to be assembled as a degraded array,
the array will be assembled even if more devices are still expected.

Signed-off-by: NeilBrown <neilb@suse.de>
2013-12-02 16:08:04 +11:00
NeilBrown 9ca39acb3e Incremental: add --export handling.
If --export is given with --incremental, then
  MD_DEVNAME
is output which gives the name of the device (in /dev/md) that
is the array (or container) that the device would be added to.
Also
  MD_STARTED
is set to one of
  no
  unsafe
  yes
  nothing

to indicate if the array was started.  IF MD_STARTED=unsafe
then it may be appropriate to run
  mdadm -R /dev/md/$MD_DEVNAME
after a timeout to ensure newly degraded array are started.

If
  MD_FOREIGN=yes
it might be appropriate to suppress this as the array is
probably not critical.

Signed-off-by: NeilBrown <neilb@suse.de>
2013-11-28 15:15:30 +11:00
NeilBrown c1736844ba Restructure assemble_container_content and improve messages.
We lose one level of indent, and now get told the difference between
'not assemble because not safe' and 'not assembled because not enough
devices'.

Signed-off-by: NeilBrown <neilb@suse.de>
2013-11-28 14:47:41 +11:00
NeilBrown eb8b951657 Incremental: don't abort container if one member explicitly disabled.
If a member of a container is explicitly disabled, others may not
be so we should continue.

Signed-off-by: NeilBrown <neilb@suse.de>
2013-11-28 13:33:56 +11:00
NeilBrown 2e44767fc2 Incremental: remove test that can never succeed.
Incremental_container never returns 1, so this test is pointless.
It is a holdover from when we called "Incremental()" rather than
"Incremental_container()" at this point.

Signed-off-by: NeilBrown <neilb@suse.de>
2013-11-28 13:30:23 +11:00
NeilBrown 357ac10678 IMSM metadata really should be ignored when found on partitions.
commit b31df43682
changed load_super_imsm to not insist on finding a partition if
ignore_hw_compat was set.
Unfortunately this is set for '--assemble' so arrays could get
assembled badly.

The comment says this was to allow e.g. --examine of image files.
A better fixes for this is to change test_partitions to not report
a regular file as being a partition.
The errors from the BLKPG ioctl are:

 ENOTTY : not a block device.
 EINVAL : not a whole device (probably a partition)
 ENXIO  : partition doesn't exist (so not a partition)

Reported-by: "David F." <df7729@gmail.com>
Signed-off-by: NeilBrown <neilb@suse.de>
2013-11-20 10:49:14 +11:00
NeilBrown be4a3188f6 ddf tests: fix get_rootdev
Getting the major number from the hex device number should take
all-but-the-last-two digits, rather than just the first two digits.

Signed-off-by: NeilBrown <neilb@suse.de>
2013-11-19 16:40:09 +11:00
NeilBrown f33a71f107 Add support for --add-spare
--add-spare is like --add, but a --re-add is never attempted.
So it is equivalent to two separate commands:

 --zero-metadata
 --add

Signed-off-by: NeilBrown <neilb@suse.de>
2013-10-31 10:41:50 +11:00
John Schmidt 422da715d9 Fix typos in mdadm.8.in
I found a small bug in the documentation of mdadm.  I fixed it in my
local git clone of git://neil.brown.name/mdadm  Here is the change:


Signed-off-by: NeilBrown <neilb@suse.de>
2013-10-30 08:33:19 +11:00
NeilBrown f81a2b56c4 Assembe: fix bug in force_array - it wasn't forcing properly.
Since 'best' was expanded to hold replacement devices, we might
need to go up to raid_disks*2 to find devices to force.

Also fix another place when considering replacement drives would
be wrong (the 'chosen' device should never be a replacement).

Reported-by: John Yates <jyates65@gmail.com>
Signed-off-by: NeilBrown <neilb@suse.de>
2013-10-22 09:55:04 +11:00
mwilck@arcor.de a4921f30ec Monitor: write meta data in readonly state, sometimes
This patch reverts 24a216bf:
"Monitor: Don't write metadata in inactive array state".

While it's true that writing meta data is usually not necessary
in readonly state, there is one important exception: if a
disk goes faulty, we want to record that, even if the array is
inactive.

We might as well just revert 24a216bf, because with the recently
submitted patch
"Monitor: don't set arrays dirty after transition to read-only"
those meta data writes that really annoying (for a clean, readonly,
healthy array during startup) are gone anyway.

Signed-off-by: Martin Wilck <mwilck@arcor.de>
Signed-off-by: NeilBrown <neilb@suse.de>
2013-10-16 15:31:30 +11:00
mwilck@arcor.de 21529ab377 tests/10ddf-incremental-wrong-order: new unit test
This is a test simulating two temporary missing disks. These will
have less recent meta data than the other disks in the container.
When the array is reassembled, we expect mdadm to detect that
and react to it by using the meta data of the more recent disks
as reference.

This test FAILS with mdadm 3.3 for DDF.

Signed-off-by: Martin Wilck <mwilck@arcor.de>
Signed-off-by: NeilBrown <neilb@suse.de>
2013-10-16 15:31:30 +11:00
mwilck@arcor.de c17d3b5cfd tests/10ddf-assemble-missing: new unit test
This is a test case for handling incremental
assembly correctly after disks had been missing once.

This test is the basis for other similar but more tricky
test cases involving inconsitent meta data.

Signed-off-by: Martin Wilck <mwilck@arcor.de>
Signed-off-by: NeilBrown <neilb@suse.de>
2013-10-16 15:31:30 +11:00
mwilck@arcor.de e00d9c10c1 tests/env-ddf-template: add helper function for checksums
Signed-off-by: Martin Wilck <mwilck@arcor.de>
Signed-off-by: NeilBrown <neilb@suse.de>
2013-10-16 15:31:30 +11:00
mwilck@arcor.de d5b8e34061 tests/10ddf-fail-readd-readonly: new unit test.
A test for my recent patch "Monitor: write meta data in readonly state,
sometimes". Test that a faulty disk is recorded in the meta data.

Signed-off-by: Martin Wilck <mwilck@arcor.de>
Signed-off-by: NeilBrown <neilb@suse.de>
2013-10-16 15:31:30 +11:00
mwilck@arcor.de ab77d284a6 tests/env-ddf-template: fix container name
/dev/md/ddf0 works also with assembly. /dev/md/ddf doesn't.

Signed-off-by: Martin Wilck <mwilck@arcor.de>
Signed-off-by: NeilBrown <neilb@suse.de>
2013-10-16 15:31:30 +11:00
mwilck@arcor.de 105e6e93a2 DDF: add_to_super_ddf: be careful with workspace_lba
Some vendor DDF structures interpret workspace_lba
very differently then us. Make a sanity check on the value
before using it for config_size.

Signed-off-by: Martin Wilck <mwilck@arcor.de>
Signed-off-by: NeilBrown <neilb@suse.de>
2013-10-16 15:31:30 +11:00
mwilck@arcor.de f502b11c74 tests/10ddf-fail-stop-readd: New DDF unit test
This is similar to 10ddf-fail-readd. The difference is that the
array is stopped and incrementally assembled before the disk is
re-added.

Signed-off-by: NeilBrown <neilb@suse.de>
2013-10-16 15:29:43 +11:00
mwilck@arcor.de 58c96b6b1e tests/10ddf-fail-readd: New DDF unit test
This unit test is for a simple fail/remove/readd scenario.

Signed-off-by: NeilBrown <neilb@suse.de>
2013-10-16 15:29:43 +11:00
mwilck@arcor.de 7bb1d61354 Monitor: don't set arrays dirty after transition to read-only
This patch reverts commit 4867e068. Setting arrays dirty after
transition from inactive to anything else causes unnecessary
meta data writes and may wreak trouble unnecessarily when
a disk was missing during assembly but the array was never
written to.

The reason for 4867e068 was a special situation during reshape
from RAID0 to RAID4. I ran all IMSM test cases with it reverted
and found no regressions, so I believe the reshape logic for
IMSM works fine in mdadm 3.3 also without this.

Signed-off-by: Martin Wilck <mwilck@arcor.de>
Signed-off-by: NeilBrown <neilb@suse.de>
2013-10-16 15:29:43 +11:00
mwilck@arcor.de 7039479987 DDF: compare_super_ddf: fix sequence number check
The sequence number check in compare_super_ddf was broken,
anchor sequence number is always -1.

With this patch, mdadm will refuse to add a disk with non-matching
sequence number.

This fixes Francis Moreau's problem reported with subject
"mdadm 3.3 fails to kick out non fresh disk".

FIXME: More work is needed here. Currently mdadm won't even add the
disk to the container, that's wrong. It should be added as a spare.

Signed-off-by: NeilBrown <neilb@suse.de>
2013-10-16 15:29:43 +11:00
mwilck@arcor.de aa0faa10b2 DDF test: make sure mdmon isn't started by systemd
For testing we usually want the locally built mdmon, not the
one systemd prefers.

Signed-off-by: NeilBrown <neilb@suse.de>
2013-10-16 15:29:42 +11:00
mwilck@arcor.de 1a2872fe9a DDF tests: allow to run on systems without /dev/sda
Some ddf tests scripts assume that /dev/sda is always present.
That's wrong e.g. on VMs. Use a more general approach.

Signed-off-by: NeilBrown <neilb@suse.de>
2013-10-16 15:29:42 +11:00