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>
Make sure "make everything" builds again.

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

Signed-off-by: NeilBrown <neilb@suse.de>
Makefile: install mdadm-grow-continue@.service

Forgot to add this to install-systemd target

Signed-off-by: NeilBrown <neilb@suse.de>
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>
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>
mdadm.8: Fix typo in "no-bbl".

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

Signed-off-by: NeilBrown <neilb@suse.de>
mdadm.8: Fix typo in setting font.

\fP returns to previous font, not \fp.

Signed-off-by: NeilBrown <neilb@suse.de>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>