Commit Graph

1328 Commits

Author SHA1 Message Date
Luca Berra cf55630357 fix mdmon takeover
- when we waited for the old mdmon to exit, we didn't look
  for the socket in the right place

- when we failed to find a pid file, we returned the wrong
  value (code expected <0, but got ==0).

Signed-off-by: Luca Berra <bluca@comedia.it>
Signed-off-by: NeilBrown <neilb@suse.de>
2010-03-03 11:35:26 +11:00
Luca Berra eb49460b74 fix mdmon option parsing
running mdmon --takeover --all resulted in a segfault.

Also allow "--all" to be longer so that e.g. md_d127 can
successfully over-write it in the argument list visible
to 'ps'.

Signed-off-by: Luca Berra <bluca@comedia.it>
Signed-off-by: NeilBrown <neilb@suse.de>
2010-03-03 11:06:08 +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 53f5035339 Fix warning about unused variable.
Warning only appears with -O2, but is invalid.

Signed-off-by: NeilBrown <neilb@suse.de>
2010-03-03 10:29:24 +11:00
NeilBrown bde713f015 fix gcc warnings about strict-aliasing rules
Original-by: Luca Berra <bluca@comedia.it>
Signed-off-by: NeilBrown <neilb@suse.de>
2010-03-03 10:17:41 +11:00
NeilBrown 24af7a8744 Assemble: clean up properly if we cannot add the bitmap file.
If we find we cannot add the requested bitmap file when
assembling the array, then make sure to clean up properly
and don't leave a half-configured array.

Signed-off-by: NeilBrown <neilb@suse.de>
2010-02-24 12:17:17 +11:00
NeilBrown ad90adb689 Create: change default metadata type to 1.2
Change default - again, sorry.

v1.1 causes problems as the conflicts with a boot sector, whether on
the whole device or in a partition.  I guess the rule is they you
aren't allowed to use the first sector in general.

v1.2 is mostly just as good and avoid boot-sector problems so default
to that instead.

Signed-off-by: NeilBrown <neilb@suse.de>
2010-02-24 12:03:27 +11:00
NeilBrown 097075b611 Grow: be more relaxed about timestamp mismatches on backup file.
As backup file has a timestamp which is updated quite separately
from the metadata timestamp.  They should be largely in-sync but
sometimes are not.
So be more generous in the check, and allow it to be over-ridden
by an environment variable.

Signed-off-by: NeilBrown <neilb@suse.de>
2010-02-24 11:59:11 +11:00
NeilBrown 4c1c3ad8cf Assemble: check inargv before complaining about stray arguments.
If --assemble is given a container and some other devices to assemble
an array from, it complains with an error because that doesn't make
sense.
However it currently also complains if the list of devices was extract
from the config file rather than being given on the command line.
That is not appropriate.

So add an '&& inargv' test to ensure that we are really complaining
about the right thing.

Signed-off-by: NeilBrown <neilb@suse.de>
Acked-by: Dan Williams <dan.j.williams@intel.com>
2010-02-24 11:43:59 +11:00
NeilBrown a31128d2de super1: put bitmap on a 4K boundary when possible.
Some devices have 4K sector sizes.  So try to align the bitmap
on a 4K boundary.
This isn't possible when hot-adding a bitmap, but will be once
we add support for configuring the bitmap via sysfs.

Signed-off-by: NeilBrown <neilb@suse.de>
2010-02-24 11:31:48 +11:00
NeilBrown b179246f4f Assemble: Handle assembling from config file which is out of order.
Currently "mdadm -As" will process the entries in the config
file in order.  If any array is a component or member of a preceding
array, that array will not be assembled.

So if there are any failures during assembly, retry those arrays,
and look until everything is assembled, or nothing more can
be assembled.

Signed-off-by: NeilBrown <neilb@suse.de>
2010-02-24 11:16:56 +11:00
NeilBrown cd9a8b5cb4 mdmon: Document startup/shutdown requirements in man page.
Signed-off-by: NeilBrown <neilb@suse.de>
2010-02-08 17:26:18 +11:00
NeilBrown 319767b85c mapfile: use ALT_RUN as alternate place to store mapfile
This gives better consistency and fewer hidden '.' files.

Signed-off-by: NeilBrown <neilb@suse.de>
2010-02-08 17:26:18 +11:00
NeilBrown fa716c83c5 mdmon: insist on creating .pid file at startup.
Now that we don't "mdadm --takeover" until /var/run is writable
there is no need to continually try to create files in there.

So only create these files at startup and fail if they cannot be
made.  This means that to start an array with externally managed
metadata, either /var/run or ALT_RUN (e.g. /lib/init/rw) must be
writable.  To 'takeover' from a previous mdmon instance, /var/run
must be writable.

This means we don't need to worry about SIGHUP (which was once used to
tell us it was time to create .pid) and SIGALRM.

Signed-off-by: NeilBrown <neilb@suse.de>
2010-02-08 17:26:18 +11:00
NeilBrown 58a4ba2a6b mdmon: don't monitor /proc/mounts to decide when to create .pid file.
Monitoring /proc/mounts and creating a .pid file as soon as /var/run
is writable is racy.  Most distros clean all non-directories from
/var/run early in boot and if mdmon races with this it could
lose the files as soon as they are created.

Instead require that "mdmon --takeover" be run after /var is writable.

Signed-off-by: NeilBrown <neilb@suse.de>
2010-02-08 17:26:18 +11:00
NeilBrown b5c727dc1a mdmon: remove switch-root functionality.
Using switch-root and then creating files in /var/run once
that location is writable is racing as most distro clean out
/var/run shortly after it is mounted.
This can cause the .pid and .sock files to be deleted shortly
after they are created.

This option doesn't seem to be used at all any, and the alternative
of communicating the pid etc in some preserved directory and then
restarting mdmon once all is settled seems simpler.

So remove the code for supporting switchroot and update man page
accordingly.

Signed-off-by: NeilBrown <neilb@suse.de>
2010-02-08 14:08:13 +11:00
NeilBrown a9596b79a3 mdmon: recognise --all in place of /proc/mdstat
It seems more meaningful.
Keep the old option as well for back compatibility.

Signed-off-by: NeilBrown <neilb@suse.de>
2010-02-04 17:34:06 +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 24f6f99b36 Having single function to read mdmon pid file.
We don't need three.
One (signal_mdmon) wasn't even being used.

Signed-off-by: NeilBrown <neilb@suse.de>
2010-02-04 16:47:21 +11:00
NeilBrown 24cfdbc5c0 mdmon: discard test_pidfile()
devname2mdmon() can be used just as easily and doing so saves us from
some duplicate code.
Also tidy up some related logic.

Signed-off-by: NeilBrown <neilb@suse.de>
2010-02-04 16:37:21 +11:00
NeilBrown 688a1e5b07 mdmon: don't mkdir /var/run
Creating /var/run in mdmon is really not justifiable.

If /var/run doesn't exist, then it is either deliberate and it should
be left that way to make sure the mapfile gets created in /dev, or
it is a configuration error and not our problem to fix.

Signed-off-by: NeilBrown <neilb@suse.de>
2010-02-04 16:37:20 +11:00
NeilBrown e98ef22509 mdmon: improve switchroot handling.
The change to get mdmon to re-exec itself from the switchroot
filesystem broken switchroot in various ways.  This fixes it.

If the switchroot path is not '/', mdmon will find the pid and
socket for the monitor, chroot to the new root, and exec mdmon
passing the pid in argv[2] and the socket in stdin.

If the switchroot path is actually a number, mdmon will not chroot,
but will kill that pid before taking over the array.

Signed-off-by: NeilBrown <neilb@suse.de>
2010-02-04 12:04:18 +11:00
NeilBrown af7ca33487 mdmon: simplify try_kill_monitor
After we SIGTERM the monitor we need to wait for it to finish up.
Rather than the complexity of waiting for every md array to be clean,
we can simply read from the sock connected to the monitor.
When the monitor dies, we will get EOF.  Before then we will block.

Signed-off-by: NeilBrown <neilb@suse.de>
2010-02-04 12:04:16 +11:00
NeilBrown 3e7312a96c mdmon: remove scan variable from mdmon()
It is redundant as each place that it is used, it can only
have one possible value.
Also change the related arg to mdmon() to have a more meaningful
name.
And make mdmon() static.

Signed-off-by: NeilBrown <neilb@suse.de>
2010-02-04 12:04:15 +11:00
NeilBrown 921d9e164f Assemble: fix --force assembly of v1.x arrays which are recovering.
1.x metadata allows a device to be a member of the array while it
is still recoverying.  So it is a working member, but is not
completely in-sync.

mdadm/assemble does not understand this distinction and assumes that a
work member is fully in-sync for the purpose of determining if there
are enough in-sync devices for the array to be functional.

So collect the 'recovery_start' value from the metadata and use it in
assemble when determining how useful a given device is.

Reported-by: Mikael Abrahamsson <swmike@swm.pp.se>
Signed-off-by: NeilBrown <neilb@suse.de>
2010-02-04 12:02:09 +11:00
NeilBrown cc86f89c85 Create: Improve warning message about booting from v1.x
Suggesting that if your boot loaded doesn't support v1.x, then use
  --metadata=1.0
doesn't make a lot of sense.
Also, '/', isn't really important, it is /boot that matters.
Hopefully people who have /boot on '/' realise that /boot is
on '/' ....

Signed-off-by: NeilBrown <neilb@suse.de>
2010-02-01 10:37:58 +11:00
NeilBrown ac5678dd9b Add test for "are we running as root".
Most operations require root access.  Rather than ensure we generate
the right error message when something fails because we aren't root,
check early.
Note that "--examine" does not necessarily require root, so test
for that first.

Resolves-Debian-bug: 396570
Signed-off-by: NeilBrown <neilb@suse.de>
2010-02-01 10:22:38 +11:00
Luca Berra cf1be220e2 super-intel.c: use %zu specifier for printf of size_t
Fix compile warning when size_t is not a long.

Acked-by: Dan Williams <dan.j.williams@intel.com>
Signed-off-by: Luca Berra <bluca@vodka.it>
Signed-off-by: NeilBrown <neilb@suse.de>
2010-02-01 09:15:35 +11:00
Luca Berra c3e1a50fcb mdadm-3.1.1 segfaults when mdadm -G -Z is used.
Signed-off-by: Luca Berra <bluca@vodka.it>
Signed-off-by: NeilBrown <neilb@suse.de>
2010-02-01 09:12:31 +11:00
Artur Wojcik 4c619b292f Kill: fix when zeroing busy devices.
mdadm should not wait indefinitely when it trys to reset
superblock on device which is busy (cannot be opened).

Acked-by: Andre Noll <maan@systemlinux.org>
Signed-off-by: Artur Wojcik <artur.wojcik@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
2010-01-29 20:53:24 +11:00
NeilBrown fc7e81e54e mapfile: fix locking.
The current locking uses lockf, and is completely broken.
When you hold a lockf lock, any close of any fd on that file will
release the lock.  So map_read() call which is made as soon as we get
the lock, will immediately drop the lock.

So change to flock locking which isn't so badly designed.

Signed-off-by: NeilBrown <neilb@suse.de>
2010-01-29 16:20:08 +11:00
NeilBrown d998adc316 Detail: Report state of FAILED when an array has too few devices to work.
We already have a call to 'enough' in Detail which is the check for
"do we have enough devices".  We just need to calculate the required
data a bit earlier, then use the same 'enough' call to possibly
print FAILED.

This is motivated by Debian bug 495755.
The other request in that bug is not practical.  

    It would be very nice if output of `mdadm' is more clear in case of a
    broken array.
    
    Currently the only hint you get from `mdadm' that your array is broken
    is this:
    
    # mdadm -A /dev/md0 /dev/sdc1 /dev/sdd1 /dev/sde1 /dev/sdf1
    mdadm: /dev/md0 assembled from 1 drive and 3 spares - not enough to start the
    array.
    
    It could say something like `Your array is broken, you can't use it anymore'

It is not valid to report that array as 'broken' if the user hasn't
listed all the devices, which could be the case here.


Resolves-Debian-Bug: 495755
Signed-off-by: NeilBrown <neilb@suse.de>
2010-01-29 15:46:23 +11:00
NeilBrown a1331cc406 Tidy up some argument parsing, particularly for -b
-b only means --brief in MISC mode, elsewhere it is --bitmap.

Resolves-debian-bug: 427777
Signed-off-by: NeilBrown <neilb@suse.de>
2010-01-29 15:46:17 +11:00
NeilBrown c93e9d68d0 md.4: various improvements to new section on scrubbing.
Signed-off-by: NeilBrown <neilb@suse.de>
2010-01-29 10:21:56 +11:00
NeilBrown 417a4b046d mdmon: fix fd leak and possible buffer overrun.
We normally wouldn't close 'fd', and as 'buf' might not have
had a nul, strstr could have overrun it.

Signed-off-by: NeilBrown <neilb@suse.de>
2010-01-29 10:15:15 +11:00
NeilBrown 0c8675cbed Correctly parse -N command line option.
'N' wasn't listed in the sort options, so you
had to use --name :-)

Resolved-Debian-Bug: 564004
Signed-off-by: NeilBrown <neilb@suse.de>
2010-01-28 16:55:28 +11:00
NeilBrown 1cc44574b2 md.4: add section on scrubbing and mismatch counts.
This relates to debian bug 405919

Signed-off-by: NeilBrown <neilb@suse.de>
2010-01-28 13:09:58 +11:00
NeilBrown 39bbb39202 Grow: If bitmap interferes with grow, report this.
If a bitmap exists on an array, then current kernels cannot grow
that array.
So when we try to grow an array, test for EBUSY and if a bitmap is
present, report that the bitmap needs to be removed.

Resolves-Debian-Bug: 534571
Signed-off-by: NeilBrown <neilb@suse.de>
2010-01-28 11:48:03 +11:00
NeilBrown 9f22b13fe1 Assemble: error-check ->load_super
Once load_super has succeeded, it should continue to succeed.  However
devices can disappear etc so it is prudent to always check the return
status of load_super.

Signed-off-by: NeilBrown <neilb@suse.de>
2010-01-28 09:02:21 +11:00
NeilBrown 080fd00521 Remove stray debugging printfs
These were never supposed to be released, and due
to a type issue they cause compile problems on
some architectures.

Resolves-Debian-Bug: 567167
Signed-off-by: NeilBrown <neilb@suse.de>
2010-01-28 08:55:18 +11:00
Doug Ledford 4d0b563b5b Fix segfault when the AUTO keyword is used in the config file
Signed-off-by: Doug Ledford <dledford@redhat.com>
Signed-off-by: NeilBrown <neilb@suse.de>
2010-01-19 10:50:26 +13:00
Doug Ledford 6e48d593c1 Don't use %02d as a metadata format specifier for metadata numbers.
It confuses us when we read the output back later

Signed-off-by: Doug Ledford <dledford@redhat.com>
Signed-off-by: NeilBrown <neilb@suse.de>
2010-01-19 10:45:28 +13:00
Doug Ledford 9ef5dbff4a Make the IMSM_DEVNAME_AS_SERIAL option work when creating containers.
This allows a person to testing using loopback devices that don't
support serial number queries.

Signed-off-by: Doug Ledford <dledford@redhat.com>
Signed-off-by: NeilBrown <neilb@suse.de>
2010-01-19 10:39:39 +13:00
Michael Evan 6acad4811b Document validity of --assume-clean when all devices are zeroed.
>>
>> When I assemble an array I tend to have checked the devices before
>> hand; it would not be difficult to make the final pass a zeroing pass
>> if I knew I could vastly speed up post-assembly performance.  As I
>> stated, it's merely a lack of clarity in the documentation.
>
> If you would like to create a patch against the man page, I would be happy to
> accept it.
>
> NeilBrown


Signed-off-by: NeilBrown <neilb@suse.de>
2009-12-30 13:51:11 +11:00
NeilBrown 8409bc51e8 Merge branch 'klockwork' of git://github.com/djbw/mdadm
Conflicts:
	super-intel.c
2009-12-30 13:46:52 +11:00
NeilBrown c1e3ab8c1e Merge branch 'master' of git://github.com/djbw/mdadm 2009-12-30 13:42:37 +11:00
NeilBrown 076515ba50 DDF: fix incorrect header magic number.
I was using the wrong magic number when creating an array.

Signed-off-by: NeilBrown <neilb@suse.de>
2009-12-30 13:42:27 +11:00
Dan Williams 1e5c69836d imsm: add support for checkpointing via 'curr_migr_unit'
Unlike native md checkpointing some data about the geometry and type of
the migration process is coded into curr_migr_unit.  Provide logic to
convert between md/{resync_start|recovery_start} and imsm/curr_migr_unit.

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
2009-12-21 17:54:32 -07:00
Dan Williams 2904b26f05 Support external metadata recovery-resume
Minimal changes needed to permit reassembling partially recovered
external metadata arrays.  The biggest logical change is that
->container_content() can now surface partially rebuilt members rather
than omitting them from the disk list.

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
2009-12-21 12:51:57 -07:00
Dan Williams d23534e464 Teach sysfs_add_disk() callers to use ->recovery_start versus 'insync' parameter
Also fixup 'in_sync' versus 'insync' typo.

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
2009-12-21 11:26:21 -07:00