]> git.ipfire.org Git - thirdparty/mdadm.git/log
thirdparty/mdadm.git
10 years agoIMSM metadata really should be ignored when found on partitions.
NeilBrown [Tue, 19 Nov 2013 23:49:14 +0000 (10:49 +1100)] 
IMSM metadata really should be ignored when found on partitions.

commit b31df43682216d1c65813eae49ebdd8253db8907
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>
10 years agoddf tests: fix get_rootdev
NeilBrown [Tue, 19 Nov 2013 05:40:09 +0000 (16:40 +1100)] 
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>
10 years agoAdd support for --add-spare
NeilBrown [Wed, 30 Oct 2013 23:41:50 +0000 (10:41 +1100)] 
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>
10 years agoFix typos in mdadm.8.in
John Schmidt [Tue, 29 Oct 2013 17:16:18 +0000 (10:16 -0700)] 
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>
10 years agoAssembe: fix bug in force_array - it wasn't forcing properly.
NeilBrown [Mon, 21 Oct 2013 22:55:04 +0000 (09:55 +1100)] 
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>
10 years agoMonitor: write meta data in readonly state, sometimes
mwilck@arcor.de [Tue, 24 Sep 2013 18:53:18 +0000 (20:53 +0200)] 
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>
10 years agotests/10ddf-incremental-wrong-order: new unit test
mwilck@arcor.de [Wed, 25 Sep 2013 20:42:02 +0000 (22:42 +0200)] 
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>
10 years agotests/10ddf-assemble-missing: new unit test
mwilck@arcor.de [Wed, 25 Sep 2013 20:42:01 +0000 (22:42 +0200)] 
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>
10 years agotests/env-ddf-template: add helper function for checksums
mwilck@arcor.de [Wed, 25 Sep 2013 20:42:00 +0000 (22:42 +0200)] 
tests/env-ddf-template: add helper function for checksums

Signed-off-by: Martin Wilck <mwilck@arcor.de>
Signed-off-by: NeilBrown <neilb@suse.de>
10 years agotests/10ddf-fail-readd-readonly: new unit test.
mwilck@arcor.de [Tue, 24 Sep 2013 19:17:22 +0000 (21:17 +0200)] 
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>
10 years agotests/env-ddf-template: fix container name
mwilck@arcor.de [Tue, 24 Sep 2013 19:17:21 +0000 (21:17 +0200)] 
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>
10 years agoDDF: add_to_super_ddf: be careful with workspace_lba
mwilck@arcor.de [Tue, 24 Sep 2013 17:18:52 +0000 (19:18 +0200)] 
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>
10 years agotests/10ddf-fail-stop-readd: New DDF unit test
mwilck@arcor.de [Mon, 23 Sep 2013 19:40:01 +0000 (21:40 +0200)] 
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>
10 years agotests/10ddf-fail-readd: New DDF unit test
mwilck@arcor.de [Mon, 23 Sep 2013 19:40:00 +0000 (21:40 +0200)] 
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>
10 years agoMonitor: don't set arrays dirty after transition to read-only
mwilck@arcor.de [Sat, 14 Sep 2013 21:24:07 +0000 (23:24 +0200)] 
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>
10 years agoDDF: compare_super_ddf: fix sequence number check
mwilck@arcor.de [Sat, 14 Sep 2013 20:47:12 +0000 (22:47 +0200)] 
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>
10 years agoDDF test: make sure mdmon isn't started by systemd
mwilck@arcor.de [Sat, 14 Sep 2013 20:47:11 +0000 (22:47 +0200)] 
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>
10 years agoDDF tests: allow to run on systems without /dev/sda
mwilck@arcor.de [Sat, 14 Sep 2013 20:47:10 +0000 (22:47 +0200)] 
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>
10 years agoBe consistent in return types from byteswap macros
Jes Sorensen [Thu, 10 Oct 2013 07:42:05 +0000 (09:42 +0200)] 
Be consistent in return types from byteswap macros

The bswap_*() macros return int values. Make sure we return the
equivalent types in same byteorder pass-through functions to avoid
problems with the original type leaking through to printf() etc.

Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
Signed-off-by: NeilBrown <neilb@suse.de>
10 years agoRemove bashism from Makefile
Michael Tokarev [Tue, 17 Sep 2013 16:20:40 +0000 (20:20 +0400)] 
Remove bashism from Makefile

Makefile uses [ x == y ] construct which does not work
with POSIX shell.  Since this is just testing a flag,
replace it with string comparison (=) operator instead.

Signed-off-By: Michael Tokarev <mjt@tls.msk.ru>
Signed-off-by: NeilBrown <neilb@suse.de>
10 years agoGive error if --incremental --scan also has a device name given.
NeilBrown [Sat, 14 Sep 2013 23:14:25 +0000 (09:14 +1000)] 
Give error if --incremental --scan also has a device name given.

Signed-off-by: NeilBrown <neilb@suse.de>
10 years agoMake -IRs and --run work properly for containers.
NeilBrown [Fri, 13 Sep 2013 00:51:20 +0000 (10:51 +1000)] 
Make -IRs and --run work properly for containers.

We really need to make sure assemble_container_content()
gets called to finished the assembly of these.

Reported-by: Francis Moreau <francis.moro@gmail.com>
Signed-off-by: NeilBrown <neilb@suse.de>
10 years agoDDF: brief_examine_subarrays_ddf: print array name
mwilck@arcor.de [Wed, 11 Sep 2013 19:55:35 +0000 (21:55 +0200)] 
DDF: brief_examine_subarrays_ddf: print array name

Print an array name in brief output, like IMSM does.

SUSE's YaST2 (libstorage) needs this in order to detect MD arrays
during installation.

Signed-off-by: Martin Wilck <mwilck@arcor.de>
Signed-off-by: NeilBrown <neilb@suse.de>
10 years agoDDF: factor out array name generation
mwilck@arcor.de [Wed, 11 Sep 2013 19:55:34 +0000 (21:55 +0200)] 
DDF: factor out array name generation

The same algorithm was used in getinfo_super_ddf_bvd and
container_content_ddf. Put it in a common function.

Signed-off-by: Martin Wilck <mwilck@arcor.de>
Signed-off-by: NeilBrown <neilb@suse.de>
10 years agomdmon: honour --offroot, again
mwilck@arcor.de [Wed, 11 Sep 2013 20:15:19 +0000 (22:15 +0200)] 
mdmon: honour --offroot, again

commit 3e32ba9d removed support for --offroot, and a9c15847 made
mdmon use @ in argv[0] only when started from initrd.

This breaks mdadm in OpenSUSE 12.3, which starts mdmon from the
root file system and relies on --offroot to work as documented earlier.

Reintroducing --offroot as an undocumented option, as its use is going to
go away soon anyway.

If this can't be applied, it should probably be included as distro-specific
patch if mdadm 3.3 is built for OpenSUSE 12.3. I haven't checked if the
patch is necesary for OpenSUSE Factory, too.

Signed-off-by: Martin Wilck <mwilck@arcor.de>
Signed-off-by: NeilBrown <neilb@suse.de>
10 years agoDDF: allow for possibility that there is no secondary copy of metadata.
NeilBrown [Thu, 12 Sep 2013 04:57:28 +0000 (14:57 +1000)] 
DDF: allow for possibility that there is no secondary copy of metadata.

If there isn't, we currently write the second copy at some
random location :-)

Reported-and-tested-by: Francis Moreau <francis.moro@gmail.com>
Signed-off-by: NeilBrown <neilb@suse.de>
10 years agoconfig: set "auto_seen" after processing the auto line.
NeilBrown [Tue, 10 Sep 2013 07:10:10 +0000 (17:10 +1000)] 
config: set "auto_seen" after processing the auto line.

Otherwise when we process an empty autoline (to be sure to
capture the MDADM_CONF_AUTO environment variable) we can end up
setting everything to 'yes' which over-rides 'no'.

Signed-off-by: NeilBrown <neilb@suse.de>
10 years agoMove ARRAY_SIZE macro to common include file.
NeilBrown [Mon, 9 Sep 2013 23:48:06 +0000 (09:48 +1000)] 
Move ARRAY_SIZE macro to common include file.

That was super-ddf can use it.

Signed-off-by: NeilBrown <neilb@suse.de>
10 years agoDDF: handle fake RAIDs with changing subarray UUIDs
mwilck@arcor.de [Mon, 9 Sep 2013 18:40:14 +0000 (20:40 +0200)] 
DDF: handle fake RAIDs with changing subarray UUIDs

Some fake RAID BIOSes (in particular, LSI ones) change the
VD GUID at every boot. These GUIDs are not suitable for
identifying an array. Luckily the header GUID appears to
remain constant.

We construct a pseudo-UUID from the header GUID and those
properties of the subarray that we expect to remain constant.
This is only array name and index; all else might change e.g.
during grow.

Don't do this for all non-MD arrays, only for those known
to use varying volume GUIDs.

This patch obsoletes my previous patch "DDF: new algorithm
for subarray UUID"

Signed-off-by: Martin Wilck <mwilck@arcor.de>
Signed-off-by: NeilBrown <neilb@suse.de>
10 years agoManage.c: fix small memory leak
Lukasz Dorau [Thu, 5 Sep 2013 09:16:34 +0000 (11:16 +0200)] 
Manage.c: fix small memory leak

'avail' is dynamically allocated, so it should be freed.

Signed-off-by: Lukasz Dorau <lukasz.dorau@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
10 years agomanagemon: fix a dprintk.
NeilBrown [Mon, 9 Sep 2013 23:31:18 +0000 (09:31 +1000)] 
managemon: fix a dprintk.

There is not guarantee that 'inst' is a number, and even if there
were there is no point converting it str->int and then int->str again.

Signed-off-by: NeilBrown <neilb@suse.de>
10 years agoMinor fixes in mdadm.conf.5 man page.
NeilBrown [Mon, 9 Sep 2013 23:30:55 +0000 (09:30 +1000)] 
Minor fixes in mdadm.conf.5 man page.

Signed-off-by: NeilBrown <neilb@suse.de>
10 years agoRelease mdadm-3.3 mdadm-3.3
NeilBrown [Tue, 3 Sep 2013 04:16:22 +0000 (14:16 +1000)] 
Release mdadm-3.3

(and  various cosmetic fixes)

Signed-off-by: NeilBrown <neilb@suse.de>
10 years agoconfig: support MDADM_CONF_AUTO= env var.
NeilBrown [Tue, 3 Sep 2013 03:25:02 +0000 (13:25 +1000)] 
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>
10 years agoconfig: refactor load_conffile() to have a single exit.
NeilBrown [Tue, 3 Sep 2013 00:26:06 +0000 (10:26 +1000)] 
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>
10 years agoConfig: multiple occurences of lines is not an error.
NeilBrown [Tue, 3 Sep 2013 00:05:59 +0000 (10:05 +1000)] 
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>
10 years agoconfig: read /etc/mdadm.conf.d as well as /etc/mdadm.conf
NeilBrown [Mon, 2 Sep 2013 23:29:52 +0000 (09:29 +1000)] 
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>
10 years agoConf: allow conf file to be a directory.
NeilBrown [Mon, 2 Sep 2013 23:03:56 +0000 (09:03 +1000)] 
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>
10 years agoConfig: factor reading of file out into separate function.
NeilBrown [Mon, 2 Sep 2013 22:47:57 +0000 (08:47 +1000)] 
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>
10 years agomdmon: make sure we set safe_mode on SIGTERM.
NeilBrown [Mon, 2 Sep 2013 02:08:44 +0000 (12:08 +1000)] 
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>
10 years agoAssemble: don't ever consider a 'spare' to be the 'most recent'.
NeilBrown [Mon, 2 Sep 2013 01:48:06 +0000 (11:48 +1000)] 
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>
10 years agoMake sure "mdmon" doesn't get called "@dmon".
NeilBrown [Mon, 2 Sep 2013 01:02:09 +0000 (11:02 +1000)] 
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>
10 years agoGrow: fix hang when growing a RAID5.
NeilBrown [Wed, 28 Aug 2013 07:00:53 +0000 (17:00 +1000)] 
Grow: fix hang when growing a RAID5.

Since:

commit 84d11e6c6a3b827b2daa32e16303235ce33d49f5
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>
10 years agoin_initrd: fix gcc compiler error
mwilck@arcor.de [Fri, 16 Aug 2013 18:21:59 +0000 (20:21 +0200)] 
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>
10 years agoDDF: increase default value for safe_mode_delay to 4000ms
mwilck@arcor.de [Fri, 16 Aug 2013 18:21:58 +0000 (20:21 +0200)] 
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>
10 years agoDDF: container_content_ddf: set safe_mode_delay > 0
mwilck@arcor.de [Fri, 16 Aug 2013 18:21:57 +0000 (20:21 +0200)] 
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>
10 years agoDDF: export_examine_super_ddf: print MD_DEVICES
mwilck@arcor.de [Fri, 16 Aug 2013 18:21:56 +0000 (20:21 +0200)] 
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>
10 years agoDDF: ddf_activate_spare: fix gcc -O2 uninitialized warning
NeilBrown [Fri, 16 Aug 2013 18:21:55 +0000 (20:21 +0200)] 
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>
10 years agoAdd ANNOUNCE-3.2.6 from different branch
NeilBrown [Mon, 26 Aug 2013 05:28:43 +0000 (15:28 +1000)] 
Add ANNOUNCE-3.2.6 from different branch

just for completeness...

Signed-off-by: NeilBrown <neilb@suse.de>
10 years agoAdd raid6check to .gitignore
NeilBrown [Mon, 26 Aug 2013 05:26:54 +0000 (15:26 +1000)] 
Add raid6check to .gitignore

Signed-off-by: NeilBrown <neilb@suse.de>
10 years agoChange "mdadm --run" to use the same code as "mdadm --IRs".
NeilBrown [Mon, 26 Aug 2013 05:24:53 +0000 (15:24 +1000)] 
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>
10 years agosuper1: fix setting of data_offset for 1.0 metadata.
NeilBrown [Wed, 14 Aug 2013 07:06:22 +0000 (17:06 +1000)] 
super1: fix setting of data_offset for 1.0 metadata.

commit 23bf42cc79d46de019d4b27c16354a191a98ed41
    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>
10 years agoFix bug with adding to 0.90 array
NeilBrown [Wed, 14 Aug 2013 05:20:02 +0000 (15:20 +1000)] 
Fix bug with adding to 0.90 array

commit 7ccc4cc4fc6889680bbe4ec673cab3f6aa49aad3
    Manage: remove call to validate_geometry.

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

Signed-off-by: NeilBrown <neilb@suse.de>
10 years agoDDF: ddf_open_new: check device status for new subarray
mwilck@arcor.de [Tue, 6 Aug 2013 21:38:02 +0000 (23:38 +0200)] 
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>
10 years agotests/10ddf-fail-create-race: test handling of fail/create race
mwilck@arcor.de [Tue, 6 Aug 2013 21:38:01 +0000 (23:38 +0200)] 
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>
10 years agotests/10ddf-fail-spare: more sophisticated result checks
mwilck@arcor.de [Tue, 6 Aug 2013 21:38:00 +0000 (23:38 +0200)] 
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>
10 years agotests/10ddf-fail-two-spares: new unit test
mwilck@arcor.de [Wed, 7 Aug 2013 20:38:03 +0000 (22:38 +0200)] 
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>
10 years agoCreate: fix warning about pre-existing filesystems.
NeilBrown [Wed, 7 Aug 2013 23:16:43 +0000 (09:16 +1000)] 
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>
10 years agoDDF: Write new conf entries with a single write.
NeilBrown [Wed, 7 Aug 2013 06:59:26 +0000 (16:59 +1000)] 
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>
10 years agotest: allow LVM volumes or RAM disks as test devices
mwilck@arcor.de [Mon, 5 Aug 2013 20:37:51 +0000 (22:37 +0200)] 
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>
10 years agoDDF: get_extents: don't allocate space on failed disks
mwilck@arcor.de [Mon, 5 Aug 2013 20:37:50 +0000 (22:37 +0200)] 
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>
10 years agotests/10ddf-fail-spare: new unit test
mwilck@arcor.de [Mon, 5 Aug 2013 20:37:49 +0000 (22:37 +0200)] 
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>
10 years agotests/10ddf-fail-twice: remove hard-coded assumptions
mwilck@arcor.de [Mon, 5 Aug 2013 20:37:48 +0000 (22:37 +0200)] 
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>
10 years agotests/env-ddf-template: some helper functions
mwilck@arcor.de [Mon, 5 Aug 2013 20:37:47 +0000 (22:37 +0200)] 
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>
10 years agoMakefile: check that 'run' directory exists.
NeilBrown [Mon, 5 Aug 2013 06:39:45 +0000 (16:39 +1000)] 
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>
10 years agomdmon: don't use 'ghost' values from an inactive array.
NeilBrown [Mon, 5 Aug 2013 05:40:16 +0000 (15:40 +1000)] 
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>
10 years agoDDF: fix removal of failed devices.
NeilBrown [Mon, 5 Aug 2013 04:56:23 +0000 (14:56 +1000)] 
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>
10 years agotest: ensure testing uses correct mdmon
NeilBrown [Mon, 5 Aug 2013 04:55:13 +0000 (14:55 +1000)] 
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>
10 years agomanagemon: fix typo affecting incrmental assembly.
NeilBrown [Mon, 5 Aug 2013 04:25:15 +0000 (14:25 +1000)] 
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>
10 years agoDDF: fix writing metadata updates.
NeilBrown [Mon, 5 Aug 2013 04:21:10 +0000 (14:21 +1000)] 
DDF: fix writing metadata updates.

Recent commit 273989b93a3185c0e4d54f0d1bc404248a92d157
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>
10 years agotests/10ddf-fail-twice: New unit test
mwilck@arcor.de [Thu, 1 Aug 2013 22:35:17 +0000 (00:35 +0200)] 
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>
10 years agoDDF: no need for GET_LAYOUT any more
mwilck@arcor.de [Thu, 1 Aug 2013 22:35:15 +0000 (00:35 +0200)] 
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>
10 years agomdmon: always get layout from sysfs
mwilck@arcor.de [Thu, 1 Aug 2013 22:35:14 +0000 (00:35 +0200)] 
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>
10 years agomdmon: don't lie to systemd.
NeilBrown [Thu, 1 Aug 2013 05:59:24 +0000 (15:59 +1000)] 
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>
10 years agomdmon: clear safe_mode_delay on shutdown
NeilBrown [Thu, 1 Aug 2013 05:45:17 +0000 (15:45 +1000)] 
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
10 years agoDDF: differentiate between new metadata and metadata updates.
NeilBrown [Thu, 1 Aug 2013 05:21:57 +0000 (15:21 +1000)] 
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>
10 years agoDDF: use some #defines instead of bare constants.
NeilBrown [Thu, 1 Aug 2013 05:21:24 +0000 (15:21 +1000)] 
DDF: use some #defines instead of bare constants.

Signed-off-by: NeilBrown <neilb@suse.de>
10 years agoIntroduce devid2kname - slightly different to devid2devnm.
NeilBrown [Thu, 1 Aug 2013 04:32:04 +0000 (14:32 +1000)] 
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>
10 years agoDon't lie to systemd about mdadm's status.
NeilBrown [Thu, 1 Aug 2013 04:04:07 +0000 (14:04 +1000)] 
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>
10 years agoGrow: exit background thread cleanly on SIGTERM.
NeilBrown [Thu, 1 Aug 2013 01:16:14 +0000 (11:16 +1000)] 
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>
10 years agotests/env-ddf-template: helper for new unit test
Martin Wilck [Wed, 31 Jul 2013 05:36:32 +0000 (07:36 +0200)] 
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>
10 years agotests/10ddf-create-fail-rebuild: new unit test for DDF
Martin Wilck [Tue, 30 Jul 2013 21:18:34 +0000 (23:18 +0200)] 
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>
10 years agomdmon: manage_member: fix race condition during slow meta data writes
Martin Wilck [Tue, 30 Jul 2013 21:18:33 +0000 (23:18 +0200)] 
mdmon: manage_member: fix race condition during slow meta data writes

In order to track kernel state changes, the monitor needs to
notice changes in sysfs. If the changes are transient, and the
monitor is busy writing meta data, it can happen that the changes
are missed. This will cause the meta data to be inconsistent with
the real state of the array.

I can reproduce this in  a test scenario with a DDF container and
two subarrays, where I set a disk to "failed" and then add a global
hot-spare. On a typical MD test setup with loop devices, I can
reliably reproduce a failure where the metadata show degraded members
although the kernel finished the recovery successfully.

This patch fixes this problem by applying two changes. First, when
a metadata update is queued, wait until it is certain that the monitor
actually applied these meta data (the for loop is actually needed to
avoid failures completely in my test case). Second, after triggering the
recovery, set prev_state of the changed array to "recover", in case
the monitor misses the transient "recover" state.

Signed-off-by: Martin Wilck <mwilck@arcor.de>
Signed-off-by: NeilBrown <neilb@suse.de>
10 years agomdmon: manage_member: debug messages for array state
Martin Wilck [Tue, 30 Jul 2013 21:18:32 +0000 (23:18 +0200)] 
mdmon: manage_member: debug messages for array state

Add debug messages to watch the manager's steps.

Signed-off-by: Martin Wilck <mwilck@arcor.de>
Signed-off-by: NeilBrown <neilb@suse.de>
10 years agomdmon: wait_and_act: fix debug message for SIGUSR1
Martin Wilck [Tue, 30 Jul 2013 21:18:31 +0000 (23:18 +0200)] 
mdmon: wait_and_act: fix debug message for SIGUSR1

Correctly print out wake reason if it was a signal. Previous code
would print misleading select events (pselect(2) man page says the
fdsets become undefined in case of error).

Signed-off-by: Martin Wilck <mwilck@arcor.de>
Signed-off-by: NeilBrown <neilb@suse.de>
10 years agomonitor: read_and_act: log status when called
Martin Wilck [Tue, 30 Jul 2013 21:18:30 +0000 (23:18 +0200)] 
monitor: read_and_act: log status when called

read_and_act() currently prints a debug message only very late.
Print the status seen by mdmon right away, to track mdmon's
actions more closely. Add a time stamp to observe long delays
between read_and_act calls, e.g. caused by meta data writes.

Signed-off-by: Martin Wilck <mwilck@arcor.de>
Signed-off-by: NeilBrown <neilb@suse.de>
10 years agoDDF: ddf_set_disk: add some debug messages
Martin Wilck [Tue, 30 Jul 2013 21:18:29 +0000 (23:18 +0200)] 
DDF: ddf_set_disk: add some debug messages

Adds more verbose debugging in ddf_set_disk, to understand failures
better.

Signed-off-by: Martin Wilck <mwilck@arcor.de>
Signed-off-by: NeilBrown <neilb@suse.de>
10 years agoDDF: load_ddf_header: more error logging
Martin Wilck [Tue, 30 Jul 2013 21:18:28 +0000 (23:18 +0200)] 
DDF: load_ddf_header: more error logging

Try to determine problem if load_ddf_header fails. May be useful
for determining compatibility problems with Fake RAID BIOSes.

Signed-off-by: Martin Wilck <mwilck@arcor.de>
Signed-off-by: NeilBrown <neilb@suse.de>
10 years agoDDF: ddf_process_update: log offsets for conf changes
Martin Wilck [Tue, 30 Jul 2013 21:18:27 +0000 (23:18 +0200)] 
DDF: ddf_process_update: log offsets for conf changes

I needed this for tracking a bug with wrong offsets after array
creation.

Signed-off-by: Martin Wilck <mwilck@arcor.de>
Signed-off-by: NeilBrown <neilb@suse.de>
10 years agoDDF: log disk status changes more nicely
Martin Wilck [Tue, 30 Jul 2013 21:18:26 +0000 (23:18 +0200)] 
DDF: log disk status changes more nicely

In particular, include refnum for better tracking. This makes
it a little easier for humans to track what happened to which disk.

Signed-off-by: Martin Wilck <mwilck@arcor.de>
Signed-off-by: NeilBrown <neilb@suse.de>
10 years agoDDF: ddf_activate_spare: bugfix for 62ff3c40
Martin Wilck [Tue, 30 Jul 2013 21:18:25 +0000 (23:18 +0200)] 
DDF: ddf_activate_spare: bugfix for 62ff3c40

Move the check for good drives in the dl loop - otherwise dl
may be NULL and mdmon may crash.

Signed-off-by: Martin Wilck <mwilck@arcor.de>
Signed-off-by: NeilBrown <neilb@suse.de>
10 years agoFix is_resync_complete for RAID10
NeilBrown [Tue, 30 Jul 2013 23:18:57 +0000 (09:18 +1000)] 
Fix is_resync_complete for RAID10

For RAID10, 'sync' numbers go up to the array size rather than the
component size.  is_resync_complete() needs to allow for this.

Reported-by: Pawel Baldysiak <pawel.baldysiak@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
10 years agoAvoid double close()
Jes Sorensen [Tue, 30 Jul 2013 16:30:03 +0000 (18:30 +0200)] 
Avoid double close()

Coverity discovered a possible double close(fd2) in Grow.c. Avoided by
invalidating fd2 after the first close.

Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
Signed-off-by: NeilBrown <neilb@suse.de>
10 years agosuper1: simplify setting of array size.
NeilBrown [Tue, 30 Jul 2013 06:51:38 +0000 (16:51 +1000)] 
super1: simplify setting of array size.

Currently the extra space to leave before the data in the array
is calculated in two separate places, and they can be inconsistent.

Instead, do it all in validate_geometry.  This records the
'data_offset' chosen which all other devices then use.

'write_init_super' now just uses the value rather than doing all the
calculations again.

This results in more consistent numbers.

Also, load_super sets st->data_offset so that it is used by "--add",
so the new device has a data offset matching a pre-existing device.

Signed-off-by: NeilBrown <neilb@suse.de>
10 years agosuper1: separate to version of _avail_space1().
NeilBrown [Tue, 30 Jul 2013 05:17:22 +0000 (15:17 +1000)] 
super1: separate to version of _avail_space1().

_avail_space1() is calls from both avail_space1() and validate_geometry1()
and does slightly different things.

The partial code sharing doesn't really help.  In particularly the
responsibility for setting the size of the array is currently
confused.

So duplicate the code into the two locations - one where 'super' is
always NULL (validate_geometry1) and one where it is never NULL
(avail_space1), and simplify.

No behaviour change - just code re-organisation.

Signed-off-by: NeilBrown <neilb@suse.de>
10 years agoManage: remove call to validate_geometry.
NeilBrown [Tue, 30 Jul 2013 03:45:22 +0000 (13:45 +1000)] 
Manage: remove call to validate_geometry.

This call to validate_geometry is really rather gratuitous.
It is purely about the fact that super0 cannot use more than 4TB.
So just make it an explicit test - less confusing that way.

With this, validate_geometry is only called from Create, which
makes it easier to reason about.

Also validate_geometry is now never passed NULL for the 'chunk'
parameter, so we can remove those annoying tests for NULL.

Signed-off-by: NeilBrown <neilb@suse.de>
10 years agoDDF: ddf_activate_spare: fix metadata update for SVDs
mwilck@arcor.de [Thu, 25 Jul 2013 18:59:13 +0000 (20:59 +0200)] 
DDF: ddf_activate_spare: fix metadata update for SVDs

Metadata updates for secondary RAID (RAID10) need to cover
all BVDs. Compare with code in write_init_super_ddf().

Signed-off-by: NeilBrown <neilb@suse.de>
10 years agoDDF: ddf_activate_spare: only activate good drives
mwilck@arcor.de [Thu, 25 Jul 2013 18:59:12 +0000 (20:59 +0200)] 
DDF: ddf_activate_spare: only activate good drives

Do not try to activate drives marked missing or failed.

Signed-off-by: NeilBrown <neilb@suse.de>
10 years agoDDF: ddf_activate_spare: Add RAID10 code
mwilck@arcor.de [Thu, 25 Jul 2013 18:59:11 +0000 (20:59 +0200)] 
DDF: ddf_activate_spare: Add RAID10 code

The check for degraded array is a bit more complex for RAID10.
Fixing it.

Signed-off-by: NeilBrown <neilb@suse.de>
10 years agoDDF: find_vdcr: fix minor bug in debug message
mwilck@arcor.de [Thu, 25 Jul 2013 18:59:10 +0000 (20:59 +0200)] 
DDF: find_vdcr: fix minor bug in debug message

This code could find disk -1. Fixed.

Signed-off-by: NeilBrown <neilb@suse.de>