]> git.ipfire.org Git - thirdparty/mdadm.git/log
thirdparty/mdadm.git
9 years agoConsistently print program Name and __func__ in debug messages.
NeilBrown [Thu, 12 Feb 2015 02:21:17 +0000 (13:21 +1100)] 
Consistently print program Name and __func__ in debug messages.

make dprintf() print program name and __func__, so that
this messaging is consistent.

Also remove all __func__ messages from pr_err(). We shouldn't
leak that internal data in error message.
If we really want function name there, we new pr_XXX might
be wanted.

Signed-off-by: NeilBrown <neilb@suse.de>
9 years agoChange way of printing name of a process
Pawel Baldysiak [Wed, 11 Feb 2015 21:25:03 +0000 (22:25 +0100)] 
Change way of printing name of a process

Sometimes mdadm prints messages with wrong name "mdmon",
and vice versa.
This patch solves this problem by changing method of determining
process name.
Now "Name" will be set in const at start of a program,
previously was hardcoded as #define.

Signed-off-by: Pawel Baldysiak <pawel.baldysiak@intel.com>
Signed-off-by: Artur Paszkiewicz <artur.paszkiewicz@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
9 years agoMonitor: fix for regression with container devices
Artur Paszkiewicz [Mon, 9 Feb 2015 10:13:50 +0000 (11:13 +0100)] 
Monitor: fix for regression with container devices

This patch fixes 2 problems introduced by commit 9a518d8: not closing a
file descriptor and ignoring container devices. Array state is always
"inactive" for containers, so we make sure that the device is not a
container by reading also the "level" sysfs entry.

Signed-off-by: Artur Paszkiewicz <artur.paszkiewicz@intel.com>
Reviewed-by: Pawel Baldysiak <pawel.baldysiak@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
9 years agomdcheck: be careful when sourcing the output of "mdadm --detail --export"
NeilBrown [Tue, 3 Feb 2015 22:06:47 +0000 (09:06 +1100)] 
mdcheck: be careful when sourcing the output of "mdadm --detail --export"

The output of "mdadm --detail --export" isn't quoted properly so
fields that contain spaces can be a problem.
We only want the MD_UUID field, and it has a very well defined
format with no spaces.
So use 'grep' to limit the output to just that.

Signed-off-by: NeilBrown <neilb@suse.de>
9 years agoIMSM: Clear migration record on disks more often
Pawel Baldysiak [Tue, 20 Jan 2015 12:52:25 +0000 (13:52 +0100)] 
IMSM: Clear migration record on disks more often

Migration record is not always cleared after successful migration. This can
block another reshape from being started. Migration will not be continued via
systemd service due to error in verifying reshape position. This patch added
clearing migration record when disk is added to container, and after successful
migration.

Signed-off-by: Pawel Baldysiak <pawel.baldysiak@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
9 years agoutil: remove rounding error where reporting "human sizes".
NeilBrown [Thu, 18 Dec 2014 05:48:15 +0000 (16:48 +1100)] 
util: remove rounding error where reporting "human sizes".

The division
 1<<20 / 200
is not exact, so dividing by this to convert bytes into half-megs
is wrong and results in incorrect output.

As we are doing "long long" arithmetic, there is no risk of an overflow
until we reach 64 petabytes.
So change to
   * 200 / (1<<20).

Reported-by: Jan Echternach <jan@goneko.de>
Resolved-debian-bug: 763917
URL: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=763917
Signed-off-by: NeilBrown <neilb@suse.de>
9 years agoGrow: Fix wrong 'goto' in set_new_data_offset
Pawel Baldysiak [Thu, 27 Nov 2014 11:35:24 +0000 (12:35 +0100)] 
Grow: Fix wrong 'goto' in set_new_data_offset

Commit a821c95f114724b38df1ea99b2858178e0ed28ce
besides introducing additional message, also changed
direct return to "goto" instruction.
'goto release' will cause routine to return with '-1',
when previously '1' was returned.
Described behaviour breaks e.g. IMSM reshape process.
This patch fixes this issue by changing 'goto' to proper one -
the one that returns '1'.

Signed-off-by: Pawel Baldysiak <pawel.baldysiak@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
9 years agoMonitor: don't open md array that doesn't exist.
NeilBrown [Tue, 28 Oct 2014 21:48:02 +0000 (08:48 +1100)] 
Monitor: don't open md array that doesn't exist.

Opening a block-special-device for an array that doesn't
exist causes that array to be instantiated (as an empty array).
Races at array shutdown can cause the array to spontaneously
re-appear if some deamon notices a 'change' event and goes
to investigate.

Teach "mdadm --monitor" to avoid this race by checking the
"array_state" before opening the device.

Reported-by: Francis Moreau <francis.moro@gmail.com>
Signed-off-by: NeilBrown <neilb@suse.de>
9 years agoMakefile: binaries shouldn't directly depend on check_rundir
NeilBrown [Tue, 25 Nov 2014 00:44:18 +0000 (11:44 +1100)] 
Makefile: binaries shouldn't directly depend on check_rundir

check_rundir always needs to be "built", so making
mdadm and mdmon depend on it causes them to always be built.
i.e. running
   make ; make

will needlessly link the binaries a second time.

So change the makefile to use "order-only" pre-requisites.

Reported-by: Michael Tokarev <mjt@tls.msk.ru>
Signed-off-by: NeilBrown <neilb@suse.de>
9 years agoimsm: use efivarfs interface for reading UEFI variables
Artur Paszkiewicz [Thu, 20 Nov 2014 17:56:13 +0000 (18:56 +0100)] 
imsm: use efivarfs interface for reading UEFI variables

Read UEFI variables using the new efivarfs interface, fallback to
sysfs-efivars if that fails.

Signed-off-by: Artur Paszkiewicz <artur.paszkiewicz@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
9 years agoimsm: detail-platform improvements
Artur Paszkiewicz [Wed, 19 Nov 2014 12:53:29 +0000 (13:53 +0100)] 
imsm: detail-platform improvements

Print platform details per OROM, not per controller, differentiate
RST(e) platforms from legacy IMSM, print NVMe device paths, adjust port
printing to newer sysfs path.

Signed-off-by: Artur Paszkiewicz <artur.paszkiewicz@intel.com>
Signed-off-by: Pawel Baldysiak <pawel.baldysiak@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
9 years agoimsm: add support for NVMe devices
Pawel Baldysiak [Wed, 19 Nov 2014 12:53:28 +0000 (13:53 +0100)] 
imsm: add support for NVMe devices

Recognize Intel(R) NVMe devices as IMSM-capable.

Signed-off-by: Pawel Baldysiak <pawel.baldysiak@intel.com>
Signed-off-by: Artur Paszkiewicz <artur.paszkiewicz@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
9 years agoimsm: support for second and combined AHCI controllers in UEFI mode
Artur Paszkiewicz [Wed, 19 Nov 2014 12:53:27 +0000 (13:53 +0100)] 
imsm: support for second and combined AHCI controllers in UEFI mode

Grantly platform introduces a second AHCI controller (sSATA) and two new
UEFI variables for the RSTe firmware. This patch adds support for those
variables in order to correctly determine IMSM platform capabilities in
UEFI mode.

Signed-off-by: Artur Paszkiewicz <artur.paszkiewicz@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
9 years agoimsm: support for OROMs shared by multiple HBAs
Artur Paszkiewicz [Wed, 19 Nov 2014 12:53:26 +0000 (13:53 +0100)] 
imsm: support for OROMs shared by multiple HBAs

The IMSM platform code was based on an assumption that the OROM or UEFI
capability structure (represented by struct imsm_orom) always belongs to
only one HBA. This assumption is no longer valid, because of newer
platforms with dual AHCI HBAs. Each HBA can have a separate OROM, but
some versions have a combined OROM for both HBAs.

This patch implements this HBA-OROM relationship in struct orom_entry,
which matches an OROM with a list of HBA PCI ids. All the detected
orom_entries are stored and retrieved using a global array and the
functions add_orom(), add_orom_device_id() and get_orom_by_device_id().
This replaces the arrays: imsm_orom, populated_orom, imsm_efi,
populated_efi.

The scan() function is extended to find all HBAs for an OROM. The list
of their device ids is retrieved from the PCI Expansion ROM Data
Structure, hence the additional field devListOffset in struct
pciExpDataStructFormat.

In UEFI mode we can't read the PCI Expansion ROM Data Structure and the
imsm_orom structures are stored in UEFI variables. They do not provide a
similar device id list, so we also check the HBA PCI class to make sure
that the HBA has RAID mode enabled.

In super-intel.c there are changes which allow spanning of IMSM
containers over HBAs of the same type, but only if the HBAs share the
same OROM.  This is done by comparing imsm_orom pointers, which (outside
of platform-intel.c) always point to the global array containing all the
detected oroms. Additional warnings are added to
validate_container_imsm() to warn about potentially dangerous operations
in all the possible cases, e.g. when an array is assembled using disks
attached to HBAs with separate OROMs.

Signed-off-by: Artur Paszkiewicz <artur.paszkiewicz@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
9 years agoIncremental: don't be distracted by partition table when calling try_spare.
NeilBrown [Wed, 5 Nov 2014 05:21:42 +0000 (16:21 +1100)] 
Incremental: don't be distracted by partition table when calling try_spare.

Currently a partition table on a device makes "mdadm -I" think
the array has a particular metadata type and so will only
add it to an array of that (partition table) type .. which doesn't
make any sense.

So tell guess_super to only look for 'array' metadata.

Reported-by: Caspar Smit <c.smit@truebit.nl>
Signed-off-by: NeilBrown <neilb@suse.de>
9 years agoDetail: fix handling of 'disks' array.
NeilBrown [Mon, 3 Nov 2014 22:35:20 +0000 (09:35 +1100)] 
Detail: fix handling of 'disks' array.

Since the introduction of replacement devices, we reserve
to places in the "disks" array for each raid disk.
That means we should allocate to twice "max_disk" as the array
could have that many raid_disks (though that would limit the
number of replacements).

A couple of other places need to use "max_disks*2" instead of
"max_disks" to co-ordinate with this.

Reported-by: Or Sagi <ors@reduxio.com>
Signed-off-by: NeilBrown <neilb@suse.de>
9 years agosuper1: remove some debugging printfs in update_super1
NeilBrown [Mon, 3 Nov 2014 01:56:37 +0000 (12:56 +1100)] 
super1: remove some debugging printfs in update_super1

These should never have been there.

Signed-off-by: NeilBrown <neilb@suse.de>
9 years agoRebuildmap: strip local host name from device name.
NeilBrown [Mon, 3 Nov 2014 01:49:05 +0000 (12:49 +1100)] 
Rebuildmap: strip local host name from device name.

When /run/mdadm/map is being rebuilt, e.g. by "mdadm -Ir",
if the device doesn't exist in /dev, we have to choose
a name.
Currently we don't strip the hostname which is wrong if
it is the local host.

Reported-by: Stephen Kent <smkent@smkent.net>
Signed-off-by: NeilBrown <neilb@suse.de>
9 years agomdcheck: don't git error if not /dev/md?* devices exist.
NeilBrown [Mon, 3 Nov 2014 00:58:06 +0000 (11:58 +1100)] 
mdcheck: don't git error if not /dev/md?* devices exist.

If there are no such devices, the 'for' will set '$dev' to
'/dev/md?*', which should be ignored.

Signed-off-by: NeilBrown <neilb@suse.de>
9 years agoGrow: fix resize of array component size to > 32bits
Justin Maggard [Sat, 25 Oct 2014 00:55:02 +0000 (17:55 -0700)] 
Grow: fix resize of array component size to > 32bits

If the request --size to --grow an array to is larger
than 32bits, then mdadm may make the wrong choice and
use ioctl instead of setting component_size via sysfs
and the change is ignored.

Instead of using casts to check for a 32-bit overflow,
just check for set bits outside of INT32_MAX.

Fixes: 4e9a3dd16d656b269f5602624ac4f7109a571368
Signed-off-by: NeilBrown <neilb@suse.de>
9 years agomdmon: already read sysfs files once after opening.
NeilBrown [Wed, 17 Sep 2014 05:02:18 +0000 (15:02 +1000)] 
mdmon: already read sysfs files once after opening.

seq_file in the kernel will allocate a read buffer on
first read.  We want this to happen under the managemon thread,
not the 'monitor' thread, as the latter is not allow to allocate
memory (might deadlock).
So do a first read after opening.

Signed-off-by: NeilBrown <neilb@suse.de>
9 years agoGrow: Report when grow needs metadata update
Andy Smith [Fri, 29 Aug 2014 20:47:12 +0000 (20:47 +0000)] 
Grow: Report when grow needs metadata update

Report when the array's metadata needs updating instead of just
reporting the generic "kernel too old" message.

Signed-off-by: Andy Smith <andy@strugglers.net>
Signed-off-by: NeilBrown <neilb@suse.de>
9 years ago--update: add 'bbl' and 'no-bbl' to the list of known updates.
NeilBrown [Wed, 27 Aug 2014 11:04:59 +0000 (21:04 +1000)] 
--update: add 'bbl' and 'no-bbl' to the list of known updates.

so "mdadm -A --update=?" mentions them.

Reported-by: Peter Hoeg <peter@hoeg.com>
Signed-off-by: NeilBrown <neilb@suse.de>
9 years agoRelease mdadm-3.3.2 mdadm-3.3.2
NeilBrown [Thu, 21 Aug 2014 10:16:56 +0000 (20:16 +1000)] 
Release mdadm-3.3.2

Minor bugfix/stability release.

Signed-off-by: NeilBrown <neilb@suse.de>
9 years agoFix parallel make problem.
Samuli Suominen [Thu, 21 Aug 2014 03:56:48 +0000 (06:56 +0300)] 
Fix parallel make problem.

When make is called with, for example,
   "make -j9 install install-system"
i.e. both install and install-systemd targets at the same
line and with high -j value,
then the same install.tmp file was used, and udev rules
ends up in systemd service files, or otherway around.

For more information, see:
  http://www.spinics.net/lists/raid/msg46782.html
  http://bugs.gentoo.org/show_bug.cgi?id=517218

Signed-off-by: NeilBrown <neilb@suse.de>
9 years agosuper1: make sure 'room' includes 'bbl_size' when creating array.
NeilBrown [Thu, 21 Aug 2014 00:57:55 +0000 (10:57 +1000)] 
super1: make sure 'room' includes 'bbl_size' when creating array.

Because we then go ahead and subtrace bbl_size from room.

Signed-off-by: NeilBrown <neilb@suse.de>
9 years agosuper1: don't allow adding a bitmap if there is no space.
NeilBrown [Fri, 15 Aug 2014 05:45:54 +0000 (15:45 +1000)] 
super1: don't allow adding a bitmap if there is no space.

If the data is too close to the superblock there may be
no space for a bitmap.
If that happens, fail the adding of the bitmap rather than
corrupt data.

Reported-by: Lars Wijtemans <rhelbugzilla@lars.wijtemans.nl>
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=922944

9 years agoMonitor: Stop monitoring devices that have disappeared.
NeilBrown [Thu, 14 Aug 2014 05:36:09 +0000 (15:36 +1000)] 
Monitor: Stop monitoring devices that have disappeared.

If we are only monitoring a device because we found it in
/proc/mdstat, and it has been gone for 5 checks, forget
about it completely.

Signed-off-by: NeilBrown <neilb@suse.de>
9 years agomdadm: document some more magic environment variables.
NeilBrown [Thu, 14 Aug 2014 04:54:05 +0000 (14:54 +1000)] 
mdadm: document some more magic environment variables.

Others are mostly for developers.

Signed-off-by: NeilBrown <neilb@suse.de>
9 years agoManage: fix removal of non-existent devices.
NeilBrown [Mon, 11 Aug 2014 00:30:42 +0000 (10:30 +1000)] 
Manage: fix removal of non-existent devices.

"--remove detached" and others stopped working a while
back when I refactored some code.
For 'remove' and  'fail', the device may not exist so
if it is  "MM:mm", (e.g. added by "detached"), just parse
out the numbers.

Reported-by: Killian De Volder <killian.de.volder@megasoft.be>
Signed-off-by: NeilBrown <neilb@suse.de>
9 years agoutil: split get_maj_min() out from dev_open()
NeilBrown [Mon, 11 Aug 2014 00:27:31 +0000 (10:27 +1000)] 
util: split get_maj_min() out from dev_open()

This allows other code to parse "8:3" style device names.

Signed-off-by: NeilBrown <neilb@suse.de>
9 years agoManage: simplify `rdev` handling in Manage_subdevs.
NeilBrown [Mon, 11 Aug 2014 00:22:24 +0000 (10:22 +1000)] 
Manage: simplify `rdev` handling in Manage_subdevs.

The only use 'struct stat stb' to get the 'rdev', and sometimes
we don't even use 'stat'.
So make 'rdev' a stand-alone variable, and only declare stb'
when we actually need it.

Signed-off-by: NeilBrown <neilb@suse.de>
9 years agoconfig: new option to suppress adding bad block lists.
NeilBrown [Thu, 7 Aug 2014 02:23:45 +0000 (12:23 +1000)] 
config: new option to suppress adding bad block lists.

   CREATE bbl=no

in mdadm.conf will cause any devices added to an array
to not have a bad block list.  By default they do for 1.x
metadata.

This is useful if you are suspicious of the bad-block-list
implementation.

Reported-by: Ethan Wilson <ethan.wilson@shiftmail.org>
Signed-off-by: NeilBrown <neilb@suse.de>
9 years agomd.4: replace "bad block log" with "bad block list"
NeilBrown [Thu, 7 Aug 2014 02:22:41 +0000 (12:22 +1000)] 
md.4: replace "bad block log" with "bad block list"

Elsewhere we use the term "list", and it is more accurate.
Logs are usually append-only.  This list isn't.

Signed-off-by: NeilBrown <neilb@suse.de>
9 years agomdmon: don't include super0 and super1 in mdmon
NeilBrown [Thu, 7 Aug 2014 02:14:49 +0000 (12:14 +1000)] 
mdmon: don't include super0 and super1 in mdmon

They are no needed, and future patch will add a dependency
yo super1 which mdmon doesn't have.

Signed-off-by: NeilBrown <neilb@suse.de>
9 years agosuper: make sure to ignore disk state flags that we don't understand.
NeilBrown [Thu, 7 Aug 2014 01:34:50 +0000 (11:34 +1000)] 
super: make sure to ignore disk state flags that we don't understand.

This make it easier to add new flags that some super-types
don't understand.

Signed-off-by: NeilBrown <neilb@suse.de>
9 years agoDetail: Avoid dereferencing some NULL pointers.
NeilBrown [Wed, 6 Aug 2014 05:56:12 +0000 (15:56 +1000)] 
Detail: Avoid dereferencing some NULL pointers.

dm devices which only have a single underlying md device
will respond to md ioctls  as though they were that md device.
This can confuse mdadm and lead it to violating its segments.

So add tests for NULL where appropriate.  You might not get exactly
the right answer when you "mdadm -D" a dm device, but at least it won't
crash now.

Reported-by: Willy Weisz <Willy.Weisz@univie.ac.at>
Resolves: https://bugzilla.novell.com/show_bug.cgi?id=887821
Signed-off-by: NeilBrown <neilb@suse.de>
9 years agoDDF: cast print arguments in super-ddf.c
Guy Menanteau [Mon, 4 Aug 2014 14:53:03 +0000 (16:53 +0200)] 
DDF: cast print arguments in super-ddf.c

mdadm fails to build on ppc64 and ppc64le architectures.
===
super-ddf.c: In function '_set_config_size':
super-ddf.c:2849:4: error: format '%llx' expects argument of type 'long long unsigned int', but argument 6 has type '__u64' [-Werror=format=]
    pr_err("%s: %x:%x: workspace size 0x%llx too big, ignoring\n",
    ^
super-ddf.c:2855:2: error: format '%llx' expects argument of type 'long long unsigned int', but argument 6 has type '__u64' [-Werror=format=]
  dprintf("%s: %x:%x config_size %llx, DDF structure is %llx blocks\n",
  ^
cc1: all warnings being treated as errors
<builtin>: recipe for target 'super-ddf.o' failed
===

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1125883
Signed-off-by: <menantea@linux.vnet.ibm.com>
Signed-off-by: Michel Normand <normand@linux.vnet.ibm.com>
Signed-off-by: NeilBrown <neilb@suse.de>
9 years agoAssemble: Only fail auto-assemble in face of mdadm.conf conflicts.
NeilBrown [Tue, 29 Jul 2014 03:48:23 +0000 (13:48 +1000)] 
Assemble: Only fail auto-assemble in face of mdadm.conf conflicts.

We should never auto-assemble things that conflict with mdadm.conf
However explicit assembly requests should be allowed.

Reported-by: olovopb
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1070245
Signed-off-by: NeilBrown <neilb@suse.de>
9 years agoGrow: improve error message is "--grow -n2" used on Linear arrays.
NeilBrown [Tue, 29 Jul 2014 03:37:42 +0000 (13:37 +1000)] 
Grow: improve error message is "--grow -n2" used on Linear arrays.

Linear arrays don't respond to setting raid-disks, only to
adding a device.

Reported-by: mulhern
Reported-by: Jes Sorensen <Jes.Sorensen@redhat.com>
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1122146
Signed-off-by: NeilBrown <neilb@suse.de>
9 years agoGrow: fix that preventing resize of array to 32bit size.
NeilBrown [Mon, 21 Jul 2014 06:51:53 +0000 (16:51 +1000)] 
Grow: fix that preventing resize of array to 32bit size.

If the request --size to --grow an array to is 32bits
(i.e. msb in bit 32) then mdadm make wrong choice and
uses ioctl instead of setting component_size via sysfs
and the change is ignored.

This is fixed by using correct casts.

Reported-and-tested-by: Killian De Volder <killian.de.volder@megasoft.be>
Signed-off-by: NeilBrown <neilb@suse.de>
9 years agoIMSM: move "validate_container_imsm" to be included in mdassemble
Pawel Baldysiak [Fri, 18 Jul 2014 15:01:27 +0000 (17:01 +0200)] 
IMSM: move "validate_container_imsm" to be included in mdassemble

Commit 0c21b485e4beb7bcfe631412a231f7c1ea1067bc added new
function in imsm superswitch. This function should be
included in mdassemble.

Signed-off-by: Pawel Baldysiak <pawel.baldysiak@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
9 years agoGrow: Do not try to restart if reshape is running
Pawel Baldysiak [Wed, 16 Jul 2014 10:20:34 +0000 (12:20 +0200)] 
Grow: Do not try to restart if reshape is running

Grow process did not check if reshape is already started
when deciding about restarting.
Sync_action should be checked in this case, and if
reshape is running - restart flag should not be set.
Otherwise, Grow process will fail to write data to
sysfs, and reshape will not be continued.

Signed-off-by: Pawel Baldysiak <pawel.baldysiak@intel.com>
Signed-off-by: Artur Paszkiewicz <artur.paszkiewicz@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
9 years agoIMSM: validate metadata_update size before using it.
NeilBrown [Thu, 10 Jul 2014 06:09:28 +0000 (16:09 +1000)] 
IMSM: validate metadata_update size before using it.

Every case in prepare_update check that the size message
size is sufficient, so process_update doesn't need to check anything.

Reported-by: Vincent Berg <vberg@ioactive.com>
Signed-off-by: NeilBrown <neilb@suse.de>
9 years agoDDF: validate metadata_update size before using it.
NeilBrown [Thu, 10 Jul 2014 05:59:06 +0000 (15:59 +1000)] 
DDF: validate metadata_update size before using it.

process_update already checks update->len, for all but
the 'magic', prepare_update doesn't at all.

So add tests to prepare_update that we don't exceed the buffer.
This will consequently protect process_update from looking
for a 'magic' which isn't there.

Reported-by: Vincent Berg <vberg@ioactive.com>
Signed-off-by: NeilBrown <neilb@suse.de>
9 years agomdmon: allow prepare_update to report failure.
NeilBrown [Thu, 10 Jul 2014 05:54:02 +0000 (15:54 +1000)] 
mdmon: allow prepare_update to report failure.

If 'prepare_update' fails for some reason there is little
point continuing on to 'process_update'.
For now only malloc failures are caught, but other failures
will be considered in future.

Signed-off-by: NeilBrown <neilb@suse.de>
9 years agoIMSM: Add warning message when assemble spanned container
Pawel Baldysiak [Mon, 30 Jun 2014 12:22:22 +0000 (12:22 +0000)] 
IMSM: Add warning message when assemble spanned container

Due to several changes in code assemble with disks
spanned between different controllers can be obtained
in some cases. After IMSM container will be assembled, check HBA of
disks, and print proper warning if mismatch is detected.

Signed-off-by: Pawel Baldysiak <pawel.baldysiak@intel.com>
Signed-off-by: Artur Paszkiewicz <artur.paszkiewicz@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
9 years agomdmon: ensure Unix domain socket is created with safe permissions.
NeilBrown [Thu, 3 Jul 2014 07:06:45 +0000 (17:06 +1000)] 
mdmon: ensure Unix domain socket is created with safe permissions.

In the unlikely case that mdmon is started with an overly
permissive umask, we don't want to risk giving away world acccess.

All other "mkdir" and  "O_CREAT" calls in mdmon and mdadm set
a suitably restrictive permission mask.  'bind' don't take an
explicit mask so it needs an implicit one.

Reported-by: Vincent Berg <vberg@ioactive.com>
Signed-off-by: NeilBrown <neilb@suse.de>
9 years agomd.4: Make tables narrow enough to fit.
NeilBrown [Thu, 3 Jul 2014 06:49:15 +0000 (16:49 +1000)] 
md.4: Make tables narrow enough to fit.

If we use "Dev" instead of "Device" on the wide tables,
they fit better.

Signed-off-by: NeilBrown <neilb@suse.de>
9 years agorevised the documentation of RAID10 layouts
Christoph Anton Mitterer [Wed, 10 Jul 2013 14:03:11 +0000 (16:03 +0200)] 
revised the documentation of RAID10 layouts

* Completely revised the documentation of the RAID10 layouts, with examples for
  n2,f2,o2 with and odd and an even number of underlying devices.

Signed-off-by: Christoph Anton Mitterer <mail@christoph.anton.mitterer.name>
Signed-off-by: NeilBrown <neilb@suse.de>
9 years agoMakefile: use "man -l" to format man pages.
NeilBrown [Thu, 3 Jul 2014 05:29:03 +0000 (15:29 +1000)] 
Makefile: use "man -l" to format man pages.

Formatting a man page is more than just "nroff -man".
In particular, that doesn't invoke "tbl" when needed.

So use "man -l" which performs correct formatting on a
given file.

Signed-off-by: NeilBrown <neilb@suse.de>
9 years agomdadm.8: Fix typo in setting font.
NeilBrown [Thu, 3 Jul 2014 05:06:17 +0000 (15:06 +1000)] 
mdadm.8: Fix typo in setting font.

\fP returns to previous font, not \fp.

Signed-off-by: NeilBrown <neilb@suse.de>
9 years agomdadm.8: Fix typo in "no-bbl".
NeilBrown [Thu, 3 Jul 2014 05:05:35 +0000 (15:05 +1000)] 
mdadm.8: Fix typo in "no-bbl".

The '\' comes before the '-', not after!

Signed-off-by: NeilBrown <neilb@suse.de>
9 years agoIMSM: use strcpy rather than pointless strncpy.
NeilBrown [Thu, 3 Jul 2014 05:04:01 +0000 (15:04 +1000)] 
IMSM: use strcpy rather than pointless strncpy.

As strncpy doesn't guarantee to nul-terminate, some static
analysers get upset that it is followed by a 'strncat'.
So just use a 'strcpy' - strlen(disk_by_path) is constant
and definitely less than PATH_MAX.

Link: https://github.com/neilbrown/mdadm/issues/4
Signed-off-by: NeilBrown <neilb@suse.de>
9 years agoGrow: fix removal of line in wrong case
Pawel Baldysiak [Wed, 11 Jun 2014 15:18:44 +0000 (15:18 +0000)] 
Grow: fix removal of line in wrong case

Commit 18d9bcfa33939cee345d4d7735bc6081bcc409c8
removed wrong line (in case RAID0->RAID4).
This patch corrects this mistake
(line should be removed in case RAID4->RAID4).

Signed-off-by: Pawel Baldysiak <pawel.baldysiak@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
9 years agoMakefile: install mdadm-grow-continue@.service
NeilBrown [Tue, 10 Jun 2014 10:34:40 +0000 (20:34 +1000)] 
Makefile: install mdadm-grow-continue@.service

Forgot to add this to install-systemd target

Signed-off-by: NeilBrown <neilb@suse.de>
9 years agoRelease mdadm-3.3.1 mdadm-3.3.1
NeilBrown [Thu, 5 Jun 2014 06:45:56 +0000 (16:45 +1000)] 
Release mdadm-3.3.1

Signed-off-by: NeilBrown <neilb@suse.de>
9 years agoMake sure "make everything" builds again.
NeilBrown [Thu, 5 Jun 2014 06:38:29 +0000 (16:38 +1000)] 
Make sure "make everything" builds again.

Signed-off-by: NeilBrown <neilb@suse.de>
9 years agoIncremental: remove old devices when assembling in container.
NeilBrown [Thu, 5 Jun 2014 05:58:31 +0000 (15:58 +1000)] 
Incremental: remove old devices when assembling in container.

When assembling a native array we just give all devices to the kernel
and leave it to discard the 'old' ones (based on sequence/event
number).

For external/container arrays, mdadm needs to do that.

So in assemble_container_content, get list of current devices in
array and discard any that aren't in the 'content' given.
They must have been rejected by metadata manager.

If we cannot discard old devices the array must already be active, so
just leave it alone, but with a message.

Signed-off-by: NeilBrown <neilb@suse.de>
9 years agoimsm: retry load_and_parse_mpb if we suspect mdmon has made modifications
Artur Paszkiewicz [Mon, 2 Jun 2014 13:02:59 +0000 (15:02 +0200)] 
imsm: retry load_and_parse_mpb if we suspect mdmon has made modifications

If the checksum verification fails in mdadm and mdmon is running, retry
the load to get a consistent snapshot of the mpb.

Based on db575f3b

Signed-off-by: Artur Paszkiewicz <artur.paszkiewicz@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
9 years agoGrow: Do not fork via systemd if freeze_reshape is set
Baldysiak, Pawel [Fri, 30 May 2014 14:40:11 +0000 (14:40 +0000)] 
Grow: Do not fork via systemd if freeze_reshape is set

Mdadm should not run 'grow-continue' unit file for container if
'--freeze-reshape' argument is passed. Otherwise it will be ignored,
and reshape will start anyway.

Signed-off-by: Pawel Baldysiak <pawel.baldysiak@intel.com>
Reviewed-by: Artur Paszkiewicz <artur.paszkiewicz@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
9 years agoGrow: Use 'forked' also for reshape_container in Grow_continue
Baldysiak, Pawel [Fri, 30 May 2014 14:39:28 +0000 (14:39 +0000)] 
Grow: Use 'forked' also for reshape_container in Grow_continue

Similar to commit 06e293d0970e36b1ed049b9d3ccb21a870e9d2eb
same thing should be done for reshape_container in Grow_continue

Signed-off-by: Pawel Baldysiak <pawel.baldysiak@intel.com>
Reviewed-by: Artur Paszkiewicz <artur.paszkiewicz@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
9 years agoDo not set default 'before.layout' when reshaping from RAID4 to RAID4
Baldysiak, Pawel [Fri, 30 May 2014 14:38:09 +0000 (14:38 +0000)] 
Do not set default 'before.layout' when reshaping from RAID4 to RAID4

Commit fdcad551e9a54c4aa8c4b63160b76e2c539a0441
brings some changes to reshape process.
Setting 'before.layout' when reshaping from RAID4 to another RAID4 is
not really necessary.
If reshape is restarted 'before.layout' will be compared with
'info->array.layout' in reshape_array(). Changes brought by mentioned
commit will cause this comparation return as false, becouse 'array.layout'
is always set to 'ALGORITHM_PARITY_N' in analyse_change() for RAID4, so
reshape will not be continued after reboot/stop.
This patch reverts unnecessary changes.

Signed-off-by: Pawel Baldysiak pawel.baldysiak@intel.com
Reviewed-by: Artur Paszkiewicz <artur.paszkiewicz@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
9 years agomdcheck: don't pass the '+' to "date".
NeilBrown [Sun, 25 May 2014 23:37:05 +0000 (09:37 +1000)] 
mdcheck: don't pass the '+' to "date".

It isn't needed, makes is harder to describe what --duration does.

Signed-off-by: NeilBrown <neilb@suse.de>
9 years agoDDF: remove "BVD xx is missing".
NeilBrown [Thu, 22 May 2014 07:22:47 +0000 (17:22 +1000)] 
DDF: remove "BVD xx is missing".

This can happen in normal cases during incremental assembly so
printing an error message is confusing.

Signed-off-by: NeilBrown <neilb@suse.de>
9 years agoinstall: use BINDIR consistently to locate mdadm and mdmon
NeilBrown [Thu, 22 May 2014 07:13:02 +0000 (17:13 +1000)] 
install:  use BINDIR consistently to locate mdadm and mdmon

Every place where the paths for mdadm or mdmon is explicit,
it should use the BINDIR setting, not "/sbin/".

Reported-by: member graysky <graysky@archlinux.us> (https://bugs.archlinux.org/task/37330)
Signed-off-by: NeilBrown <neilb@suse.de>
9 years agomdcheck: new script to help with regular checks of md arrays.
NeilBrown [Thu, 22 May 2014 06:00:39 +0000 (16:00 +1000)] 
mdcheck: new script to help with regular checks of md arrays.

This script allows arrays to be 'checked' for a limited amount
of time on a regular basis.

For example, running

 mdcheck --duration 6hours

early every Sunday morning and

 mdcheck --continue 6hours

ever other morning will check all arrays every week, but if that take
more than 6 hours, will won't run into the day, but will be continued
the next morning, and the next ... etc.

Signed-off-by: NeilBrown <neilb@suse.de>
9 years agoMISC: add --action option to set or abort check/repair.
NeilBrown [Thu, 22 May 2014 05:55:31 +0000 (15:55 +1000)] 
MISC: add --action option to set or abort check/repair.

Signed-off-by: NeilBrown <neilb@suse.de>
9 years ago--examine-bitmap: give useful message if no bitmap found on md array.
NeilBrown [Thu, 22 May 2014 05:22:39 +0000 (15:22 +1000)] 
--examine-bitmap: give useful message if no bitmap found on md array.

The bitmap is stored on member devices, not on the array, so
--examine-bitmap should be given the member device.
If --examine-bitmap is given an array, and it doesn't have a bitmap
on it (i.e. it isn't a member of some other array), then that
is probably a usage error, so print a helpful message.

Signed-off-by: NeilBrown <neilb@suse.de>
9 years agomdadm: Do not reimplment offsetof
Cristian Rodríguez [Wed, 21 May 2014 16:45:19 +0000 (12:45 -0400)] 
mdadm: Do not reimplment offsetof

Proper implementations have offsetof in stddef.h

Signed-off-by: NeilBrown <neilb@suse.de>
9 years agoGrow: fix resent grow_continue breakage.
NeilBrown [Thu, 22 May 2014 04:22:58 +0000 (14:22 +1000)] 
Grow: fix resent grow_continue breakage.

Commit 5e76dce1acd906e8fc8af04973c3a129cdc77fd6 changed
Grow_continue to assume a fork had already happened, so that
   mdadm --grow --continue

didn't fork.  This is good, but it means that if Grow_continue
is run from Assemble, then
  mdadm --assemble ....

can misbehave if the array was in the middle of a reshape.

So introduce finer control.  Grow_continue only assumes it has
already forked if run from "mdadm --grow --continue".

Signed-off-by: NeilBrown <neilb@suse.de>
9 years agoDDF: remove some pointless code in validate_geometry
NeilBrown [Wed, 21 May 2014 04:03:48 +0000 (14:03 +1000)] 
DDF: remove some pointless code in validate_geometry

I'm not sure what this was supposed to do, but it isn't needed
as creating on a container and on individual devices (in a container)
work fine already.

Signed-off-by: NeilBrown <neilb@suse.de>
9 years agoDDF: remove a FIXME comment that doesn't seem to mean anything.
NeilBrown [Wed, 21 May 2014 03:51:33 +0000 (13:51 +1000)] 
DDF: remove a FIXME comment that doesn't seem to mean anything.

Signed-off-by: NeilBrown <neilb@suse.de>
9 years agoDDF: remove 'FIXME' comment that doesn't need fixing.
NeilBrown [Wed, 21 May 2014 03:50:52 +0000 (13:50 +1000)] 
DDF: remove 'FIXME' comment that doesn't need fixing.

It appears this is correct, though for consistency with elsewhere
we check that pdnum is not negative.

Signed-off-by: NeilBrown <neilb@suse.de>
9 years agoDDF: ensure dl->devname is freed when processing a 'delete device' update.
NeilBrown [Wed, 21 May 2014 03:27:54 +0000 (13:27 +1000)] 
DDF: ensure dl->devname is freed when processing a 'delete device' update.

As this code runs in 'monitor' it cannot just free memory,
it must add it to a list for 'manager' to free.
Fortunate update->space_list exists for just this purpose.
dl->devname might be small, so put it in update->space and
put dl in update->space_list.

Signed-off-by: NeilBrown <neilb@suse.de>
9 years agoDDF: remove old comment about looking for spares.
NeilBrown [Wed, 21 May 2014 03:10:03 +0000 (13:10 +1000)] 
DDF: remove old comment about looking for spares.

As handle_missing() sets ->check_degraded, nothing else needs to be
done here.

Signed-off-by: NeilBrown <neilb@suse.de>
9 years agoDDF: remove an old incorrect FIXME comment.
NeilBrown [Wed, 21 May 2014 03:00:08 +0000 (13:00 +1000)] 
DDF: remove an old incorrect FIXME comment.

We mustn't close fds in write_init_super if ->update_tail
was set.

Signed-off-by: NeilBrown <neilb@suse.de>
9 years agoDDF: add data-offset information to --examine output.
NeilBrown [Wed, 21 May 2014 02:43:40 +0000 (12:43 +1000)] 
DDF: add data-offset information to --examine output.

 Raid Devices[1] : 5 (4@20000K 3@20000K 2@0K 1@0K 0@0K)

The data offsets are 200000K and 0K.

Signed-off-by: NeilBrown <neilb@suse.de>
9 years agoDDF: split up ddf_process_update
NeilBrown [Wed, 21 May 2014 02:20:56 +0000 (12:20 +1000)] 
DDF: split up ddf_process_update

Function was way too big, make several smaller functions.

Signed-off-by: NeilBrown <neilb@suse.de>
9 years agotests: handle change to DDF assembly.
NeilBrown [Tue, 13 May 2014 02:22:03 +0000 (12:22 +1000)] 
tests: handle change to DDF assembly.

When a DDF array is assembled with missing devices, those devices
are now alway marked as 'missing' and cannot just re-appear in the array
and be working again.

test must be changed to acknowledge this.

Signed-off-by: NeilBrown <neilb@suse.de>
9 years agotests: handle new raid10/ddf geometries.
NeilBrown [Tue, 13 May 2014 02:19:40 +0000 (12:19 +1000)] 
tests: handle new raid10/ddf geometries.

Recent changes to support more ddf geometries using raid1e
requires updates to tests.

Signed-off-by: NeilBrown <neilb@suse.de>
9 years agoDDF: add support of --data-offset when creating array.
NeilBrown [Tue, 6 May 2014 04:52:24 +0000 (14:52 +1000)] 
DDF: add support of --data-offset when creating array.

Infrastructure is there, so use it.

This requires making sure that ->data_offset is correctly set, even
for containers.

Signed-off-by: NeilBrown <neilb@suse.de>
9 years agoDDF: factor out common code for search through extents.
NeilBrown [Tue, 6 May 2014 04:47:03 +0000 (14:47 +1000)] 
DDF: factor out common code for search through extents.

Each place the uses "get_extents" has slightly different search code
to look through the result.

Factor this out into a single find_space() function.

This is will make it easier to add --data-offset support.

Signed-off-by: NeilBrown <neilb@suse.de>
9 years agoDDF: allow for unused slots when creating map list for getinfo_super_ddf.
NeilBrown [Tue, 6 May 2014 01:42:12 +0000 (11:42 +1000)] 
DDF: allow for unused slots when creating map list for getinfo_super_ddf.

Signed-off-by: NeilBrown <neilb@suse.de>
9 years agoDDF: DDF_Missing devices should not be reported as 'working' by getinfo_super_ddf
NeilBrown [Tue, 6 May 2014 01:29:49 +0000 (11:29 +1000)] 
DDF: DDF_Missing devices should not be reported as 'working' by getinfo_super_ddf

Signed-off-by: NeilBrown <neilb@suse.de>
9 years agoDDF: remove old and wrong comment about settinig raid_disk.
NeilBrown [Mon, 28 Apr 2014 07:01:04 +0000 (17:01 +1000)] 
DDF: remove old and wrong comment about settinig raid_disk.

Signed-off-by: NeilBrown <neilb@suse.de>
9 years agoDDF: provide simple detail_super() implementation.
NeilBrown [Mon, 28 Apr 2014 06:50:57 +0000 (16:50 +1000)] 
DDF: provide simple detail_super() implementation.

Just print the GUID, Seq and number of VDs in the container.

Signed-off-by: NeilBrown <neilb@suse.de>
9 years agoDDF: support more RAID10 levels.
NeilBrown [Mon, 28 Apr 2014 05:31:50 +0000 (15:31 +1000)] 
DDF: support more  RAID10 levels.

The DDF "RAID1E" level is similar to md "raid10".

So use raid10 to support RAID1E, and create RAID1E for raid10
configs not already supported.

Signed-off-by: NeilBrown <neilb@suse.de>
9 years agoDDF: explain why spare_refs are ignored.
NeilBrown [Thu, 10 Apr 2014 02:57:25 +0000 (12:57 +1000)] 
DDF: explain why spare_refs are ignored.

Signed-off-by: NeilBrown <neilb@suse.de>
9 years agoDDF: use array_size from metadata.
NeilBrown [Thu, 10 Apr 2014 02:54:13 +0000 (12:54 +1000)] 
DDF: use array_size from metadata.

If some other controller sets a number smaller than a calculation
would give us, we really should honour it.

Signed-off-by: NeilBrown <neilb@suse.de>
9 years agoDDF: set utime for container from timestamp is superblock.
NeilBrown [Thu, 10 Apr 2014 01:44:50 +0000 (11:44 +1000)] 
DDF: set utime for container from timestamp is superblock.

Also be more consistent about setting events from seq in superblock.

Signed-off-by: NeilBrown <neilb@suse.de>
9 years agoDDF: don't assume the anchor is fully up-to-date.
NeilBrown [Thu, 10 Apr 2014 01:41:18 +0000 (11:41 +1000)] 
DDF: don't assume the anchor is fully up-to-date.

We currently copy the anchor to both primary and secondary
blocks.
This assumes that the anchor is uptodate, but it might not be.
We should trust the 'active' block and copy from there.

Signed-off-by: NeilBrown <neilb@suse.de>
9 years agoDDF: update timestamp/seqnum for virtual disks when config changes.
NeilBrown [Thu, 10 Apr 2014 01:34:56 +0000 (11:34 +1000)] 
DDF: update timestamp/seqnum for virtual disks when config changes.

- we weren't updating this timestamp at all
- the 'vd_config' seqnum was updated on every write of the metadata,
  which is excessive.  Just update it when there is a change.

Signed-off-by: NeilBrown <neilb@suse.de>
9 years agoDDF: update timestamp in DDF header.
NeilBrown [Wed, 9 Apr 2014 07:11:57 +0000 (17:11 +1000)] 
DDF: update timestamp in DDF header.

Doco says:
  Header update timestamp. MUST be set when the DDF
  header is updated.

So I guess we should.

Signed-off-by: NeilBrown <neilb@suse.de>
9 years agoDDF: avoid ref outside array in getinfo_super_ddf_bvd
NeilBrown [Wed, 9 Apr 2014 06:59:49 +0000 (16:59 +1000)] 
DDF: avoid ref outside array in getinfo_super_ddf_bvd

As we are range-checking 'cd', there is a chance that it is not
in-range.  In that case we should include all array indexes with 'cd'
inside the range-tested branch.

Signed-off-by: NeilBrown <neilb@suse.de>
9 years agoDDF: examine_pds to also list devices that aren't in the metadata.
NeilBrown [Wed, 9 Apr 2014 06:56:45 +0000 (16:56 +1000)] 
DDF: examine_pds to also list devices that aren't in the metadata.

The phys disks table should list all disks, but if the metadata
is corrupt, it might not even list the disk it was read from.
So check for and report any known disks that aren't listed.

Signed-off-by: NeilBrown <neilb@suse.de>
9 years agoDDF: fix usage of ->used_pdes
NeilBrown [Wed, 9 Apr 2014 06:45:27 +0000 (16:45 +1000)] 
DDF: fix usage of ->used_pdes

The "used_pdes" value counts the number of physdisk entries that
are in used.
It may not be the last one in use as there may be unused slots in
the middle.

So when were are iterating over phys disks, we need to use max_pdes
and skip unused entries.

Signed-off-by: NeilBrown <neilb@suse.de>
9 years agoDDF: more guards against pdnum being negative.
NeilBrown [Wed, 9 Apr 2014 06:35:18 +0000 (16:35 +1000)] 
DDF: more guards against pdnum being negative.

With consistent metdata, pdnum should never be negative,
but it is better to be safe than sorry.

Signed-off-by: NeilBrown <neilb@suse.de>
9 years agoReshape: use systemd to continue containers as well as native arrays.
NeilBrown [Tue, 20 May 2014 06:59:58 +0000 (16:59 +1000)] 
Reshape: use systemd to continue containers as well as native arrays.

Signed-off-by: NeilBrown <neilb@suse.de>
9 years agoGrow: split continue_via_systemd into a separate function.
NeilBrown [Tue, 20 May 2014 06:56:51 +0000 (16:56 +1000)] 
Grow: split continue_via_systemd into a separate function.

This allows it to be used for containers too.

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