Commit Graph

159 Commits

Author SHA1 Message Date
Lukasz Florczak e9dd564484 mdadm: Respect config file location in man
Default config file location could differ depending on OS (e.g. Debian family).
This patch takes default config file into consideration when creating mdadm.man
file as well as mdadm.conf.man.

Rename mdadm.conf.5 to mdadm.conf.5.in. Now mdadm.conf.5 is generated automatically.

Signed-off-by: Lukasz Florczak <lukasz.florczak@linux.intel.com>
Acked-by: Coly Li <colyli@suse.de>
Signed-off-by: Jes Sorensen <jsorensen@fb.com>
2022-04-04 21:12:54 -04:00
Mariusz Tkaczyk af3396dadf Monitor: make libudev dependency optional
Make -ludev configurable, enabled by default.
To disable it, -DNO_LIBUDEV has to be set explicitly in CXFALGS.

This patch restores commit cab9c67d46 ("mdmonitor: set small delay
once") for configuration without libudev to bring minimal support in
such case.

Signed-off-by: Mariusz Tkaczyk <mariusz.tkaczyk@linux.intel.com>
Signed-off-by: Jes Sorensen <jsorensen@fb.com>
2021-03-19 08:31:11 -04:00
Oleksandr Shchirskyi 49b69533e8 mdmonitor: check if udev has finished events processing
If mdmonitor is awaken by event, wait for udev to finish
events processing, to eliminate the race between udev and mdadm
when spare has been added and need to be moved by mdmonitor

Signed-off-by: Oleksandr Shchirskyi <oleksandr.shchirskyi@intel.com>
Signed-off-by: Jes Sorensen <jsorensen@fb.com>
2021-03-08 10:20:48 -05:00
Kinga Tanska b4a5ad4958 Make target to install binaries only
Make install causes installation of binaries, udev and man.
This commit contains new target make install-bin, which
results in installation of binaries only.

Signed-off-by: Kinga Tanska <kinga.tanska@intel.com>
2020-11-25 18:20:55 -05:00
Guoqing Jiang f4c8a605d2 uuid.c: split uuid stuffs from util.c
Currently, 'make raid6check' is build broken since commit b06815989
("mdadm: load default sysfs attributes after assemblation").

/usr/bin/ld: sysfs.o: in function `sysfsline':
sysfs.c:(.text+0x2707): undefined reference to `parse_uuid'
/usr/bin/ld: sysfs.c:(.text+0x271a): undefined reference to `uuid_zero'
/usr/bin/ld: sysfs.c:(.text+0x2721): undefined reference to `uuid_zero'

Apparently, the compile of mdadm or raid6check are coupled with uuid
functions inside util.c. However, we can't just add util.o to CHECK_OBJS
which raid6check is needed, because it caused other worse problems.

So, let's introduce a uuid.c file which is indenpended file to fix the
problem, all the contents are splitted from util.c.

Signed-off-by: Guoqing Jiang <guoqing.jiang@cloud.ionos.com>
Signed-off-by: Jes Sorensen <jsorensen@fb.com>
2020-05-18 20:10:39 -04:00
Tkaczyk Mariusz 03ab9763f5 Makefile: add EXTRAVERSION support
Add optional EXTRAVERSION parameter to Makefile and allow to mark version
by user friendly label. It might be useful when creating custom
spins of mdadm, or labeling some instance in between major releases.

Signed-off-by: Tkaczyk Mariusz <mariusz.tkaczyk@intel.com>
Signed-off-by: Jes Sorensen <jsorensen@fb.com>
2020-05-15 09:52:01 -04:00
dann frazier aced6fc954 Respect $(CROSS_COMPILE) when $(CC) is the default
Commit 1180ed5 told make to only respect $(CROSS_COMPILE) when $(CC)
was unset. But that will never be the case, as make provides
a default value for $(CC). Change this logic to respect $(CROSS_COMPILE)
when $(CC) is the default. Patch originally by Helmet Grohne.

Fixes: 1180ed5 ("Makefile: make the CC definition conditional")
Signed-off-by: dann frazier <dann.frazier@canonical.com>
Signed-off-by: Jes Sorensen <jsorensen@fb.com>
2020-01-16 13:46:53 -05:00
NeilBrown 7cd7e91ab3 Monitor: add system timer to run --oneshot periodically
"mdadm --monitor --oneshot" can be used to get a warning
if there are any degraded arrays.  It can be helpful to get
this warning periodically while the condition persists.

This patch add a systemd service and timer which can
be enabled with
   systemctl enable mdmonitor-oneshot.service

and will then provide daily warnings.

Signed-off-by: NeilBrown <neilb@suse.com>
Signed-off-by: Jes Sorensen <jsorensen@fb.com>
2018-12-06 07:44:57 -05:00
NeilBrown 4199d3c629 mdcheck: add systemd unit files to run mdcheck.
Having the mdcheck script is not use if is never run.
This patch adds systemd unit files so that it can easily
be run on the first Sunday of each month for 6 hours,
then on every subsequent morning until the check is
finished.

The units still need to be enabled with
  systemctl enable mdcheck_start.timer

The timer will only actually be started when an array
which might need it becomes active.

Signed-off-by: NeilBrown <neilb@suse.com>
Signed-off-by: Jes Sorensen <jsorensen@fb.com>
2018-12-06 07:44:18 -05:00
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