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>
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>
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>
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>
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>
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>
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>
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>
'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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
'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>
commit d04f65f48c
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>
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>
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>
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>
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>