Commit Graph

114 Commits

Author SHA1 Message Date
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
Piergiorgio Sartor a9c2c6c697 RAID-6 check standalone md device
Allow RAID-6 check to be passed only the
MD device, start and length.
The three parameters are mandatory.

All necessary information is collected using
the "sysfs_read()" call.
Furthermore, if "length" is "0", then the check
is performed until the end of the array.

Some checks are done, for example if the md device
is really a RAID-6. Nevertheless I guess it is not
bullet proof...

Next patch will include the "suspend" action.
My idea is to do it "per stripe", please let me
know if you've some better options.

Signed-off-by: NeilBrown <neilb@suse.de>
2011-04-05 08:56:41 +10:00
NeilBrown 78c0a3b17f Split some of util.c into a new lib.c
Some of util.c is dependent on lots of other code, some of it
is stand-alone.
Move some of the stand-alone stuff into a new lib.c so it can be used
by smaller utilities.

Signed-off-by: NeilBrown <neilb@suse.de>
2011-04-05 08:44:54 +10:00
NeilBrown 32367cb558 split name/number maps into separate file.
This reduced some interdependencies between files.

Signed-off-by: NeilBrown <neilb@suse.de>
2011-04-05 08:40:49 +10:00
Piergiorgio Sartor 979afcb82b RAID-6 check standalone
Hi Neil,

please find attached a patch, to mdadm-3.2 base, including
a standalone versione of the raid-6 check.

This is basically a re-working (and hopefully improvement)
of the already implemented check in "restripe.c".

I splitted the check function into "collect" and "stats",
so that the second one could be easily replaced.
The API is also simplified.

The command line option are reduced, since we only level
is raid-6, but the ":offset" option is included.

The output reports the block/stripe rotation, P/Q errors
and the possible HDD (or unknown).

BTW, the patch applies also to the already patched "restripe.c",
including the last ":offset" patch (which is not yet in git).

Other item is that due to "sysfs.c" linking (see below) the
"Makefile" needed some changes, I hope this is not a problem.

Next steps (TODO list you like) would be:

1) Add the "sysfs.c" code in order to retrieve the HDDs info
from the MD device. It is already linked, together with the
whole (mdadm) universe, since it seems it cannot leave alone.
I'll need some advice or hint on how to do use it. I checked
"sysfs.c", but before I dig deep into it maybe better to
have some advice (maybe just one function call will do it).

2) Add the suspend lo/hi control. Fellow John Robinson was
suggesting to look into "Grow.c", which I did, but I guess
the same story as 1) is valid: better to have some hint on
where to look before wasting time.

3) Add a repair option (future). This should have different
levels, like "all", "disk", "stripe". That is, fix everything
(more or less like "repair"), fix only if a disk is clearly
having problems, fix each stripe which has clearly a problem
(but maybe different stripes may belong to different HDDs).

So, for the point 1) and 2) would be nice to have some more
detail on where to look what. Point 3) we will discuss later.

Thanks, please consider for inclusion,

bye,

pg

Signed-off-by: NeilBrown <neilb@suse.de>
2011-03-21 13:52:44 +11:00
Przemyslaw Czarnowski 403410eb97 extension of IncrementalRemove to store location (path-id) of removed device
If the disk is taken out from its port this port information is
lost. Only udev rule can provide us with this information, and then we
have to store it somehow. This patch adds writing 'cookie' file in
/dev/.mdadm/failed-slots directory in form of file named with value of
f<path-id> containing the metadata type and uuid of the array (or
container) that the device was a member of.  The uuid is in exactly
the same format as in the mapfile.

FAILED_SLOTS_DIR constant has been added to hold the location of
cookie files.

Signed-off-by: Przemyslaw Czarnowski <przemyslaw.hawrylewicz.czarnowski@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
2010-11-22 20:58:06 +11:00
NeilBrown 0592faeb5e Add gpt pseudo-metadata
This allows mdadm to work with gpt metadata to a limited extent.

Signed-off-by: NeilBrown <neilb@suse.de>
2010-09-06 11:26:28 +10:00
NeilBrown 0f22b998fb Add mbr pseudo metadata handler.
To support incorpating a new bare device into a collection of arrays -
one partition each - mdadm needs a modest understanding of partition
tables.
The main needs to be able to recognise a partition table on one device
and copy it onto another.

This will be done using pseudo metadata types 'mbr' and 'gpt'.

Signed-off-by: NeilBrown <neilb@suse.de>
2010-09-06 11:26:28 +10:00
NeilBrown 5527fc7462 Add policy framework.
Policy can be stated as lines in mdadm.conf like:

POLICY  type=disk path=pci-0000:00:1f.2-* action=ignore domain=onboard

This defines two distinct policies which apply to any disk (but not
partition) device reached through the pci device 0000:00:1f.2.
The policies are "action=ignore" which means certain actions will
ignore the device, and "domain=onboard" which means all such devices
as treated as being united under the name 'onboard'.

This patch just adds data structures and code to read and
manipulate them.  Future patches will actually use them.

Signed-off-by: NeilBrown <neilb@suse.de>
2010-09-06 11:03:43 +10:00
NeilBrown 8efb9d16ac Fix compile error on non-x86 systems.
-z is not an option for 'gcc', it is an option for the loader!!

Reported-by: Debian build system
Signed-off-by: NeilBrown <neilb@suse.de>
2010-09-03 13:33:29 +10:00
NeilBrown 5d40884d6b Don't link mdadm with pthreads
Only mdmon needs pthreads, so link accordingly.

Signed-off-by: NeilBrown <neilb@suse.de>
Reported-by: martin f krafft <madduck@madduck.net>
2010-08-06 20:11:43 +10:00
NeilBrown 850a31783a Release mdadm-3.1.3
Signed-off-by: NeilBrown <neilb@suse.de>
2010-08-06 16:55:23 +10:00
NeilBrown f21e18ca89 Compile with -Wextra by default
This produced lots of warning, some of which pointed to actual bugs.

Signed-off-by: NeilBrown <neilb@suse.de>
2010-08-05 13:13:02 +10:00
NeilBrown 7f5de63d51 Switch from /lib/init/rw to /dev for early-boot files.
It turns out that /lib/init/rw doesn't exist in early boot
like I thought.  So give up on that idea and just use
/dev/.mdadm/ for files that must persist from early-boot
to regular boot.

Signed-off-by: NeilBrown <neilb@suse.de>
2010-07-28 17:41:35 +10:00
Doug Ledford 753cf90512 Fix all the confusion over directories once and for all.
We now have 3 directory definitions: mdmon directory for its pid and
sock files (compile time define, not changable at run time), mdmonitor
directory which is for the mdadm monitor mode pid file (can only be
passed in via command line at the time mdadm is invoked in monitor mode),
and the directory for the mdadm incremental assembly map file (compile
time define, not changable at run time).  Only the mdadm map file still
hunts multiple locations, and the number of locations has been reduced
to /var/run and the compile time specified location.  Re-use of similar
sounding defines that actually didn't denote their actual usage at
compile time made it more difficult for a person to know what affect
changing the compile time defines would have on the resulting programs.

This patch renames the various defines to clearly identify which item
the define affects.  It also reduces the number of various directories
which will be searched for these files as this has lead to confusion
in mdadm and mdmon in terms of which files should take precedence when
files exist in multiple locations, etc.  It's best if the person
compiling the program intentionally and with planning selects the
right directories to be used for the various purposes.  Which directory
is right depends on which items you are talking about and what boot
loader your system uses and what initramfs generation program your
system uses.  Because of the inter-dependency of all these items it
would typically be up to the distribution that mdadm is being integrated
into to select the correct values for these defines.

Signed-off-by: Doug Ledford <dledford@redhat.com>
2010-07-22 10:16:30 -04:00
Dan Williams f4190c2f12 mdmon: satisfy glibc tls abi requirements with pthreads
Setting up a proper tls descriptor is required to conform to the abi
[1].  Until it can be implemented in mdmon use pthreads instead of
clone(2) to let glibc handle the details.  The old behaviour can be had
by un-defining USE_PTHREADS.

Note, the "O2" builds need LDFLAGS now to pick up the '-pthread' option.

[1]: http://people.redhat.com/drepper/tls.pdf

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
2010-07-06 12:48:56 -07:00
Dan Williams 23eb475a96 mdmon: prevent allocations due to late binding
Current versions of glibc do not provide a useable interface to clone(2) as it
inflicts hidden dependencies on setting up a glibc specific tls
descriptor.  The dynamic linker trips this dependency and causes mdmon
to intermittently fail to load.  Resolving all dynamic linking prior to
starting the monitor thread appears to mitigate the issue but there is no
guarantee that another tls dependency will bite us later.

However, while the debate continues with the glibc maintainers it seems
prudent to keep this change.  It ensures that we do not get into a
situation where the monitor thread needs to make a late allocation to
resolve a symbol.

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
2010-07-01 17:28:14 -07:00
martin f. krafft 26f467a954 Compile-time switch to enable 0.9 metadata as default
This commit introduces DEFAULT_OLD_METADATA as a preprocessor
definition. If defined, it causes mdadm to assume metadata version 0.9
as default. If not defined, version 1.x (currently 1.2) is used as
default.

The man page mdadm.8 is also modified to reflect the chosen default.

The selftests will not work if the old default is chosen.

This patch was requested by Debian so they could distribute a current
mdadm together with boot loaders that only understand 0.90 metadata
for md-raid.

Preferred usage is simply
   make DEFAULT_OLD_METADATA=yes


Signed-off-by: martin f. krafft <madduck@debian.org>
Signed-off-by: NeilBrown <neilb@suse.de>
2010-05-31 12:52:37 +10:00
Dan Williams c824e91898 Fixup default definitions of VAR_RUN and ALT_RUN
I suspect commit c132678b wanted VAR_RUN and ALT_RUN to be suffixed by
'/mdadm' to match the defaults in mdadm.h.

Cc: Luca Berra <bluca@comedia.it>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
2010-04-15 15:29:49 +10:00
Doug Ledford e259df4e63 mapfile: if we putting the mapfile in a custom location via ALT_RUN, allow
a custom filename too.

Signed-off-by: Doug Ledford <dledford@redhat.com>
2010-03-24 09:37:34 +11:00
NeilBrown a31c140f13 Release mdadm-3.1.2 2010-03-10 15:58:46 +11:00
Luca Berra c132678b18 allow redefinition of VAR_RUN
having mdmon socket under var is painful at shutdown time

Signed-off-by: Luca Berra <bluca@comedia.it>
Signed-off-by: NeilBrown <neilb@suse.de>
2010-03-03 12:23:30 +11:00
NeilBrown fcf5762500 Add _FORTIFY_SOURCE to mdadm.O2 build.
When building mdadm.O2, set _FORTIFY_SOURCE to get more
warnings, and also build mdmon.O2 to find warnings in that
code too.
Then fix the warnings.

Suggested-by: Luca Berra <bluca@comedia.it>
Signed-off-by: NeilBrown <neilb@suse.de>
2010-03-03 10:54:17 +11:00
NeilBrown 5d4d1b26d3 mdmon: allow pid to be stored in different directory.
/var/run probably doesn't persist from early boot.
So if necessary, store in in /lib/init/rw or somewhere else
that does persist.

Signed-off-by: NeilBrown <neilb@suse.de>
2010-02-04 16:47:28 +11:00
NeilBrown 38a07ed61e Move WaitClean from Monitor.c to sysfs.c
That way mdmon doesn't need to include Monitor.o

Signed-off-by: NeilBrown <neilb@suse.de>
2009-06-02 15:27:16 +10:00
NeilBrown e0fe762a63 mdadm.8: Man page updates
General review and update of mdadm.8
2009-06-02 14:06:05 +10:00
NeilBrown 8320878543 Merge branch 'master' into devel-3.0
Conflicts:
	Build.c
	mdadm.c
	mdadm.h
	super1.c
2009-05-11 16:05:41 +10:00
NeilBrown 667e66d329 Makefile: use $(CC) more consistently.
Explicitly calling 'gcc' in some rules makes it hard to test with
other compilers.
2009-04-29 11:21:08 +10:00
NeilBrown 55e5475945 Makefile: build 'mdmon' for 'test'
Else
  make test
might not prepare everything for running tests.
2009-04-01 13:49:34 +11:00
NeilBrown 8844e29149 Merge branch 'master' in devel-3.0 2009-03-10 16:47:02 +11:00
NeilBrown 388953d27c Release mdadm-2.6.9 2009-03-10 16:38:37 +11:00
NeilBrown 6c40598f59 Merge branch 'master' into devel-3.0 2009-02-02 11:09:09 +11:00
Bernhard Reutner-Fischer 2df1f26911 mdadm fix compilation for uClibc
2008-12-08  Bernhard Reutner-Fischer  <rep.dot.nop@gmail.com>

	* Makefile (dadm.uclibc): Remove misspelled and unneeded rule.
	* md5.h: Include stdint.h for uClibc.
	* mdadm.h: uClibc defines __UCLIBC__. If uClibc has LFS off
	then use lseek instead of lseek64.

Signed-off-by:  Bernhard Reutner-Fischer  <rep.dot.nop@gmail.com>
2009-02-02 09:53:51 +11:00
Dan Williams 88c32bb1ec imsm: validate arrays being created against firmware capabilities
These checks are only enabled when platform support for imsm is found,
i.e. ahci driver is loaded and talking to an Intel(R) controller, and
the option rom header is located.

They can be turned off by setting the environment variable
IMSM_NO_PLATFORM to 1.

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
2008-12-08 16:59:18 -07:00
NeilBrown 25956fef10 Makefile: install udev file into $DESTDIR
Forgot the $DESTDIR in the install target :-(

Signed-off-by: NeilBrown <neilb@suse.de>
2008-11-07 14:46:50 +11:00
Dan Williams f64165f757 config: add 'containers' as a DEVICE keyword
Add anything that looks like a container in /proc/mdstat to the devlist

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
2008-11-04 20:50:39 +11:00
NeilBrown 757a5d74ff Add udev rules file for mdadm.
This is based on the rules from openSUSE 11.1-rc3.
2008-11-04 20:50:39 +11:00