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).
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.
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.
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.
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.
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>
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>
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
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>
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.
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.
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'.
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.
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.
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.
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.
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'.
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.
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
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.
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.
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.
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.
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>,...
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.
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.
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.