Commit Graph

150 Commits

Author SHA1 Message Date
Jes Sorensen 28156667e5 gcc-8 coverity hack
Coverity still has issues with gcc-7, not to mention gcc-8. Hack around
it, until they fix it.

Signed-off-by: Jes Sorensen <jsorensen@fb.com>
2018-06-04 14:49:59 -04:00
NeilBrown f93b797b71 Move mdadm_env.sh out of /usr/lib/systemd
The systemd developers like to keep control of the
lib/systemd namespace, and haven't approved of the use
of lib/systemd/scripts.  So we should stop using it.

Move the mdadm_env.sh script, optionally sourced by
mdmonitor.service, to a new directory /usr/lib/mdadm.

Signed-off-by: NeilBrown <neilb@suse.com>
Signed-off-by: Jes Sorensen <jsorensen@fb.com>
2017-10-10 16:45:04 -04:00
Guoqing Jiang 0e23c59718 udev rules: introduce rules for cluster-md to confirm device
For cluster scenario, add device is different with native raid.
When a node issues adds a device, then the node will broadcast
a message with UUID to other nodes in the cluster. If receiving
node can find the device with the specific UUID, it must confirm
the device, otherwise reports it is missing.

Signed-off-by: Guoqing Jiang <gqjiang@suse.com>
Signed-off-by: Jes Sorensen <jsorensen@fb.com>
2017-08-02 09:30:51 -04:00
NeilBrown cd6cbb08c4 Create: tell udev md device is not ready when first created.
When an array is created the content is not initialized,
so it could have remnants of an old filesystem or md array
etc on it.
udev will see this and might try to activate it, which is almost
certainly not what is wanted.

So create a mechanism for mdadm to communicate with udev to tell
it that the device isn't ready.  This mechanism is the existance
of a file /run/mdadm/created-mdXXX where mdXXX is the md device name.

When creating an array, mdadm will create the file.
A new udev rule file, 01-md-raid-creating.rules, will detect the
precense of thst file and set ENV{SYSTEMD_READY}="0".
This is fairly uniformly used to suppress actions based on the
contents of the device.

Signed-off-by: NeilBrown <neilb@suse.com>
Signed-off-by: Jes Sorensen <jsorensen@fb.com>
2017-05-02 09:41:39 -04:00
Jes Sorensen 17d80e6eb6 Makefile: Default to -O2 optimization
Signed-off-by: Jes Sorensen <jsorensen@fb.com>
2017-04-21 12:06:35 -04:00
Coly Li b63804583e mdadm: retire mdassemble in make everything
make everything reports no rule to make mdassemble, because mdassemble
is removed from mdadm. This patch removes mdassemble from "everything"
in Makefile, now there is no failure when compiling a static mdadm binary.

Signed-off-by: Coly Li <colyli@suse.de>
Signed-off-by: Jes Sorensen <jsorensen@fb.com>
2017-04-20 12:28:32 -04:00
Jes Sorensen 32141c1765 Retire mdassemble
mdassemble doesn't handle container based arrays, no support for sysfs,
etc. It has not been actively maintained for years, so time to send it
off to retirement.

Signed-off-by: Jes Sorensen <jsorensen@fb.com>
2017-04-11 12:54:26 -04:00
Artur Paszkiewicz 2432ce9b32 imsm: PPL support
Enable creating and assembling IMSM raid5 arrays with PPL. Update the
IMSM metadata format to include new fields used for PPL.

Add structures for PPL metadata. They are used also by super1 and shared
with the kernel, so put them in md_p.h.

Write the initial empty PPL header when creating an array. When
assembling an array with PPL, validate the PPL header and in case it is
not correct allow to overwrite it if --force was provided.

Write the PPL location and size for a device to the new rdev sysfs
attributes 'ppl_sector' and 'ppl_size'. Enable PPL in the kernel by
writing to 'consistency_policy' before the array is activated.

Signed-off-by: Artur Paszkiewicz <artur.paszkiewicz@intel.com>
Signed-off-by: Jes Sorensen <Jes.Sorensen@gmail.com>
2017-03-29 11:32:49 -04:00
Xiao Ni 8268821b43 mdadm: Add Wimplicit-fallthrough=0 in Makefile
There are many errors like 'error: this statement may fall through'.
But the logic is right. So add the flag Wimplicit-fallthrough=0
to disable the error messages. The method I use is from
https://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html
#index-Wimplicit-fallthrough-375

Signed-off-by: Xiao Ni <xni@redhat.com>
Signed-off-by: Jes Sorensen <Jes.Sorensen@gmail.com>
2017-03-17 15:56:50 -04:00
Jes Sorensen 53835cf500 Makefile: Fix date to be output in ISO format
Updated the static version in the release, but forgot to fix the
Makefile generated version when extracting from git

Reported-by: NeilBrown <neilb@suse.com>
Signed-off-by: Jes Sorensen <Jes.Sorensen@gmail.com>
2017-01-10 18:51:40 -05:00
Maxin B. John 1180ed5000 Makefile: make the CC definition conditional
By hardcoding CC's definition in the Makefile, all the external gcc
parameters set by tune settings are lost. This causes compile failure
with x32 toolchain

Signed-off-by: Maxin B. John <maxin.john@intel.com>
Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
2016-02-08 10:54:34 -05:00
NeilBrown 7071320a18 Assorted fixed for a "make everything" build
Signed-off-by: NeilBrown <neilb@suse.com>
2016-01-28 13:28:58 +11:00
NeilBrown ef639064b6 restripe: fix compilation of "make test"
Signed-off-by: NeilBrown <neilb@suse.com>
2016-01-13 10:01:02 +11:00
Song Liu 198d54787c add crc32c and use it for r5l checksum
In kernel space, r5l checksum will use crc32c:
http://marc.info/?l=linux-raid&m=144598970529191
mdadm need to change too.

This patch ports a simplified crc32c algorithm from kernel code,
and used in super1.c:write_empty_r5l_meta_block();

Signed-off-by: Song Liu <songliubraving@fb.com>
Signed-off-by: Shaohua Li <shli@fb.com>
Signed-off-by: NeilBrown <neilb@suse.com>
2015-10-30 17:38:28 +11:00
Guoqing Jiang d15a1f72bd Safeguard against writing to an active device of another node
Modifying an exiting device's superblock or creating a new superblock
on an existing device needs to be checked because the device could be
in use by another node in another array. So, we check this by taking
all superblock locks in userspace so that we don't  step onto an active
device used by another node and safeguard against accidental edits.
After the edit is complete, we release all locks and the lockspace so
that it can be used by the kernel space.

Signed-off-by: Goldwyn Rodrigues <rgoldwyn@suse.com>
Signed-off-by: Guoqing Jiang <gqjiang@suse.com>
Signed-off-by: NeilBrown <neilb@suse.com>
2015-10-21 11:19:05 +11:00
NeilBrown ccc93b33ca Makefile: test -s flag and suppress echo when set.
Some rules do their own tracing and so aren't affected
by -s.
So add a test for -s in MAKE_FLAGS and avoid echo when present.

Signed-off-by: NeilBrown <neilb@suse.com>
2015-08-05 15:10:43 +10:00
NeilBrown 53a087b105 mdassemble: include mapfile support.
This does make mdassemble a bit bigger, but it also means
it actually works properly with named arrays.

Ref: https://bbs.archlinux.org/viewtopic.php?id=198196
Signed-off-by: NeilBrown <neilb@suse.com>
2015-08-03 11:54:16 +10:00
Guoqing Jiang 7716570e6d Set home-cluster while creating an array
The home-cluster is stored in the bitmap super block of the
array. The device can be assembled on a cluster with the
cluster name same as the one recorded in the bitmap.

If home-cluster is not specified, this is auto-detected using
dlopen corosync cmap library.

neilb: allow code to compile when corosync-devel is not installed.

Signed-off-by: Goldwyn Rodrigues <rgoldwyn@suse.com>
Signed-off-by: Guoqing Jiang <gqjiang@suse.com>
Signed-off-by: NeilBrown <neilb@suse.de>
2015-06-17 09:06:30 +10:00
NeilBrown 7ae0775871 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>
2014-11-25 11:44:18 +11:00
Samuli Suominen 47c4331d1f 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>
2014-08-21 15:00:29 +10:00
NeilBrown 935a32543e 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>
2014-08-07 12:14:49 +10:00
NeilBrown 6ffdbec6e2 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>
2014-07-03 16:46:43 +10:00
NeilBrown 616f197f9d Makefile: install mdadm-grow-continue@.service
Forgot to add this to install-systemd target

Signed-off-by: NeilBrown <neilb@suse.de>
2014-06-10 20:34:40 +10:00
NeilBrown 1e60caebbc Make sure "make everything" builds again.
Signed-off-by: NeilBrown <neilb@suse.de>
2014-06-05 16:38:29 +10:00
NeilBrown 85945e1986 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>
2014-05-22 17:13:02 +10:00
NeilBrown 5e76dce1ac Grow: try to let "--grow --continue" from systemd complete a reshape.
If "--assemble" or "--incremental" is started by udev, then
monitoring the reshape in the background won't work.

So try asking systemd to start a grow-continue.

If that fails, just do it the old way.

Signed-off-by: NeilBrown <neilb@suse.de>
2014-05-15 14:23:21 +10:00
NeilBrown 8d1d32bb33 systemd: various fixes for boot with container-arrays.
1/ Add systemd shutdown script to ensure DDF and IMSM are
   clean before we actually shutdown

2/ Get udev to tell systemd to run the mdmon@mdXXX.service
   units when a member array appears.

   If we boot off a member array (with dracut at least),
   the mdmon started in the initramfs will lose track of
   /sys etc, so we need to restart it.
   systemd will try to forget about it too (but not actually
   kill it because we said not to do this).
   Having udev tell it to start it will allow a new mdmon to
   run which can see /sys, and systemd will know about it.

3/ Always use --offroot and --takeover when starting mdmon with
   systemd
   --offroot is needed else shutdown will hang.
   --takeover is needed incase an mdmon was started earlier
   (e.g. in initramfs).
   Neither hurt if they aren't actually needed.

Signed-off-by: NeilBrown <neilb@suse.de>
2014-04-08 17:37:08 +10:00
NeilBrown 61c0947158 Add mdmonitor.service systemd unit file.
This systemd unit file runs mdadm in --monitor mode.
It is started by a SYSTEMD_WANTS signal from udev whenever
an md array is started that would benefit from mdadm --monitor.

Commandline arguments can be provided by a script
  /usr/lib/systemd/scripts/mdadm_env.sh
which should write an
  MDADM_MONITOR_ARGS=....
line to /run/sysconfig/mdadm

A script to extra args from SUSE's /etc/sysconfig/mdadm file
is provided.
If no mdadm_env.sh is provided, then args are "--scan" which
requires "mail" or "program" to be set in /etc/mdadm.conf.
I believe this is suitable for Fedora.

Signed-off-by: NeilBrown <neilb@suse.de>
2013-12-11 10:47:54 +11:00
NeilBrown 169ffac7ad Systemd integration for starting newly-degraded arrays.
Normally "mdadm -I" will not start an array if it has reason to
expect further devices.
This means that if a device is removed while the host is shut down,
"mdadm -I" will never start the device.

If  the array is know to the host, it make sense to start the array
anyway after a reasonable timeout.

This patch adds systemd/udev infrastructure so that 30 seconds after
a known array first becomes able to be assembled as a degraded array,
the array will be assembled even if more devices are still expected.

Signed-off-by: NeilBrown <neilb@suse.de>
2013-12-02 16:08:04 +11:00
Michael Tokarev fe8ea9407f Remove bashism from Makefile
Makefile uses [ x == y ] construct which does not work
with POSIX shell.  Since this is just testing a flag,
replace it with string comparison (=) operator instead.

Signed-off-By: Michael Tokarev <mjt@tls.msk.ru>

Signed-off-by: NeilBrown <neilb@suse.de>
2013-09-18 09:21:23 +10:00
NeilBrown ebf916c526 Makefile: check that 'run' directory exists.
mdadm default to using /run/mdadm.  However not all distros
provide /run yet.  This can confuse people who build their own
mdadm.
So have "make" complain if the given directory doesn't exist.
This will make it harder to build an mdadm which doesn't work.

Reported-by: Albert Pauw <albert.pauw@gmail.com>
Signed-off-by: NeilBrown <neilb@suse.de>
2013-08-05 16:42:12 +10:00
NeilBrown 71556ff9ac raid6check - fix compile
Recent rearrangement of library code broke 'raid6check' and this
wasn't noticed because 'make everything' doesn't build it.

So fix the breakage and have 'make everything' built it.

Signed-off-by: NeilBrown <neilb@suse.de>
2013-07-02 16:06:55 +10:00
NeilBrown 289c74f8d7 Move find_free_devnum to mdopen.c
There is only one called to find_free_devnum and it is in mdopen.c

The removes a dependency between util.c and config.c which allows
us to now drop config.o from mdmon.

Signed-off-by: NeilBrown <neilb@suse.de>
2013-07-02 10:24:50 +10:00
NeilBrown 8e4a42719c "make test" should build "raid6check"
As there are selftests for raid6check.

Signed-off-by: NeilBrown <neilb@suse.de>
2013-06-27 14:09:48 +10:00
NeilBrown b379508eeb Makefile/version: use version/date from .git if possible.
If being built from a git tree, use the version and date
information from the top commit rather than the hard-coded
values.

Signed-off-by: NeilBrown <neilb@suse.de>
2013-06-25 16:27:05 +10:00
NeilBrown 688eb823bc Make: CXFLAGS should be conditionally assigned.
As the Makefile encourages users to set CXFLAGS for extra flags,
we should only conditionally set it.
That way it can be over-ridden in the environment as well as on
the command line.

Suggested-by: Bernd Schubert <bernd.schubert@itwm.fraunhofer.de>
Signed-off-by: NeilBrown <neilb@suse.de>
2013-06-24 16:59:37 +10:00
NeilBrown 1011e8344a Remove lots of unnecessary white space.
Now that I am using white-space mode in Emacs I can see all of this,
and I don't like it :-)

Signed-off-by: NeilBrown <neilb@suse.de>
2013-06-19 12:31:45 +10:00
NeilBrown 7506f86012 Makefile: add "-O3" to WARN_UNUSED options.
This finds more errors

Also remove some trailing spaces.

Signed-off-by: NeilBrown <neilb@suse.de>
2013-06-19 10:02:54 +10:00
NeilBrown 74db60b00a Add --dump / --restore functionality.
This allows the metadata on a device to be saved and later restored.
This can be useful before experimenting on an array that is misbehaving.

Suggested-by: Dan Williams <dan.j.williams@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
2013-05-16 15:07:16 +10:00
Thomas Bächler 2452f13a41 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>
2013-02-11 11:15:34 +11:00
Jes Sorensen 0f7bdf8946 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>
2013-02-05 15:40:38 +11:00
NeilBrown 04463b2f58 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>
2012-11-20 12:15:11 +11:00
Robert Buchholz 1cc101f3f8 Move xmalloc et al into their own file
This avoid code duplication for utilities that do not link to
util.c and everything that comes with it, such as test_restripe and
raid6check

Signed-off-by: NeilBrown <neilb@suse.de>
2012-09-10 17:23:59 +10:00
Samuli Suominen fa0d79e2b2 query udev dir via pkg-config
Since udev is moving its internal dir around, query it via pkg-config
rather than hardcoding the old path.  This should work with new/old
versions.

Signed-off-by: Samuli Suominen <ssuominen@gentoo.org>
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
Signed-off-by: NeilBrown <neilb@suse.de>
2012-08-14 09:46:25 +10:00
Mike Frysinger 824cb837f2 mdassemble: split dietlibc logic into dedicated target
This lets people run `make mdassemble` and get a sane build by default.

Signed-off-by: Mike Frysinger <vapier@gentoo.org>
Signed-off-by: NeilBrown <neilb@suse.de>
2012-08-13 08:07:49 +10:00
Mike Frysinger bb624f78b9 fix handling of CPPFLAGS
The current Makefile ends up ignoring the system CPPFLAGS settings,
so make sure we append the variable.  Also, the old metadata logic
has a typo with the flag name.

Signed-off-by: Mike Frysinger <vapier@gentoo.org>
Signed-off-by: NeilBrown <neilb@suse.de>
2012-08-13 08:07:49 +10:00
NeilBrown 96fd06edce Adjust to new standard of /run
Now that /run seems to be a good standard, make that
the default for storing various run-time files, rather than
/var/run or /dev/.mdadm.

Signed-off-by: NeilBrown <neilb@suse.de>
2012-05-03 14:16:56 +10:00
Piergiorgio Sartor c48d75d38f RAID-6 check standalone man page
Signed-off-by: NeilBrown <neilb@suse.de>
2011-08-09 10:43:58 +10:00
Mike Frysinger 8ccca44dde mdadm/mdmon: use CFLAGS when linking
People often put flags that control ABI options into CFLAGS (like -mcpu)
and don't duplicate them in LDFLAGS because most build systems nowadays
(like autotools) use both when linking.  So make that work with mdadm's
custom build system too.

Signed-off-by: Mike Frysinger <vapier@gentoo.org>
Signed-off-by: NeilBrown <neilb@suse.de>
2011-04-11 14:54:42 +10:00
Mike Frysinger 9e69baf3d4 move .man targets from "all" to "man" - and "everything"
These .man files are never installed, nor generally used, so don't force
people who generally want to build/install mdadm to build them up.

Signed-off-by: Mike Frysinger <vapier@gentoo.org>
Signed-off-by: NeilBrown <neilb@suse.de>
2011-04-11 14:54:16 +10:00