]> git.ipfire.org Git - thirdparty/mdadm.git/log
thirdparty/mdadm.git
11 years agofix: adjust parse_size() to the unsigned size variable
Lukasz Dorau [Fri, 14 Sep 2012 14:12:45 +0000 (16:12 +0200)] 
fix: adjust parse_size() to the unsigned size variable

An error in parse_size() should be reported by 0, not -1,
because -1 is changed to the max value of unsigned long long
during calculations of size (e.g. at mdadm.c:412).

A negative value of size should be reported as error
(e.g. size equal -1 has been changed to the max value of
unsigned long long so far).

Signed-off-by: Lukasz Dorau <lukasz.dorau@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
11 years agofix: imsm: re-enable size expansion to the max value
Lukasz Dorau [Fri, 14 Sep 2012 14:04:08 +0000 (16:04 +0200)] 
fix: imsm: re-enable size expansion to the max value

Size expansion to the 'max' value has been broken since
the following patch:

    commit d04f65f48c93e7e57cc3c1d70dd07d094dece717
    Change the values for "max size" from -1 to 1.

This patch re-enables it.

Signed-off-by: Lukasz Dorau <lukasz.dorau@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
11 years agogrow: fix typo : MAX_DISKS -> MAX_SIZE
NeilBrown [Thu, 20 Sep 2012 01:32:39 +0000 (11:32 +1000)] 
grow: fix typo : MAX_DISKS -> MAX_SIZE

oopps.

Signed-off-by: NeilBrown <neilb@suse.de>
11 years agofix segfaults in Detail()
Lukasz Dorau [Thu, 20 Sep 2012 01:06:25 +0000 (11:06 +1000)] 
fix segfaults in Detail()

If disk has been removed, 'st' and 'info' can be NULL. It causes segfault.
'st' and 'info' should be checked against being NULL before being used.

Signed-off-by: Lukasz Dorau <lukasz.dorau@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
11 years agoraid6check: Auto-repair mode
Robert Buchholz [Mon, 10 Sep 2012 07:28:21 +0000 (17:28 +1000)] 
raid6check: Auto-repair mode

When calling raid6check in regular scanning mode, specifiying
"autorepair" as the last positional parameter will cause it
to automatically repair any single slot failes it identifies.

Signed-off-by: NeilBrown <neilb@suse.de>
11 years agoraid6check: Extract (un)locking into functions
Robert Buchholz [Mon, 10 Sep 2012 07:28:03 +0000 (17:28 +1000)] 
raid6check: Extract (un)locking into functions

Signed-off-by: NeilBrown <neilb@suse.de>
11 years agoraid6check: Repair mode used geo_map incorrectly
Robert Buchholz [Mon, 10 Sep 2012 07:25:27 +0000 (17:25 +1000)] 
raid6check: Repair mode used geo_map incorrectly

In repair mode, the data block indices to be repaired were calculated
using geo_map() which returns the disk slot for a data block index
and not the reverse. Now we simply store the reverse of that calculation
when we do it anyway.

Signed-off-by: NeilBrown <neilb@suse.de>
11 years agoraid6check: Fix off-by-one in argument check
Robert Buchholz [Thu, 19 Jul 2012 15:14:47 +0000 (17:14 +0200)] 
raid6check: Fix off-by-one in argument check

In repair mode, specifying a failed slot that is equal to the number of
devices in the raid could cause a segfault.

Signed-off-by: NeilBrown <neilb@suse.de>
11 years agoMove xmalloc et al into their own file
Robert Buchholz [Mon, 16 Jul 2012 21:56:54 +0000 (23:56 +0200)] 
Move xmalloc et al into their own file

This avoid code duplication for utilities that do not link to
util.c and everything that comes with it, such as test_restripe and
raid6check

Signed-off-by: NeilBrown <neilb@suse.de>
11 years agomapfile: fix mapfile rebuild for containers
NeilBrown [Mon, 20 Aug 2012 02:34:28 +0000 (12:34 +1000)] 
mapfile: fix mapfile rebuild for containers

When recreating the mapfile entry for a container we need to
use ->getinfo_super, not ->container_content, just like we
do in Detail().

Signed-off-by: NeilBrown <neilb@suse.de>
11 years agofind_free_devnum: avoid auto-using names in /etc/mdadm.conf
NeilBrown [Mon, 20 Aug 2012 00:50:42 +0000 (10:50 +1000)] 
find_free_devnum: avoid auto-using names in /etc/mdadm.conf

high-number names like "/dev/md126" shouldn't be in /etc/mdadm.conf,
but if they are they should be ignored when choosing an
unused number.

Signed-off-by: NeilBrown <neilb@suse.de>
11 years agomdmon: allow --takeover when original was started with --offroot
NeilBrown [Mon, 20 Aug 2012 00:37:21 +0000 (10:37 +1000)] 
mdmon: allow --takeover when original was started with --offroot

As --offroot causes ARGV[0] to be changed, we need to be more
lenient when checking that the mdmon we are about to kill really
is mdmon.  i.e. allow name to be "@dmon" instead.

Signed-off-by: NeilBrown <neilb@suse.de>
11 years agomdmon: fix arg processing for -a
NeilBrown [Mon, 20 Aug 2012 00:33:50 +0000 (10:33 +1000)] 
mdmon: fix arg processing for -a

'-a' was not being recognised as an abbreviation for '--all'.

Signed-off-by: NeilBrown <neilb@suse.de>
11 years agoddf: hack to fix container recognition.
NeilBrown [Wed, 15 Aug 2012 00:07:26 +0000 (10:07 +1000)] 
ddf: hack to fix container recognition.

When adding a spare to a DDF there is some confusion about the
'level' of the container.  It is reported by kernel as unknown
 -1000000.
I don't know why this broke but until I figure out why and fix it,
this hack gets us going again.

Signed-off-by: NeilBrown <neilb@suse.de>
11 years agoddf: allow a non-spare to be used to recovery a missing device.
NeilBrown [Tue, 14 Aug 2012 23:59:55 +0000 (09:59 +1000)] 
ddf: allow a non-spare to be used to recovery a missing device.

If a DDF has two arrays sharing devices and one device fails, then
as soon as the spare is used to recover one of the arrays it isn't
spare any more and so is not chosen for the other array.

Work around this for now by allowing a non-spare to be used if it has
enough space.

Reported-by: Albert Pauw <albert.pauw@gmail.com>
Signed-off-by: NeilBrown <neilb@suse.de>
11 years agoddf: fix multiple white-space issues.
NeilBrown [Tue, 14 Aug 2012 23:55:40 +0000 (09:55 +1000)] 
ddf: fix multiple white-space issues.

Just general tidy-up

Signed-off-by: NeilBrown <neilb@suse.de>
11 years agoManage: zero metadata before adding to 'external' array.
NeilBrown [Tue, 14 Aug 2012 23:51:20 +0000 (09:51 +1000)] 
Manage: zero metadata before adding to 'external' array.

'external' arrays don't support --re-add yet so old metadata is no
value, and 'ddf' gets confusing in mdmon if old metadata is found.
So for now, zero out any old metadata found before adding a spare to
an externally-managed array.

Reported-by: Albert Pauw <albert.pauw@gmail.com>
Signed-off-by: NeilBrown <neilb@suse.de>
11 years agoManage.c: fix make everything compilation error
Lukasz Dorau [Mon, 13 Aug 2012 09:56:19 +0000 (11:56 +0200)] 
Manage.c: fix make everything compilation error

This patch fixes the following make everything compilation error:
Manage.c: In function ‘Manage_add’:
Manage.c:538: error: ‘dev_st’ may be used uninitialized in this function
make: *** [mdadm.Os] Error 1

Signed-off-by: Lukasz Dorau <lukasz.dorau@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
11 years agosha1.h: remove ansidecl.h header inclusion
Lukasz Dorau [Mon, 13 Aug 2012 12:20:43 +0000 (14:20 +0200)] 
sha1.h: remove ansidecl.h header inclusion

Inclusion of the 'ansidecl.h' header requires the 'binutils-devel'
package to be installed but is not needed.

Signed-off-by: Maciej Patelczyk <maciej.patelczyk@intel.com>
Signed-off-by: Lukasz Dorau <lukasz.dorau@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
11 years agoquery udev dir via pkg-config
Samuli Suominen [Mon, 13 Aug 2012 17:44:22 +0000 (13:44 -0400)] 
query udev dir via pkg-config

Since udev is moving its internal dir around, query it via pkg-config
rather than hardcoding the old path.  This should work with new/old
versions.

Signed-off-by: Samuli Suominen <ssuominen@gentoo.org>
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
Signed-off-by: NeilBrown <neilb@suse.de>
11 years agomdassemble: split dietlibc logic into dedicated target
Mike Frysinger [Sun, 12 Aug 2012 19:24:16 +0000 (15:24 -0400)] 
mdassemble: split dietlibc logic into dedicated target

This lets people run `make mdassemble` and get a sane build by default.

Signed-off-by: Mike Frysinger <vapier@gentoo.org>
Signed-off-by: NeilBrown <neilb@suse.de>
11 years agofix handling of CPPFLAGS
Mike Frysinger [Sun, 12 Aug 2012 19:24:15 +0000 (15:24 -0400)] 
fix handling of CPPFLAGS

The current Makefile ends up ignoring the system CPPFLAGS settings,
so make sure we append the variable.  Also, the old metadata logic
has a typo with the flag name.

Signed-off-by: Mike Frysinger <vapier@gentoo.org>
Signed-off-by: NeilBrown <neilb@suse.de>
11 years agoGrow.c: change size to be unsigned and use '0' in case of 'no change'
Lukasz Dorau [Fri, 10 Aug 2012 14:06:34 +0000 (16:06 +0200)] 
Grow.c: change size to be unsigned and use '0' in case of 'no change'

The 'size' has been changed to be unsigned recently.
Analogous changes should be made to reshape_super().
'0' should be used in case of 'no change' now.

Signed-off-by: Lukasz Dorau <lukasz.dorau@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
11 years agoudev-rules: prevent systemd from mount devices before they are ready.
Harald Hoyer [Sun, 12 Aug 2012 22:00:21 +0000 (08:00 +1000)] 
udev-rules: prevent systemd from mount devices before they are ready.

In the "add" uevent, ATTR{md/array_state} does not exist, so the next
rule does not kick in.

When an array is assembled incrementally, systemd might see it
before it is ready, try to mount it, fail, and give up.
Result is that array doesn't get mounted.

If we ask udev to tell systemd that it isn't ready yet in this
case, systemd waits until it is ready, and all are happy.

Signed-off-by: NeilBrown <neilb@suse.de>
11 years ago07reshape5intr: Set speed_limit_min to be able to reduce resync speed below 1000
Jes Sorensen [Sun, 12 Aug 2012 22:00:21 +0000 (08:00 +1000)] 
07reshape5intr: Set speed_limit_min to be able to reduce resync speed below 1000

We need to set speed_limit_min accordingly, otherwise setting
speed_limit_max below 1000 will have no effect.

Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
Signed-off-by: NeilBrown <neilb@suse.de>
11 years agoMinor cosmetic fixes in various files.
NeilBrown [Sun, 12 Aug 2012 22:00:21 +0000 (08:00 +1000)] 
Minor cosmetic fixes in various files.

Signed-off-by: NeilBrown <neilb@suse.de>
11 years agotests/03r5assemV1: reduce sync speed further.
NeilBrown [Sun, 12 Aug 2012 22:00:21 +0000 (08:00 +1000)] 
tests/03r5assemV1: reduce sync speed further.

This test is quite sensitive to resync speed - if the resync happens
to quickly it fails because it sees aan optimal array when it expects
a degraded array.
1000 is often slow enough but now always, so slow it down even more.
This requires reducing speed_limit_min also as kernel ignores 'max'
when speed is below 'min'.

Reported-by: Jes Sorensen <Jes.Sorensen@redhat.com>
Signed-off-by: NeilBrown <neilb@suse.de>
11 years agoManage_subdevs: factor out Manage_delete
NeilBrown [Sun, 12 Aug 2012 22:00:21 +0000 (08:00 +1000)] 
Manage_subdevs: factor out Manage_delete

Now Manage_subdevs is now small enough to be manageable.

Signed-off-by: NeilBrown <neilb@suse.de>
11 years agoManage_subdevs: split most of 'add' handling into Manage_add.
NeilBrown [Sun, 12 Aug 2012 22:00:21 +0000 (08:00 +1000)] 
Manage_subdevs: split most of 'add' handling into Manage_add.

This makes Manage_subdevs smaller, and makes the error-path handling
for Manage_add much cleaner and probably less buggy.

Signed-off-by: NeilBrown <neilb@suse.de>
11 years agoManage: split out attempt_re_add.
NeilBrown [Sun, 12 Aug 2012 22:00:21 +0000 (08:00 +1000)] 
Manage: split out attempt_re_add.

The indent level is way too deep here, and this is a well defined
task, so split it out to a separate function.

Signed-off-by: NeilBrown <neilb@suse.de>
11 years agoManage_subdev: give 'st' a better name and narrower focus.
NeilBrown [Sun, 12 Aug 2012 22:00:20 +0000 (08:00 +1000)] 
Manage_subdev: give 'st' a better name and narrower focus.

'st' is use to examine the metadata on the device being added
to see if a 're-add' is possible.  However it is loaded long before
the 're-add' attempt is made.

So move the 'load_super' closer to were it is used - allowing us to
discard a number of 'free_super' call - and rename it to 'dev_st'
to emphasize that it related to the current device.

Signed-off-by: NeilBrown <neilb@suse.de>
11 years agoManage: minor cosmetic fixes.
NeilBrown [Sun, 12 Aug 2012 22:00:20 +0000 (08:00 +1000)] 
Manage: minor cosmetic fixes.

Signed-off-by: NeilBrown <neilb@suse.de>
11 years agoFix default size calculations that were recently broken.
NeilBrown [Sun, 12 Aug 2012 22:00:18 +0000 (08:00 +1000)] 
Fix default size calculations that were recently broken.

commit d04f65f48c93e7e57cc3c1d70dd07d094dece717
    Change the values for "max size" from -1 to 1.

Messed up 's->size' - leaving it as '1' (MAX_SIZE) in some cases and
causing the array reshape to fail.

Signed-off-by: NeilBrown <neilb@suse.de>
11 years agoRepair mode for raid6
Robert Buchholz [Mon, 9 Jul 2012 07:22:45 +0000 (17:22 +1000)] 
Repair mode for raid6

In repair mode, raid6check will rewrite one single stripe
by regenerating the data (or parity) of two raid devices that
are specified via the command line.
If you need to rewrite just one slot, pick any other slot
at random.

Note that the repair option will change data on the disks
directly, so both the md layer above as well as any layers
above md (such as filesystems) may be accessing the stripe
data from cached buffers. Either instruct the kernels
to drop the caches or reassemble the raid after repair.

Signed-off-by: NeilBrown <neilb@suse.de>
11 years agoMake test a bash script (as it is)
Robert Buchholz [Mon, 9 Jul 2012 07:22:43 +0000 (17:22 +1000)] 
Make test a bash script (as it is)

Signed-off-by: NeilBrown <neilb@suse.de>
11 years agoExtract function to generate zeroes and expose xor function
Robert Buchholz [Mon, 9 Jul 2012 07:22:38 +0000 (17:22 +1000)] 
Extract function to generate zeroes and expose xor function

Signed-off-by: NeilBrown <neilb@suse.de>
11 years agoManage: simplify device searches in Manage_subdevs
NeilBrown [Mon, 9 Jul 2012 07:22:16 +0000 (17:22 +1000)] 
Manage: simplify device searches in Manage_subdevs

We currently have rather hard-to-follow loop to iterate
through all the matches for 'missing' or 'faulty' or 'detached'.

Simplify it by creating a list of possible devices for each
of those and splicing the new list into the device list.

This removes the need for 'jnext' and 'next' and various other hacks.

Signed-off-by: NeilBrown <neilb@suse.de>
11 years agoUse new struct context and struct shape for Grow_addbitmap
NeilBrown [Mon, 9 Jul 2012 07:22:12 +0000 (17:22 +1000)] 
Use new struct context and struct shape for Grow_addbitmap

Signed-off-by: NeilBrown <neilb@suse.de>
11 years agoUse new struct context and struct shape in Grow_reshape
NeilBrown [Mon, 9 Jul 2012 07:22:09 +0000 (17:22 +1000)] 
Use new struct context and struct shape in Grow_reshape

Signed-off-by: NeilBrown <neilb@suse.de>
11 years agoUse new 'struct shape' to pass args to Create
NeilBrown [Mon, 9 Jul 2012 07:22:05 +0000 (17:22 +1000)] 
Use new 'struct shape' to pass args to Create

Signed-off-by: NeilBrown <neilb@suse.de>
11 years agoUse new 'struct shape' to pass args to Build
NeilBrown [Mon, 9 Jul 2012 07:21:57 +0000 (17:21 +1000)] 
Use new 'struct shape' to pass args to Build

Signed-off-by: NeilBrown <neilb@suse.de>
11 years agoFix --build on 2.2 kernels :-)
NeilBrown [Mon, 9 Jul 2012 07:21:50 +0000 (17:21 +1000)] 
Fix --build on 2.2 kernels :-)

This code has clearly never been used because it isn't right.
But let's fix it anyway.

Signed-off-by: NeilBrown <neilb@suse.de>
11 years agoCreate new 'struct shape' to pass around array details.
NeilBrown [Mon, 9 Jul 2012 07:21:38 +0000 (17:21 +1000)] 
Create new 'struct shape' to pass around array details.

This collects to together many of the args given to
create/build/grow

Signed-off-by: NeilBrown <neilb@suse.de>
11 years agoCreate: Remove unnecessary cast from 'size'.
NeilBrown [Mon, 9 Jul 2012 07:21:27 +0000 (17:21 +1000)] 
Create: Remove unnecessary cast from 'size'.

'size' is already unsigned long long, so no need to cast it.

Signed-off-by: NeilBrown <neilb@suse.de>
11 years agochange array_size to be unsigned and use the new MAX_SIZE
NeilBrown [Mon, 9 Jul 2012 07:21:06 +0000 (17:21 +1000)] 
change array_size to be unsigned and use the new MAX_SIZE

Signed-off-by: NeilBrown <neilb@suse.de>
11 years agoChange the values for "max size" from -1 to 1.
NeilBrown [Mon, 9 Jul 2012 07:20:32 +0000 (17:20 +1000)] 
Change the values for "max size" from -1 to 1.

Both are impossible, and '1' allows size to be unsigned,
which is neater.
Also #define MAX_SIZE to be '1' to make it all more explicit.

Signed-off-by: NeilBrown <neilb@suse.de>
11 years agoAssemble: don't leak memory with fdlist.
NeilBrown [Mon, 9 Jul 2012 07:20:25 +0000 (17:20 +1000)] 
Assemble: don't leak memory with fdlist.

We should free fdlist when finished with it.

Signed-off-by: NeilBrown <neilb@suse.de>
11 years agoChange Incremental and related functions to take struct context
NeilBrown [Mon, 9 Jul 2012 07:20:22 +0000 (17:20 +1000)] 
Change Incremental and related functions to take struct context

Signed-off-by: NeilBrown <neilb@suse.de>
11 years agoChange Monitor to take a struct context
NeilBrown [Mon, 9 Jul 2012 07:20:19 +0000 (17:20 +1000)] 
Change Monitor to take a struct context

Signed-off-by: NeilBrown <neilb@suse.de>
11 years agoChange Detail and misc_scan to take a struct context
NeilBrown [Mon, 9 Jul 2012 07:20:16 +0000 (17:20 +1000)] 
Change Detail and misc_scan to take a struct context

Signed-off-by: NeilBrown <neilb@suse.de>
11 years agoChange name of 'c' variable in Detail
NeilBrown [Mon, 9 Jul 2012 07:20:05 +0000 (17:20 +1000)] 
Change name of 'c' variable in Detail

I want to use 'c' uniformly as a 'struct context', so
in Detail change 'c' to 'str'.

Signed-off-by: NeilBrown <neilb@suse.de>
11 years agochange Examine to take a struct context
NeilBrown [Mon, 9 Jul 2012 07:20:00 +0000 (17:20 +1000)] 
change Examine to take a struct context

Signed-off-by: NeilBrown <neilb@suse.de>
11 years agoExamine: split 'verbose' out from 'brief'.
NeilBrown [Mon, 9 Jul 2012 07:19:48 +0000 (17:19 +1000)] 
Examine: split 'verbose' out from 'brief'.

The value of 'verbose' is sometimes mixed into 'brief', particularly
for Examine.
This is messy and confusing.  So keep them separate.
'brief' still gets assumed when 'scan' is set, unless we are very
verbose.

Signed-off-by: NeilBrown <neilb@suse.de>
11 years agoChange Create to take a struct context
NeilBrown [Mon, 9 Jul 2012 07:19:24 +0000 (17:19 +1000)] 
Change Create to take a struct context

Signed-off-by: NeilBrown <neilb@suse.de>
11 years agoChange Build to take a struct context
NeilBrown [Mon, 9 Jul 2012 07:19:21 +0000 (17:19 +1000)] 
Change Build to take a struct context

Signed-off-by: NeilBrown <neilb@suse.de>
11 years agoChange misc_list to take struct context
NeilBrown [Mon, 9 Jul 2012 07:19:17 +0000 (17:19 +1000)] 
Change misc_list to take struct context

Signed-off-by: NeilBrown <neilb@suse.de>
11 years agoConvert Assemble() to take a context rather than a list of options.
NeilBrown [Mon, 9 Jul 2012 07:19:07 +0000 (17:19 +1000)] 
Convert Assemble() to take a context rather than a list of options.

Signed-off-by: NeilBrown <neilb@suse.de>
11 years agoDiscard 'quiet' context variable.
NeilBrown [Mon, 9 Jul 2012 07:18:48 +0000 (17:18 +1000)] 
Discard 'quiet' context variable.

Just use negative verbose, now that we are ready for that.

Signed-off-by: NeilBrown <neilb@suse.de>
11 years agoConvert 'quiet' to 'not verbose' in various places.
NeilBrown [Mon, 9 Jul 2012 07:18:09 +0000 (17:18 +1000)] 
Convert 'quiet' to 'not verbose' in various places.

If we change some functions to accept 'verbose', where <0 means to be
quiet, in place of 'quiet', then we will be able to merge
'quiet' and 'verbose' together for simplicity.

Signed-off-by: NeilBrown <neilb@suse.de>
11 years agoCreate 'struct context' for ad hoc context option.
NeilBrown [Mon, 9 Jul 2012 07:17:33 +0000 (17:17 +1000)] 
Create 'struct context' for ad hoc context option.

Rather than passing a long list of little flags etc to various
functions we will soon pass a small collection of structures.

This first step combines a collection of variables local to
'main' into a single structure.

Signed-off-by: NeilBrown <neilb@suse.de>
11 years agoCreate parse_num() function.
NeilBrown [Mon, 9 Jul 2012 07:14:17 +0000 (17:14 +1000)] 
Create parse_num() function.

Instead of open-coding this several times, just do it once.

The frees up the name 'c' which I'm about to use.

Signed-off-by: NeilBrown <neilb@suse.de>
11 years agoCreate: support --readonly flag.
NeilBrown [Mon, 9 Jul 2012 07:14:17 +0000 (17:14 +1000)] 
Create: support --readonly flag.

Allow array to be created read-only

Signed-off-by: NeilBrown <neilb@suse.de>
11 years agoAssemble: allow arrays to be assembled read-only.
NeilBrown [Mon, 9 Jul 2012 07:14:16 +0000 (17:14 +1000)] 
Assemble: allow arrays to be assembled read-only.

The option was there, but never used.

Signed-off-by: NeilBrown <neilb@suse.de>
11 years agoRemove scattered checks for malloc success.
NeilBrown [Mon, 9 Jul 2012 07:14:16 +0000 (17:14 +1000)] 
Remove scattered checks for malloc success.

malloc should never fail, and if it does it is unlikely
that anything else useful can be done.  Best approach is to
abort and let some super-daemon restart.

So define xmalloc, xcalloc, xrealloc, xstrdup which don't
fail but just print a message and exit.  Then use those
removing all the tests for failure.

Also replace all "malloc;memset" sequences with 'xcalloc'.

Signed-off-by: NeilBrown <neilb@suse.de>
11 years agoRemove re_add flag in favour of new disposition.
NeilBrown [Mon, 9 Jul 2012 07:14:16 +0000 (17:14 +1000)] 
Remove re_add flag in favour of new disposition.

Instead of
   disposition == 'a'  re_add == 1
use
   disposition == 'A'

to record that a re-add was requested.

Signed-off-by: NeilBrown <neilb@suse.de>
11 years agoIntroduce pr_err for printing error messages.
NeilBrown [Mon, 9 Jul 2012 07:14:16 +0000 (17:14 +1000)] 
Introduce pr_err for printing error messages.

'pr_err("' is a lot shorter than 'fprintf(stderr, Name ": '
cont_err() is also available.

Signed-off-by: NeilBrown <neilb@suse.de>
11 years agoHelp: use an array to choose which help matches which mode.
NeilBrown [Mon, 9 Jul 2012 07:14:16 +0000 (17:14 +1000)] 
Help: use an array to choose which help matches which mode.

Looks cleaner than a big switch statement.

Signed-off-by: NeilBrown <neilb@suse.de>
11 years agomain: extract more functions.
NeilBrown [Mon, 9 Jul 2012 07:14:16 +0000 (17:14 +1000)] 
main: extract more functions.

extract misc_scan stop_scan misc_list from main to try to
make main() a little more manageable.

Signed-off-by: NeilBrown <neilb@suse.de>
11 years agomain: split scan_assemble into a separate function
NeilBrown [Mon, 9 Jul 2012 07:14:10 +0000 (17:14 +1000)] 
main: split scan_assemble into a separate function

main is too big.  This makes it a little more manageable.

Signed-off-by: NeilBrown <neilb@suse.de>
11 years agomdadm.c: various minor clean-ups
NeilBrown [Mon, 9 Jul 2012 07:00:50 +0000 (17:00 +1000)] 
mdadm.c: various minor clean-ups

Signed-off-by: NeilBrown <neilb@suse.de>
11 years agoUse explicit non-char opt for --zero-super
NeilBrown [Mon, 9 Jul 2012 07:00:45 +0000 (17:00 +1000)] 
Use explicit non-char opt for --zero-super

As we don't allow '-K' for '--zero-super' there is no point
using it internally.  Just define a 'KillOpt' like with
other options.

Signed-off-by: NeilBrown <neilb@suse.de>
11 years agoReadMe: various updates and corrections.
NeilBrown [Mon, 9 Jul 2012 07:00:24 +0000 (17:00 +1000)] 
ReadMe: various updates and corrections.

Signed-off-by: NeilBrown <neilb@suse.de>
11 years agomdmon: fix arg parsing.
NeilBrown [Mon, 9 Jul 2012 06:50:22 +0000 (16:50 +1000)] 
mdmon: fix arg parsing.

-t aka --takeover should not be setting container_name.
It sets it to NULL which causes failure when you try
  mdmon --all --takeover

Signed-off-by: NeilBrown <neilb@suse.de>
11 years agoMonitor: fix reporting for Fail vs FailSpare etc.
NeilBrown [Mon, 4 Jun 2012 02:57:52 +0000 (12:57 +1000)] 
Monitor: fix reporting for Fail vs FailSpare etc.

The tests here were specific to 0.90 metadata and didn't
work properly for 1.x metadata, where a device's "number"
doesn't change.

By checking if this is a new array we can avoid some
corner cases.  Then we test mostly based on state and
not based on 'number' at all.

Signed-off-by: NeilBrown <neilb@suse.de>
11 years agoMonitor: Report NewArray when an array the disappeared, reappears.
NeilBrown [Mon, 4 Jun 2012 02:52:36 +0000 (12:52 +1000)] 
Monitor: Report NewArray when an array the disappeared, reappears.

Signed-off-by: NeilBrown <neilb@suse.de>
11 years agoMonitor: fix inconsistencies in values for ->percent
NeilBrown [Mon, 4 Jun 2012 02:31:40 +0000 (12:31 +1000)] 
Monitor: fix inconsistencies in values for ->percent

->percent sometimes stores negative values recording states
like 'pending' or 'delayed'.
The value '-2' means both 'delayed' and in Monitor, 'unknown'.
Also, '-1' has a meaning but not #define.

So change the #defines to be prefixed with "RESYNC_", instead
of "PROCESS_", add new "_NONE" and "_UNKNOWN", and use correct
value in each location.

Signed-off-by: NeilBrown <neilb@suse.de>
11 years agoMonitor: Allow correct monitoring of more member devices.
NeilBrown [Sun, 3 Jun 2012 23:30:56 +0000 (09:30 +1000)] 
Monitor: Allow correct monitoring of more member devices.

Having "MaxDisks == 384" is not good.  Discard it in favour of
MAX_DISKS which is 4096

Signed-off-by: NeilBrown <neilb@suse.de>
11 years agoDetail: show which 'set' each device in a RAID10 belongs to
NeilBrown [Wed, 30 May 2012 03:08:39 +0000 (13:08 +1000)] 
Detail: show which 'set' each device in a RAID10 belongs to

A RAID10 can be though of as having 2 sets of devices
(if there are 2 copies and an even number of devices in total).

With this patch "mdadm --detail" shows which 'set' each device
belongs to - set-A or set-B.

If there are more than 3 copies, there can be more than 3 sets.

If the number of copies does not evenly divide the number of devices,
there are not distinct 'sets' so none are reported.

Signed-off-by: NeilBrown <neilb@suse.de>
11 years agoNew tests testing removal of internal bitmaps
Jes Sorensen [Wed, 30 May 2012 00:46:25 +0000 (10:46 +1000)] 
New tests testing removal of internal bitmaps

To match the add-bitmap tests, here is a set of tests checking the
removal of bitmaps.

Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
Signed-off-by: NeilBrown <neilb@suse.de>
11 years agoNew tests testing the addition of bitmaps
Jes Sorensen [Wed, 30 May 2012 00:45:27 +0000 (10:45 +1000)] 
New tests testing the addition of bitmaps

This set of tests verifies that it is possible to add an internal
bitmap to an existing array, and that the device can be written to
after the bitmap is added. This should catch cases such as the one
fixed by 4474ca42e2577563a919fd3ed782e2ec55bf11a2

Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
Signed-off-by: NeilBrown <neilb@suse.de>
11 years agoFix --no-error in test script
Jes Sorensen [Tue, 29 May 2012 13:17:54 +0000 (15:17 +0200)] 
Fix --no-error in test script

b8e91a32cdaa2a6dea8b0dd54365ede33d5a9a60 was applied incorrectly.
It changed the name of the variable set when specifying --no-error,
without changing the places checking it.

Set it back as it was to make --no-error work correctly again.

Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
Signed-off-by: NeilBrown <neilb@suse.de>
11 years agoimsm: fix: correct checking volume's degradation
Lukasz Dorau [Fri, 25 May 2012 13:06:41 +0000 (15:06 +0200)] 
imsm: fix: correct checking volume's degradation

We do not check the return value of sysfs_get_ll() now. It is wrong.
If reading of the sysfs "degraded" key does not succeed,
the "new_degraded" variable will not be initiated
and accidentally it can have the value of "degraded" variable.
In that case the change of degradation will not be checked.

It happens if mdadm is compiled with gcc's "-fstack-protector" option
when one tries to stop a volume under reshape (e.g. OLCE).
Reshape seems to be finished then (metadata is in normal/clean state)
but it is not finished, it is broken and data are corrupted.

Now we always check the return value of sysfs_get_ll().
Even if reading of the sysfs "degraded" key does not succeed
(rv == -1) the change of degradation will be checked.

Signed-off-by: Lukasz Dorau <lukasz.dorau@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
11 years agomdadm: Fix Segmentation fault.
majianpeng [Mon, 28 May 2012 23:21:51 +0000 (09:21 +1000)] 
mdadm: Fix Segmentation fault.

In function write_init_super1():
If "rv = store_super1(st, di->fd)" return error and the di is the last.
Then the di = NULL && rv > 0, so exec:
if (rv)
    fprintf(stderr, Name ": Failed to write metadata to%s\n",
       di->devname);
will be segmentation fault.

Signed-off-by: majianpeng <majianpeng@gmail.com>
Signed-off-by: NeilBrown <neilb@suse.de>
11 years agoMove setup code to a function and introduce matching cleanup argument
Jes Sorensen [Mon, 28 May 2012 00:52:27 +0000 (10:52 +1000)] 
Move setup code to a function and introduce matching cleanup argument

Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
Signed-off-by: NeilBrown <neilb@suse.de>
11 years agoImprove --help message from test
Jes Sorensen [Mon, 28 May 2012 00:51:57 +0000 (10:51 +1000)] 
Improve --help message from test

Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
Signed-off-by: NeilBrown <neilb@suse.de>
11 years agoAdd --no-error argument to 'test'
Jes Sorensen [Mon, 28 May 2012 00:51:43 +0000 (10:51 +1000)] 
Add --no-error argument to 'test'

This allows the test suite to run to completion even if one test
fails.

Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
Signed-off-by: NeilBrown <neilb@suse.de>
11 years agoAdd support for saving log files in test script
Jes Sorensen [Mon, 28 May 2012 00:50:38 +0000 (10:50 +1000)] 
Add support for saving log files in test script

--logdir= specifies where to save, if different from default, and
--save-logs tells test to save all log files.

Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
Signed-off-by: NeilBrown <neilb@suse.de>
11 years agoIncrease minimum chunk size in testsuite to 64kB
Anton Blanchard [Thu, 24 May 2012 05:10:47 +0000 (15:10 +1000)] 
Increase minimum chunk size in testsuite to 64kB

When running the mdadm testsuite on ppc64 with a 64kB page size I
see a couple of failures because the chunk size is smaller than a
page.

Bump the chunksize to 64kB to fix these failures.

Signed-off-by: Anton Blanchard <anton@samba.org>
Signed-off-by: NeilBrown <neilb@suse.de>
11 years agoudev-rules: prevent systemd from mount devices before they are ready.
NeilBrown [Thu, 24 May 2012 01:49:49 +0000 (11:49 +1000)] 
udev-rules: prevent systemd from mount devices before they are ready.

When an array is assembled incrementally, systemd might see it
before it is ready, try to mount it, fail, and give up.
Result is that array doesn't get mounted.

If we ask udev to tell systemd that it isn't ready yet in this
case, systemd waits until it is ready, and all are happy.

Signed-off-by: NeilBrown <neilb@suse.de>
11 years agoAdd command line argument parsing to 'test' sript
Jes Sorensen [Wed, 23 May 2012 03:36:52 +0000 (13:36 +1000)] 
Add command line argument parsing to 'test' sript

This adds more generic command line argument parsing to the test
script. It also introduces a couple of new options, while preserving
the old '<prefix>' and 'setup' arguments. The new options are
--disable-multipath and --tests=<test1>,<test2>,...

Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
Signed-off-by: NeilBrown <neilb@suse.de>
11 years agoCheck for multipath module before running multipath tests
Jes Sorensen [Tue, 22 May 2012 16:55:29 +0000 (18:55 +0200)] 
Check for multipath module before running multipath tests

Some systems do not ship the md multipath module. If not available
simply skip any multipath tests.

Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
Signed-off-by: NeilBrown <neilb@suse.de>
11 years agoCreate new release: 3.2.5 mdadm-3.2.5
NeilBrown [Fri, 18 May 2012 06:21:41 +0000 (16:21 +1000)] 
Create new release: 3.2.5

Fix a serious regression in 3.2.4 which caused "--add" to often
fail.  Other minor fixes included.

Signed-off-by: NeilBrown <neilb@suse.de>
11 years agoUpdate some device sizes for self tests.
NeilBrown [Fri, 18 May 2012 07:08:28 +0000 (17:08 +1000)] 
Update some device sizes for self tests.

A recent change means that devices smaller than
1Gig no longer have 1Meg wasted at the start.
So we must adjust some sizes again.

Signed-off-by: NeilBrown <neilb@suse.de>
11 years agoimsm: fix: check if size of expansion is not larger than maximum
Lukasz Dorau [Thu, 17 May 2012 14:14:00 +0000 (16:14 +0200)] 
imsm: fix: check if size of expansion is not larger than maximum

We do not check if requested size of expansion is larger than maximum
available size now. If it is larger the output message is a bit misleading,
for example:
   mdadm: Cannot set size on array members.
   mdadm: Cannot set device size for /dev/md/vol: Device or resource busy
Now we check if requested size of expansion is larger than maximum
available size and the appropriate output message was added.

Signed-off-by: Lukasz Dorau <lukasz.dorau@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
11 years agoimsm: fix a typo in fprintf message
Lukasz Dorau [Thu, 17 May 2012 13:37:24 +0000 (15:37 +0200)] 
imsm: fix a typo in fprintf message

Signed-off-by: Lukasz Dorau <lukasz.dorau@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
11 years agomdadm.conf.5: typo: of -> or
NeilBrown [Fri, 18 May 2012 02:29:29 +0000 (12:29 +1000)] 
mdadm.conf.5: typo: of -> or

Addresses-Debian-bug: 673344
Reported-by: Robert Henney <robh@rut.org>
Signed-off-by: NeilBrown <neilb@suse.de>
11 years agoRebuildMap: check that container_content returns a valid 'info'.
NeilBrown [Thu, 17 May 2012 05:46:09 +0000 (15:46 +1000)] 
RebuildMap: check that container_content returns a valid 'info'.

If it doesn't, just skip that entry.

Reported-by: Maciej Naruszewicz <maciej.naruszewicz@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
11 years agoDon't consider disks with a valid recovery offset as candidates for bumping up event...
Alexander Lyakas [Sun, 13 May 2012 07:10:43 +0000 (10:10 +0300)] 
Don't consider disks with a valid recovery offset as candidates for bumping up event count

When we are looking for a candidate disk to bump up the event count,
we consider only disks that have recovery_start==MaxSector.
However, after we find one such disk, we agree to accept more disks
having same event count, regardless of their recovery_start.
Be consistent and don't accept disks with a valid recovery_start at all.

Signed-off-by: NeilBrown <neilb@suse.de>
11 years agoGrow: don't print message if unfreezing fails.
NeilBrown [Tue, 15 May 2012 02:12:58 +0000 (12:12 +1000)] 
Grow: don't print message if unfreezing fails.

This is most likely to happen if the array has been stopped,
in which case the error is pointless.

Reported-by: Patrik Horník <patrik@dsl.sk>
Signed-off-by: NeilBrown <neilb@suse.de>
11 years agoGrow: fix --layout=preserve to match man page.
NeilBrown [Tue, 15 May 2012 01:59:40 +0000 (11:59 +1000)] 
Grow: fix --layout=preserve to match man page.

I think there was some confusion about what --layout=preserve
actually means, but in any case it wasn't doing what the man
page says it should.
So add some case analysis and make sure it does the right thing,
or complains if it cannot.

Reported-by: Patrik Horník <patrik@dsl.sk>
Signed-off-by: NeilBrown <neilb@suse.de>