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>
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>
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>
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>
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>
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>
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>
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>
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>
mdadm: document some more magic environment variables.

Others are mostly for developers.

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

Minor bugfix/stability release.

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