]> git.ipfire.org Git - thirdparty/mdadm.git/log
thirdparty/mdadm.git
11 years agoDiscard devnum in favour of devnm
NeilBrown [Thu, 1 Nov 2012 05:14:01 +0000 (16:14 +1100)] 
Discard devnum in favour of devnm

We widely use a "devnum" which is 0 or +ve for md%d devices
and -ve for md_d%d devices.
But I want to be able to use md_%s device names.

So get rid of devnum (a number) and use devnm (a 32char string).
eg.
  md0
  md_d2
  md_home

Signed-off-by: NeilBrown <neilb@suse.de>
11 years agoGrow: fix problem with reshaping RAID4 to RAID0.
NeilBrown [Thu, 21 Feb 2013 06:02:21 +0000 (17:02 +1100)] 
Grow: fix problem with reshaping RAID4 to RAID0.

As 'layout' doesn't map neatly from RAID4 to RAID5, we need to
set it correctly for RAID4.
Also, when no reshape is needed we should set re->level to the final
desired level.

Signed-off-by: NeilBrown <neilb@suse.de>
11 years agoGrow: disallow --size changes on RAID0 and Linear.
NeilBrown [Thu, 21 Feb 2013 03:51:11 +0000 (14:51 +1100)] 
Grow: disallow --size changes on RAID0 and Linear.

These aren't meaningful and must be disabled.

Signed-off-by: NeilBrown <neilb@suse.de>
11 years agoudev: Fix order of execution of the md rules
Thomas Bächler [Sat, 9 Feb 2013 20:49:47 +0000 (21:49 +0100)] 
udev: Fix order of execution of the md rules

Right now, the rules that run blkid on raid arrays are executed after
the assembly rules. This means incremental assembly will always fail
when raid arrays are again physical components of raid arrays.

Instead of simply reversing the order, split the rules up into two files,
one dealing with array properties and one dealing with assembly.

Signed-off-by: NeilBrown <neilb@suse.de>
11 years agoModernize udev rules
Thomas Bächler [Sat, 9 Feb 2013 17:48:38 +0000 (18:48 +0100)] 
Modernize udev rules

* $tempnode is deprecated, use $devnode
* blkid -o udev output is deprecated, use IMPORT{builtin}="blkid" instead

Signed-off-by: NeilBrown <neilb@suse.de>
11 years agomdadm.h: fix ugly glibc specific ifdeffery
John Spencer [Sat, 2 Feb 2013 16:37:55 +0000 (17:37 +0100)] 
mdadm.h: fix ugly glibc specific ifdeffery

the code that was exposed on anything else than dietlibc and klibc
is entirely glibc specific and broke the build on musl libc.

Signed-off-by: John Spencer <maillist-mdadm@barfooze.de>
Signed-off-by: NeilBrown <neilb@suse.de>
11 years agoplatform-intel: canonicalize_file_name() is not portable
John Spencer [Sat, 2 Feb 2013 16:26:45 +0000 (17:26 +0100)] 
platform-intel: canonicalize_file_name() is not portable

this is a GLIBC specific feature and should not be used.

according to its manpage:
"The call canonicalize_file_name(path) is equivalent
to the call realpath(path, NULL)."

thus, we use realpath so it works everywhere.

Signed-off-by: John Spencer <maillist-mdadm@barfooze.de>
Signed-off-by: NeilBrown <neilb@suse.de>
11 years agomake --update=homehost work again
NeilBrown [Thu, 7 Feb 2013 00:51:21 +0000 (11:51 +1100)] 
make --update=homehost work again

Commit 1e2b276535cea41c348292a019bdda8a58cb1679 (Report error in --update
string is not recognised) broke homehost updating functionality because it
depended on each string comparison being done even after we already found
a match.  Make it work again by restructuring code.

Reported-by: (and original version by) Justin Maggard <jmaggard10@gmail.com>
Signed-off-by: NeilBrown <neilb@suse.de>
11 years agoAvoid using BLKFLSBUF.
NeilBrown [Tue, 5 Feb 2013 04:34:17 +0000 (15:34 +1100)] 
Avoid using BLKFLSBUF.

Now that we use O_DIRECT for all device IO, BLKFLSBUF is not needed to
ensure we get current data, and it can impose a cost if any flush-out
is needed.  So remove it.

To be safe, add O_DIRECT to one place where it isn't currently used:
when reading a bitmap.

Signed-off-by: NeilBrown <neilb@suse.de>
11 years agoDetail: print correct size for large external-metadata arrays.
NeilBrown [Tue, 5 Feb 2013 04:32:49 +0000 (15:32 +1100)] 
Detail: print correct size for large external-metadata arrays.

If externally menaged metadata is in use, array.major_version will
be zero, so the test here to consider using get_component_size()
is wrong.  So if sra is present, use the major_version from there.

Signed-off-by: NeilBrown <neilb@suse.de>
11 years agomdmon: add --foreground option
NeilBrown [Tue, 5 Feb 2013 04:57:09 +0000 (15:57 +1100)] 
mdmon: add --foreground option

While not strictly necessary for systemd, it is cleaner to avoid
forking when running from a management daemon.  So add a --foreground
option to mdmon.

Signed-off-by: NeilBrown <neilb@suse.de>
11 years agoIn case launching mdmon fails, print an error message before exiting
Jes Sorensen [Fri, 1 Feb 2013 15:15:19 +0000 (16:15 +0100)] 
In case launching mdmon fails, print an error message before exiting

Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
Signed-off-by: NeilBrown <neilb@suse.de>
11 years agoAdd support for launching mdmon via systemctl instead of fork/exec
Jes Sorensen [Fri, 1 Feb 2013 15:15:18 +0000 (16:15 +0100)] 
Add support for launching mdmon via systemctl instead of fork/exec

If launching mdmon via systemctl fails, we fall back to the old method
of fork/exec. This allows for having mdmon launched via systemctl
which avoids problems with it getting killed by systemd due to it
ending up in the parent's cgroup (udev).

Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
Signed-off-by: NeilBrown <neilb@suse.de>
11 years agoRemove --offroot argument and default to always setting argv[0] to @
Jes Sorensen [Fri, 1 Feb 2013 15:15:17 +0000 (16:15 +0100)] 
Remove --offroot argument and default to always setting argv[0] to @

We still allow --offroot to be given - for compatibility with scripts
- but ignore it.

The whole point of --offroot is to get systemd to not auto-kill mdmon,
and we always want that.

Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
Signed-off-by: NeilBrown <neilb@suse.de>
11 years agomdadm.conf.5: clarify connection between action=re-add and bitmaps.
NeilBrown [Sun, 20 Jan 2013 23:12:53 +0000 (10:12 +1100)] 
mdadm.conf.5: clarify connection between action=re-add and bitmaps.

action=re-add will only re-add a recently removed device if a
bitmap is present.
Otherwise a force-space is needed.

Signed-off-by: NeilBrown <neilb@suse.de>
11 years agodev_open - don't bother trying map_dev
NeilBrown [Sun, 6 Jan 2013 23:38:46 +0000 (10:38 +1100)] 
dev_open - don't bother trying map_dev

map_dev can be slow, and doesn't really provide a better result
than just creating a temporary device.
So discard it and use mknod/open/unlink to open a major:minor device.

Signed-off-by: NeilBrown <neilb@suse.de>
11 years agoplatform-intel - cache 'intel_devices' for a few seconds.
NeilBrown [Sun, 6 Jan 2013 23:34:43 +0000 (10:34 +1100)] 
platform-intel - cache 'intel_devices' for a few seconds.

find_intel_devices() has take a little while to run as it scans
some directory tree, and the result isn't likely to change
often.
So cache the value and only discard it after 10 seconds.

Signed-off-by: NeilBrown <neilb@suse.de>
11 years agoconditionally remove map_dev from find_free_devnum
NeilBrown [Sun, 6 Jan 2013 23:17:04 +0000 (10:17 +1100)] 
conditionally remove map_dev from find_free_devnum

map_dev can be slow so it is best to not call it when
not necessary.
The final test in "find_free_devnum" is not relevant when
udev is being used, so remove the test in that case.

Signed-off-by: NeilBrown <neilb@suse.de>
11 years agoMISC: Add --examine-badblocks option
NeilBrown [Wed, 5 Dec 2012 01:56:31 +0000 (12:56 +1100)] 
MISC: Add --examine-badblocks option

This will list the contents of the bad-blocks log, if one is present.

Signed-off-by: NeilBrown <neilb@suse.de>
11 years agoAssemble: fix spelling: report_missmatch -> report_mismatch
NeilBrown [Wed, 5 Dec 2012 00:40:28 +0000 (11:40 +1100)] 
Assemble: fix spelling: report_missmatch -> report_mismatch

Signed-off-by: NeilBrown <neilb@suse.de>
11 years agoAssemble: Don't auto-assemble arrays which conflict with mdadm.conf
NeilBrown [Wed, 5 Dec 2012 00:06:55 +0000 (11:06 +1100)] 
Assemble:  Don't auto-assemble arrays which conflict with mdadm.conf

When auto-assembling we might find an array which appear in
mdadm.conf.
This can happen if the array (based on UUID) doesn't match what is
in mdadm.conf.
For consistency we should avoid auto-assembling such an array just as
we avoid regular-assembling of the array.

Reported-by: Ross Boylan <ross@biostat.ucsf.edu>
Signed-off-by: NeilBrown <neilb@suse.de>
11 years agoManage: Add support for --re-add faulty
NeilBrown [Tue, 27 Nov 2012 23:19:52 +0000 (10:19 +1100)] 
Manage: Add support for --re-add faulty

mdadm /dev/mdXX --re-add faulty

will identify any faulty devices in the array, remove them, and
--re-add them.

Signed-off-by: NeilBrown <neilb@suse.de>
11 years agoFix "--remove faulty" and similar commands.
NeilBrown [Tue, 27 Nov 2012 23:12:09 +0000 (10:12 +1100)] 
Fix "--remove faulty" and similar commands.

A recent change to improve error messages for subdev management broken
all use cases were device names like %d:%d were used.
Re-arrange the code again so we use dev_open first - which understands
those names - and then only try 'stat' if that failed.
The important thing is to base the 'Cannot find' message on the result
of 'stat', not on the result of 'open'.

Signed-off-by: NeilBrown <neilb@suse.de>
11 years agoAssemble: ensure that <ignore>d arrays are not auto-assembled.
NeilBrown [Thu, 22 Nov 2012 06:04:20 +0000 (17:04 +1100)] 
Assemble: ensure that <ignore>d arrays are not auto-assembled.

It isn't enough to simply not assemble arrays found to be called
<ignore>, as the final stage of auto-assemble doesn't check for names
in mdadm.conf.

So add a check to Assemble, similar to the check in Incremental()

Reported-by: Mike Frysinger <vapier@gentoo.org>
Signed-off-by: NeilBrown <neilb@suse.de>
11 years agoconf: allow multiple arrays to be <ignore>d
NeilBrown [Thu, 22 Nov 2012 05:28:00 +0000 (16:28 +1100)] 
conf: allow multiple arrays to be <ignore>d

We currently complain if mdadm.conf contains multiple
definitions for the same name.  Unfortunately this stops
multiple arrays  from being <ignored>d.

So exclude "<ignore>" from the duplicate-names test.

Reported-by: Mike Frysinger <vapier@gentoo.org>
Signed-off-by: NeilBrown <neilb@suse.de>
11 years agoAllow --wait to wait for delayed resync.
NeilBrown [Wed, 21 Nov 2012 21:58:54 +0000 (08:58 +1100)] 
Allow --wait to wait for delayed resync.

If a resync is delayed, then e->percent will be negative but not
RESYNC_NONE.  In that case we still want to wait.

Reported-by: Ross Boylan <ross@biostat.ucsf.edu>
Signed-off-by: NeilBrown <neilb@suse.de>
11 years agoGrow: fix bug when multiple arrays present.
NeilBrown [Wed, 21 Nov 2012 21:57:25 +0000 (08:57 +1100)] 
Grow: fix bug when multiple arrays present.

commit 1f9b0e2845e1ec22dc24dcef275a733c09ff2edd
    Grow - be careful about 'delayed' reshapes.

Introduced a bug where a list of devices longer than 1
would cause an infinite loop.  Oops.

Signed-off-by: NeilBrown <neilb@suse.de>
11 years agoMakefile: remove "sh" from instructions for running 'test'.
NeilBrown [Tue, 20 Nov 2012 01:15:11 +0000 (12:15 +1100)] 
Makefile: remove "sh" from instructions for running 'test'.

'test' is really a bash script more than an 'sh' script, so
don't say "run 'sh ./test'", just say "run './test'".

Reported-by: Gilles Espinasse <g.esp@free.fr>
Signed-off-by: NeilBrown <neilb@suse.de>
11 years agoGrow.c: fix uninitialized variables compilation-time error
Lukasz Dorau [Tue, 13 Nov 2012 12:29:43 +0000 (13:29 +0100)] 
Grow.c: fix uninitialized variables compilation-time error

It fixes the following uninitialized variables compilation-time error:
WARN  - Grow.c: In function ‘reshape_array’:
WARN  - Grow.c:2413:21: error: ‘min_space_after’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
WARN  - Grow.c:2376:39: note: ‘min_space_after’ was declared here
WARN  - Grow.c:2414:22: error: ‘min_space_before’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
WARN  - Grow.c:2376:21: note: ‘min_space_before’ was declared here
WARN  - cc1: all warnings being treated as errors
WARN  - make: *** [Grow.o] Error 1
It occurs during compilation of mdadm on Fedora 17.

Signed-off-by: Lukasz Dorau <lukasz.dorau@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
11 years agoKeep track on which kernel the test suite has run
Gilles Espinasse [Sat, 10 Nov 2012 09:14:43 +0000 (10:14 +0100)] 
Keep track on which kernel the test suite has run

Signed-off-by: Gilles Espinasse <g.esp@free.fr>
Signed-off-by: NeilBrown <neilb@suse.de>
11 years agoimsm: Forbid spanning between multiple controllers.
Marcin Tomczak [Fri, 9 Nov 2012 14:46:36 +0000 (15:46 +0100)] 
imsm: Forbid spanning between multiple controllers.

Attaching disks to multiple controllers of the same type has been
allowed so far. Now spanning between multiple controllers is disallowed
at all by IMSM metadata.

Signed-off-by: Marcin Tomczak <marcin.tomczak@intel.com>
Reviewed-by: Lukasz Dorau <lukasz.dorau@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
11 years agoCreate.c: check if freesize is equal 0
Lukasz Dorau [Fri, 16 Nov 2012 16:24:36 +0000 (17:24 +0100)] 
Create.c: check if freesize is equal 0

"freesize" can be equal 0, particularly after rounding to the chunk's size.
Creating should be aborted in such case.

Signed-off-by: Lukasz Dorau <lukasz.dorau@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
11 years agoAssemble: fix call to wait_for
NeilBrown [Wed, 31 Oct 2012 23:50:13 +0000 (10:50 +1100)] 
Assemble: fix call to wait_for

Recent patch closed 'mdfd' before calling wait_for, which means
it doesn't work.

Put the close back in the right place.

Signed-off-by: NeilBrown <neilb@suse.de>
11 years agotest: remove unnecessary bash-ism.
NeilBrown [Wed, 31 Oct 2012 22:56:15 +0000 (09:56 +1100)] 
test: remove unnecessary bash-ism.

Bash allows '-' in function names, but other shells don't.
So use '_' - always safe.

Signed-off-by: NeilBrown <neilb@suse.de>
11 years agoAssemble: Fix critical-section-recovery when assembling a growing array.
NeilBrown [Wed, 31 Oct 2012 06:02:49 +0000 (17:02 +1100)] 
Assemble: Fix critical-section-recovery when assembling a growing array.

commit aacb2f816afbddf56c406039b8e2e6c0dbc8a8a0
    Assemble: add support for replacement devices.

broke the restoring of the 'critical section' because it messed up the
list of file descriptors passed to Grow_restart.  Put it back the way
it should be.

Signed-off-by: NeilBrown <neilb@suse.de>
11 years agoIncremental: allow recently removed device to be added as a spare.
NeilBrown [Wed, 31 Oct 2012 06:02:42 +0000 (17:02 +1100)] 
Incremental: allow recently removed device to be added as a spare.

Currently, action=force-spare isn't effective at all as I'm not
sure what is really sensible.
This patch allows a device that was part of an array, but has been
removed, to be added as a spare of passed to --incremental while
force-spare is active.

If it is can be re-added, that done first.  If it fails, we add it as
a spare.

Signed-off-by: NeilBrown <neilb@suse.de>
11 years agotest: add --disable-integrity switch.
NeilBrown [Wed, 31 Oct 2012 06:02:35 +0000 (17:02 +1100)] 
test:  add --disable-integrity switch.

The integrity tests are very slow and aren't always needed.
So make them optional.

Signed-off-by: NeilBrown <neilb@suse.de>
11 years agoIMSM - allow assembling any imsm array even without OROM.
NeilBrown [Tue, 30 Oct 2012 03:28:25 +0000 (14:28 +1100)] 
IMSM - allow assembling any imsm array even without OROM.

It is important to check for compatibility with 'platform' or
Option ROM when creating or changing and array.  However there is no
real need when simply assembling the array.

On some systems there are situations where the platform information is
not available.  e.g. on some UEFI systems, UEFI is not available
during 'kdump' handling.  This makes it impossible to assemble
an IMSM array to receive the dump.

So remove the requirements that the platform be visible to assemble
an IMSM array.

Signed-off-by: NeilBrown <neilb@suse.de>
11 years agoTests: adjust for recent changes.
NeilBrown [Tue, 30 Oct 2012 03:28:16 +0000 (14:28 +1100)] 
Tests: adjust for recent changes.

commit cb19a251a581fe78dcddd1d95dca4d8cb7664819
    super1: reserve  at least 2 chunks for reshape headroom.

reserved more space in a RAID5, so we need to update to array
sizes when reshaping.
Also make sure reshape tests we change the shape:  raid5->raid1
was failing and we didn't notice.

Signed-off-by: NeilBrown <neilb@suse.de>
11 years agoGrow: fix reshape from RAID5 to RAID1.
NeilBrown [Tue, 30 Oct 2012 02:34:54 +0000 (13:34 +1100)] 
Grow: fix reshape from RAID5 to RAID1.

Commit 5da9ab9874cb5896023afae1462550d83a869831
       Grow_reshape re-factor
in mdadm-3.2 broke conversion from RAID5 and RAID1 - and we
never noticed.

This fixes it.

Signed-off-by: NeilBrown <neilb@suse.de>
11 years agoQuery: allow member of non-0.90 arrays to be better reported.
NeilBrown [Thu, 25 Oct 2012 05:38:11 +0000 (16:38 +1100)] 
Query: allow member of non-0.90 arrays to be better reported.

Currently if a member of a 1.x array is queried, mdadm will
fail to find the name of the active md array if there is one.

Change the lookup to use the mapfile - now it works.

Signed-off-by: NeilBrown <neilb@suse.de>
11 years agoQuery: don't be confused by partition tables.
NeilBrown [Thu, 25 Oct 2012 05:32:00 +0000 (16:32 +1100)] 
Query: don't be confused by partition tables.

Now that we recognise partition tables as a sort of metadata
we need to be careful in --query not to say that a device
with a partition table looks like a device in an array.

Testing ->compare_super for NULL is an easy way to do that.

Signed-off-by: NeilBrown <neilb@suse.de>
11 years agoMonitor: don't complain about non-monitorable arrays in mdadm.conf
NeilBrown [Wed, 24 Oct 2012 02:09:09 +0000 (13:09 +1100)] 
Monitor: don't complain about non-monitorable arrays in mdadm.conf

If we are asked to monitor a RAID0 or Linear - which cannot be
monitored - we complain with "Device Disappeared .... Wrong-Level".

However if the RAID0 or Linear is being requested because it is
in mdadm.conf then the message is inappropriate and confusing.

So track which arrays are added from the config file, and suppress
that message in that case.

Reported-by: "Johnson Yan" <johnson_yan@usish.com>
Signed-off-by: NeilBrown <neilb@suse.de>
11 years agoManage: improve error message when given a non-block device.
NeilBrown [Wed, 24 Oct 2012 01:51:14 +0000 (12:51 +1100)] 
Manage: improve error message when given a non-block device.

As dev_open uses O_DIRECT it will fail on directories and such.
So we never get to report that it isn't a block device.

So do a 'stat' earlier and if it is a block device, report the
error there.

Signed-off-by: NeilBrown <neilb@suse.de>
11 years agoCreate new md devices consistently
Justin Maggard [Tue, 23 Oct 2012 22:04:00 +0000 (15:04 -0700)] 
Create new md devices consistently

 Creating a new MD device with the name 'd-0' results in some
 unexpected behavior, since mdadm sees that '-0' is a
 non-negative integer and therefore makes a "partitionable"
 device (/dev/md_d0).  This is not the expected behavior,
 since the documentation mentions 'dN' several places, and a
 reboot brings it up as /dev/md/d-0.  Make this consistent
 by ensuring that the character immediately following 'd' is
 a digit during creation.

Signed-off-by: NeilBrown <neilb@suse.de>
11 years agoIncremental: support replacement devices.
NeilBrown [Wed, 24 Oct 2012 01:06:51 +0000 (12:06 +1100)] 
Incremental: support replacement devices.

These need to be counted in the number of 'active' devices.

Signed-off-by: NeilBrown <neilb@suse.de>
11 years agoAssemble: add support for replacement devices.
NeilBrown [Tue, 23 Oct 2012 22:48:18 +0000 (09:48 +1100)] 
Assemble: add support for replacement devices.

Need to possibly collect 2 devices for each slot, and
original and a replacement.

Signed-off-by: NeilBrown <neilb@suse.de>
11 years agoReport replacement devices correctly with --detail and --examine
NeilBrown [Tue, 23 Oct 2012 06:16:16 +0000 (17:16 +1100)] 
Report replacement devices correctly with --detail and --examine

--detail needs to be read to report 2 devices in each slot,
and --examine need to report if the device is the original or
the replacement.

Signed-off-by: NeilBrown <neilb@suse.de>
11 years agoAdd support for --replace and --with
NeilBrown [Tue, 23 Oct 2012 05:27:15 +0000 (16:27 +1100)] 
Add support for --replace and --with

--replace can be used to replace a device without completely failing
it.  Once the replacement completes the device will be failed.
--with can indicate which of several spares to use.

Signed-off-by: NeilBrown <neilb@suse.de>
11 years agotest: keep separate log file for each failed test.
NeilBrown [Mon, 22 Oct 2012 22:21:32 +0000 (09:21 +1100)] 
test: keep separate log file for each failed test.

If a test failed when --keep-going is selected, give the
log file a name based on the test name, so that all the logs
can be examined afterwards.

Signed-off-by: NeilBrown <neilb@suse.de>
11 years agotest: redirect all output to log file to keep output clean
Gilles Espinasse [Mon, 22 Oct 2012 22:12:15 +0000 (09:12 +1100)] 
test: redirect all output to log file to keep output clean

If a test sent anything to stdout, it would not get logged, and would
mess up the listing of test status.

Signed-off-by: Gilles Espinasse <g.esp@free.fr>
Signed-off-by: NeilBrown <neilb@suse.de>
11 years agosuper0: allow creation of array on 2TB+ devices.
NeilBrown [Mon, 22 Oct 2012 21:48:00 +0000 (08:48 +1100)] 
super0: allow creation of array on 2TB+ devices.

As 'info->size' is signed, it cannot even hold values above
2TB.
But it isn't used much.  sb->size is the important value and it
is unsigned.
So use that to check for overflow of size.

Reported-by: Eugene San <eugenesan@gmail.com>
11 years agoAssemble.c - re-indent file.
NeilBrown [Mon, 22 Oct 2012 06:25:19 +0000 (17:25 +1100)] 
Assemble.c - re-indent file.

Make sure spaces and indents are consistent.

Signed-off-by: NeilBrown <neilb@suse.de>
11 years agoAssemble: remove support for assembling arrays with ancient kernel.
NeilBrown [Mon, 22 Oct 2012 06:23:25 +0000 (17:23 +1100)] 
Assemble: remove support for assembling arrays with ancient kernel.

Using "START_ARRAY" ioctl never really worked reliably,
was removed a decade ago, and just clutters the code.
So remove it.

Signed-off-by: NeilBrown <neilb@suse.de>
11 years agoRemove get_one_disk
NeilBrown [Mon, 22 Oct 2012 06:23:15 +0000 (17:23 +1100)] 
Remove get_one_disk

It has never been used, and there isn't really any place that
could usefully use it.

Signed-off-by: NeilBrown <neilb@suse.de>
11 years agoAssemble: split out "start_array()" function.
NeilBrown [Mon, 22 Oct 2012 06:23:11 +0000 (17:23 +1100)] 
Assemble: split out "start_array()" function.

Apart from code movement, there is a small functional change here.
If the array is not successfully started, it is stopped.
Previously we would sometimes leave the array in a partially-assembled
but inactive state.
This just causes confusion.
"--incremental" can be used to partially assemble arrays.

Signed-off-by: NeilBrown <neilb@suse.de>
11 years agoDetail: don't report a faulty device as 'spare' or 'rebuilding'.
NeilBrown [Sun, 21 Oct 2012 23:38:11 +0000 (10:38 +1100)] 
Detail: don't report a faulty device as 'spare' or 'rebuilding'.

If a device is faulty, then that is all there is too it.
Even if it isn't 'removed' yet, it shouldn't be reported as 'spare'
or 'rebuilding'.

Signed-off-by: NeilBrown <neilb@suse.de>
11 years agoReplace --no-error by --keep-going
Gilles Espinasse [Sun, 21 Oct 2012 22:11:07 +0000 (09:11 +1100)] 
Replace --no-error by --keep-going

Suggest to replace by the option name that 'make' use.
no error is only a developper hope.

Signed-off-by: Gilles Espinasse <g.esp@free.fr>
Signed-off-by: NeilBrown <neilb@suse.de>
11 years agoAllow escape by ctrl-c broken by --no-error change
Gilles Espinasse [Sat, 20 Oct 2012 16:03:51 +0000 (18:03 +0200)] 
Allow escape by ctrl-c broken by --no-error change

Signed-off-by: Gilles Espinasse <g.esp@free.fr>
Signed-off-by: NeilBrown <neilb@suse.de>
11 years agoTrivial bugfix and spelling fixes.
Michael Tokarev [Sat, 20 Oct 2012 11:44:14 +0000 (15:44 +0400)] 
Trivial bugfix and spelling fixes.

And here's another trivial bugfix, now for spelling mistakes in various
places, authred by Sergey Kirpichev (Cc'ed) and carried in debian mdadm
package.

Signed-off-by: NeilBrown <neilb@suse.de>
11 years agomdadm: super0: do not override uuid with homehost
Michael Tokarev [Sat, 20 Oct 2012 11:40:02 +0000 (15:40 +0400)] 
mdadm: super0: do not override uuid with homehost

When --uuid is specified in the command line, even for v0.90
superblock we override last portion of uuid with data from
--homehost, which is wrong (and disagrees with the manpage).
Only use homehost in super0 if no uuid is specified.

Signed-off-By: Michael Tokarev <mjt@tls.msk.ru>
Signed-off-by: NeilBrown <neilb@suse.de>
11 years agoAssemble: split out force_array()
NeilBrown [Thu, 18 Oct 2012 06:30:51 +0000 (17:30 +1100)] 
Assemble: split out force_array()

force_array() is called if --force was specified to update
and metadata necessary to make the array assemble.

Signed-off-by: NeilBrown <neilb@suse.de>
11 years agoAssemble: split out load_devices() functionality.
NeilBrown [Thu, 18 Oct 2012 05:39:49 +0000 (16:39 +1100)] 
Assemble: split out load_devices() functionality.

Once we have found the devices we want, we need to load the
metadata from them and store it.  This new function extracts that
functionality out of Assemble()

Signed-off-by: NeilBrown <neilb@suse.de>
11 years agoAssemble: split out select_devices function.
NeilBrown [Thu, 18 Oct 2012 04:31:20 +0000 (15:31 +1100)] 
Assemble: split out select_devices function.

Assemble() is way too big.
This patch starts cleaning it up by pulling the 'select_devices()'
function.  This examines the device to make sure they all belong to
one array, or select those that do (depending on exact use case).

Signed-off-by: NeilBrown <neilb@suse.de>
11 years agoFix open_container
NeilBrown [Thu, 11 Oct 2012 06:15:55 +0000 (17:15 +1100)] 
Fix open_container

open_container should open a container which contains the device,
but sometimes it would open another volume which contains the
device.  Be more careful in 'holder' selection.

Signed-off-by: NeilBrown <neilb@suse.de>
11 years agoGrow: fix a couple of typos with --assume-clean usage
NeilBrown [Thu, 11 Oct 2012 00:35:41 +0000 (11:35 +1100)] 
Grow: fix a couple of typos with --assume-clean usage

Signed-off-by: NeilBrown <neilb@suse.de>
11 years agoFix tests sh too many arguments warnings
Gilles Espinasse [Wed, 10 Oct 2012 11:38:15 +0000 (13:38 +0200)] 
Fix tests sh too many arguments warnings

Signed-off-by: Gilles Espinasse <g.esp@free.fr>
Add quotes on if [ $sum != $sum1 ]
Fix 2 typo /sh1sum/sha1sum/ /matc /match /
Signed-off-by: NeilBrown <neilb@suse.de>
11 years agoReplace a lot of leading spaces with tabs.
NeilBrown [Wed, 10 Oct 2012 07:33:26 +0000 (18:33 +1100)] 
Replace a lot of leading spaces with tabs.

Signed-off-by: NeilBrown <neilb@suse.de>
11 years agoFix up interactions between --assemble and --incremental
NeilBrown [Wed, 10 Oct 2012 07:27:32 +0000 (18:27 +1100)] 
Fix up interactions between --assemble and --incremental

If --incremental has partly assembled an array and
--assemble is asked to assemble it, the just finds remaining
devices and makes a new array.  Not good.

So:
1/ modify locking policy so that assemble can be sure that
  no --incremental is running once it locks the map file
2/ Assemble() checks the map file for a duplicate and adds to
   that array instead of creating a new one.

Signed-off-by: NeilBrown <neilb@suse.de>
11 years agoGrow: allow --grow --continue to work for native metadata.
NeilBrown [Tue, 9 Oct 2012 02:54:59 +0000 (13:54 +1100)] 
Grow: allow --grow --continue to work for native metadata.

As it was the code would crash due to "mdstat" being NULL.
Code is now more sane, but hasn't been tested on an array that
needs to grow.

Signed-off-by: NeilBrown <neilb@suse.de>
11 years agoimsm: allow --assume-clean to work.
NeilBrown [Thu, 4 Oct 2012 06:51:22 +0000 (16:51 +1000)] 
imsm: allow --assume-clean to work.

We must avoid setting IMSM_T_STATE_UNINITIALIZED if the
array was declared to be clean due to --assume-clean.

Signed-off-by: NeilBrown <neilb@suse.de>
11 years agoAllow data-offset to be specified per-device for create
NeilBrown [Thu, 4 Oct 2012 06:34:21 +0000 (16:34 +1000)] 
Allow data-offset to be specified per-device for create

 mdadm --create /dev/md0 .... /dev/sda1:1024 /dev/sdb1:2048 ...

The size is in K unless a suffix: K M G is given.
The suffix 's' means sectors.

Signed-off-by: NeilBrown <neilb@suse.de>
11 years agoGrow/raid10: support reducing the devices in a RAID10.
NeilBrown [Thu, 4 Oct 2012 06:34:21 +0000 (16:34 +1000)] 
Grow/raid10: support reducing the devices in a RAID10.

When reducing the number of devices in a RAID10, we increase the
data offset to avoid the need for backup area.

If there is no room at the end of the device to allow this, we need
to first reduce the component size of each device.  However if there
is room, we don't want to insist on that, otherwise growing then
shrinking the array would not be idempotent.

So find the min before/after space before analysing a RAID10 for
reshape, and if the after space is insufficient, reduce the total size
of the array and the component size accordingly.

Signed-off-by: NeilBrown <neilb@suse.de>
11 years agosuper1: reserve at least 2 chunks for reshape headroom.
NeilBrown [Thu, 4 Oct 2012 06:34:21 +0000 (16:34 +1000)] 
super1: reserve  at least 2 chunks for reshape headroom.

sometimes 0.1% isn't enough, though mostly only in testing.

We need one chunk for a successful reshape, so reserve 2.

Signed-off-by: NeilBrown <neilb@suse.de>
11 years agoNew RESHAPE_NO_BACKUP flag to track when backup action is needed.
NeilBrown [Thu, 4 Oct 2012 06:34:21 +0000 (16:34 +1000)] 
New RESHAPE_NO_BACKUP flag to track when backup action is needed.

Some arrays (raid10) never need a backup file, so during assembly
we can avoid the whole Grow_continue check in that case.
Achieve this using a flag set by the metadata handler.

Also get "mdadm -I" to fail if a backup process would be
needed.  It currently does fail as the kernel rejects things,
but it is nicer to have this explicit.

Signed-off-by: NeilBrown <neilb@suse.de>
11 years agoGrow: add raid10 reshape.
NeilBrown [Thu, 4 Oct 2012 06:34:21 +0000 (16:34 +1000)] 
Grow: add raid10 reshape.

RAID10 reshape requires that data_offset be changed.
So we only allow it if the new_data_offset attribute is available,
and we compute a suitable change in data offset.

Signed-off-by: NeilBrown <neilb@suse.de>
11 years agoSplit 'GCD' out into a separate function.
NeilBrown [Thu, 4 Oct 2012 06:34:21 +0000 (16:34 +1000)] 
Split 'GCD' out into a separate function.

It is neater that way.

Signed-off-by: NeilBrown <neilb@suse.de>
11 years agoGrow: set new_data_offset if appropriate
NeilBrown [Thu, 4 Oct 2012 06:34:21 +0000 (16:34 +1000)] 
Grow: set new_data_offset if appropriate

11 years agoAdd space_before/space_after fields to mdinfo
NeilBrown [Thu, 4 Oct 2012 06:34:21 +0000 (16:34 +1000)] 
Add space_before/space_after fields to mdinfo

These will be needed to guide changes to data_offset during reshape.
Only set them for super1 for now.

Signed-off-by: NeilBrown <neilb@suse.de>
11 years agosuper1: add new_offset field.
NeilBrown [Thu, 4 Oct 2012 06:34:21 +0000 (16:34 +1000)] 
super1: add new_offset field.

The 'new_offset' is used for reshaping to avoid the need
for a backup file.

For now we only report the value when it is set.

Signed-off-by: NeilBrown <neilb@suse.de>
11 years agoAdd --data-offset flag for Create and Grow
NeilBrown [Thu, 4 Oct 2012 06:34:21 +0000 (16:34 +1000)] 
Add --data-offset flag for Create and Grow

This can be used to over-ride the automatic assignment of
data offset.
For --create, it is useful to re-create old arrays where different
   defaults applied.
For --grow it may be able to force a reshape in the reverse direction.

Signed-off-by: NeilBrown <neilb@suse.de>
11 years agoAdd data_offset arg to ->init_super and use it in super1.c
NeilBrown [Thu, 4 Oct 2012 06:34:20 +0000 (16:34 +1000)] 
Add data_offset arg to ->init_super and use it in super1.c

So if ->data_offset is already set, use that rather than
computing one.

Signed-off-by: NeilBrown <neilb@suse.de>
11 years agoAdd data_offset arg to ->validate_geometry.
NeilBrown [Thu, 4 Oct 2012 06:34:20 +0000 (16:34 +1000)] 
Add data_offset arg to ->validate_geometry.

This is needed to return correct available size.  It isn't
really used yet.

Signed-off-by: NeilBrown <neilb@suse.de>
11 years agoAdd data_offset arg to ->avail_size
NeilBrown [Thu, 4 Oct 2012 06:34:20 +0000 (16:34 +1000)] 
Add data_offset arg to ->avail_size

This is currently only useful for 1.x metadata and will allow an
explicit --data-offset request on command line.

Signed-off-by: NeilBrown <neilb@suse.de>
11 years agoAllow parse_size to return 0.
NeilBrown [Thu, 4 Oct 2012 06:34:20 +0000 (16:34 +1000)] 
Allow parse_size to return 0.

We will shortly introduce --data-offset= which is allowed to
be zero.  We will want to use parse_size() so it needs to be
able to return '0' without it being an error.

So define INVALID_SECTORS to be an impossible value (currently '1')
and return and test for it consistently.

Signed-off-by: NeilBrown <neilb@suse.de>
11 years agoHandles spaces in array names better.
NeilBrown [Thu, 4 Oct 2012 06:34:20 +0000 (16:34 +1000)] 
Handles spaces in array names better.

1/ When printing the "name=" entry for --brief output,
   enclose name in quotes if it contains spaces etc.
   Quotes are already supported for reading mdadm.conf

2/ When a name is used as a device name, translate spaces
   and tabs to '_', as well as the current translation of
   '/' to '-'.

Signed-off-by: NeilBrown <neilb@suse.de>
11 years agoimsm: Allow to specify controller for --detail-platform.
Maciej Naruszewicz [Thu, 4 Oct 2012 06:34:11 +0000 (16:34 +1000)] 
imsm: Allow to specify controller for --detail-platform.

Usually, 'mdadm --detail-platform -e imsm' scans all the controllers
looking for IMSM capabilities. This patch provides the possibility
to specify a controller to scan, enabling custom usage by other
processes - especially with the --export switch.

$ mdadm --detail-platform
       Platform : Intel(R) Matrix Storage Manager
        Version : 9.5.0.1037
    RAID Levels : raid0 raid1 raid10 raid5
    Chunk Sizes : 4k 8k 16k 32k 64k 128k
    2TB volumes : supported
      2TB disks : not supported
      Max Disks : 7
    Max Volumes : 2 per array, 4 per controller
 I/O Controller : /sys/devices/pci0000:00/0000:00:1f.2 (SATA)

$ mdadm --detail-platform /sys/devices/pci0000:00/0000:00:1f.2
       Platform : Intel(R) Matrix Storage Manager
        Version : 9.5.0.1037
    RAID Levels : raid0 raid1 raid10 raid5
    Chunk Sizes : 4k 8k 16k 32k 64k 128k
    2TB volumes : supported
      2TB disks : not supported
      Max Disks : 7
    Max Volumes : 2 per array, 4 per controller
 I/O Controller : /sys/devices/pci0000:00/0000:00:1f.2 (SATA)

$ mdadm --detail-platform /sys/devices/pci0000:00/0000:00:1f.2 --export
MD_FIRMWARE_TYPE=imsm
IMSM_VERSION=9.5.0.1037
IMSM_SUPPORTED_RAID_LEVELS=raid0 raid1 raid10 raid5
IMSM_SUPPORTED_CHUNK_SIZES=4k 8k 16k 32k 64k 128k
IMSM_2TB_VOLUMES=yes
IMSM_2TB_DISKS=no
IMSM_MAX_DISKS=7
IMSM_MAX_VOLUMES_PER_ARRAY=2
IMSM_MAX_VOLUMES_PER_CONTROLLER=4

$ mdadm --detail-platform /sys/devices/pci0000:00/0000:00:1f.0 # This isn't an IMSM-capable controller
mdadm: no active Intel(R) RAID controller found under /sys/devices/pci0000:00/0000:00:1f.0

Signed-off-by: Maciej Naruszewicz <maciej.naruszewicz@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
11 years agoAdd zlib license to crc32.c
Jes Sorensen [Wed, 3 Oct 2012 08:00:34 +0000 (10:00 +0200)] 
Add zlib license to crc32.c

Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
Signed-off-by: NeilBrown <neilb@suse.de>
11 years agosuper1: ensure bitmap doesn't overlap bad block log.
NeilBrown [Wed, 3 Oct 2012 07:07:20 +0000 (17:07 +1000)] 
super1: ensure bitmap doesn't overlap bad block log.

If a bad block log already exists when adding a bitmap,
make sure the bitmap stays before the log.

Signed-off-by: NeilBrown <neilb@suse.de>
11 years agoAllow --update to add or remove space for a bad block list.
NeilBrown [Wed, 3 Oct 2012 07:07:13 +0000 (17:07 +1000)] 
Allow --update to add or remove space for a bad block list.

--update=bbl will add a bad block list to each device.
--update=no-bblk will remove the bad block list providing that it
is empty.

Signed-off-by: NeilBrown <neilb@suse.de>
11 years agoBad block log
NeilBrown [Wed, 3 Oct 2012 07:07:11 +0000 (17:07 +1000)] 
Bad block log

11 years agoGrow: make warning about old metadata more explicit.
NeilBrown [Wed, 3 Oct 2012 04:44:20 +0000 (14:44 +1000)] 
Grow: make warning about old metadata more explicit.

Don't print it just when --verbose is set, and explain how
to over-ride it.

Signed-off-by: NeilBrown <neilb@suse.de>
11 years agoGrow - be careful about 'delayed' reshapes.
NeilBrown [Wed, 3 Oct 2012 04:41:31 +0000 (14:41 +1000)] 
Grow - be careful about 'delayed' reshapes.

If multiple reshapes are activated on the same devices (different
partitions) then one might be forced to wait for the other to
complete.
As reshaping suspends access to small sections of the array
at time, this cause a region to be suspended for a long time,
which isn't good.

To try to detect this and don't start suspending until
the reshape is actually happening.

This is only effective on 3.7 and later as prior kernels
don't report when the delayed reshape can progress.  For
the earlier kernels, just give a warning.

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

11 years agoUse --offroot flag when assembling md arrays via --incrmental
NeilBrown [Wed, 3 Oct 2012 03:54:03 +0000 (13:54 +1000)] 
Use --offroot flag when assembling md arrays via --incrmental

This ensures that mdmon won't be killed by systemd.
Signed-off-by: NeilBrown <neilb@suse.de>
11 years agoDetail/raid10: don't report 'set' names for 'far' and 'offset' raid10.
NeilBrown [Wed, 3 Oct 2012 03:53:54 +0000 (13:53 +1000)] 
Detail/raid10: don't report 'set' names for 'far' and 'offset' raid10.

The 'set' concept is only meaningful for 'near' arrays, so only
use it there.

Signed-off-by: NeilBrown <neilb@suse.de>
11 years agoFix 'enough' function for RAID10.
NeilBrown [Wed, 3 Oct 2012 03:53:46 +0000 (13:53 +1000)] 
Fix 'enough' function for RAID10.

The 'enough' function is written to work with 'near' arrays only
in that is implicitly assumes that the offset from one 'group' of
devices to the next is the same as the number of copies.
In reality it is the number of 'near' copies.

So change it to make this number explicit.

Reported-by: Jakub Husák <jakub@gooseman.cz>
Signed-off-by: NeilBrown <neilb@suse.de>
11 years agoReplace sha1.h with slightly older version.
NeilBrown [Wed, 3 Oct 2012 03:34:15 +0000 (13:34 +1000)] 
Replace sha1.h with slightly older version.

sha1.h claims GPL3+, while sha1.c claims GPL2+.  This is
inconsistent and technically prevents the whole from being
distributed under GPL2.
So replace sha1.h with a version from the GCC sources from before
  Tue Apr 20 08:36:39 2010
when the copyright notice was updated.

Reported-by: Jes Sorensen <Jes.Sorensen@redhat.com>
Signed-off-by: NeilBrown <neilb@suse.de>
11 years agoAdd MD_ARRAY_SIZE for --examine --export
Maciej Naruszewicz [Tue, 2 Oct 2012 06:42:25 +0000 (16:42 +1000)] 
Add MD_ARRAY_SIZE for --examine --export

An additional pair of key=value for --examine --export.

Signed-off-by: Maciej Naruszewicz <maciej.naruszewicz@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
11 years agoDisplay size with human_size_brief with a chosen prefix
Maciej Naruszewicz [Tue, 2 Oct 2012 06:41:13 +0000 (16:41 +1000)] 
Display size with human_size_brief with a chosen prefix

When using human_size_brief, only IEC prefixes were supported. Now
it's possible to specify which format we want to see - either IEC
(kibi, mibi, gibi) or JEDEC (kilo, mega, giga).

Signed-off-by: Maciej Naruszewicz <maciej.naruszewicz@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
11 years agoSynchronize size calculation in human_size and human_size_brief
Maciej Naruszewicz [Tue, 2 Oct 2012 06:40:11 +0000 (16:40 +1000)] 
Synchronize size calculation in human_size and human_size_brief

It would be better if two size-calculating methods had the same
calculating algorithm. The human_size way of calculation seems
more readable, so let's use it for both methods.

Signed-off-by: Maciej Naruszewicz <maciej.naruszewicz@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>