Commit Graph

1337 Commits

Author SHA1 Message Date
NeilBrown 972ee7253a Release mdadm-3.1.4
bugfix/stability.

Signed-off-by: NeilBrown <neilb@suse.de>
2010-08-31 17:21:13 +10:00
NeilBrown 93601c439c Fix spare migration.
Spare migration uses major:minor device names.
When we added support for kernel style names, we broke that.

Signed-off-by: NeilBrown <neilb@suse.de>
2010-08-31 17:21:11 +10:00
NeilBrown b1702f4826 Don't remove md devices with standard names.
If udev is not in use, we create device in /dev when assembling
arrays and remove them when stopping the array.

However it may not always be correct to remove the device.  If
the array was started with kernel auto-detect, them mdadm didn't
create anything and so shouldn't remove anything.

We don't record whether we created things, so just don't remove
anything with a 'standard' name.  Only remove symlinks to the
standard name as we almost certainly created those.

Reported-by: Petre Rodan <petre.rodan@avira.com>
Signed-off-by: NeilBrown <neilb@suse.de>
2010-08-31 15:21:40 +10:00
NeilBrown 6df6a774bf Allow dev_open to work on read-only /dev
/dev could be read-only in which case we cannot make devices
there.
So dev_open should first try to use an existing device name,
and if that doesn't work try creating a node in /dev or /tmp.

Reported-by:  Paweł Sikora <pluto@agmk.net>
Signed-off-by: NeilBrown <neilb@suse.de>
2010-08-30 08:48:48 +10:00
NeilBrown ef83fe7cba Allow --incremental to add spares to an array.
Commit 3a6ec29ad5 stopped us from adding apparently-working devices
to an active array with --incremental as there is a good chance that they
are actually old/failed devices.

Unfortunately it also stopped spares from being added to an active
array, which is wrong.  This patch refines the test to be more
careful.

Reported-by: <fibreraid@gmail.com>
Analysed-by: Dan Williams <dan.j.williams@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
2010-08-12 11:41:41 +10:00
Dan Williams 172356c93a Incremental: accept '--no-degraded' as a deprecated option
Commit 3288b419 (Revert "Incremental: honor --no-degraded to delay assembly")
killed the --no-degraded flag since commit 97b4d0e9 (Incremental: honor
an 'enough' flag from external handlers) made this the default behavior
of -I, and brought -I usage for external/container formats in line with
native metadata.  However, this breaks existing usages of '-I
--no-degraded', so allow it as a deprecated option.

Starting a degraded container, like the native metadata case, requires -R.

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
Reported-by: Ignacy Kasperowicz <ignacy.kasperowicz@intel.com>
2010-08-12 11:20:16 +10:00
Dan Williams fd4c9ba491 Incremental: return success in 'container not enough' case
Commit 97b4d0e9 "Incremental: honor an 'enough' flag from external
handlers" introduced a regression in that it changed the error return
code for successful invocations.

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
Reported-by: Ignacy Kasperowicz <ignacy.kasperowicz@intel.com>
2010-08-10 08:44:45 -07: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 cdbe98cd54 Fix compiler warning concering bad use of snprintf.
Signed-off-by: NeilBrown <neilb@suse.de>
Reported-by: Mikael Abrahamsson <swmike@swm.pp.se>
2010-08-06 20:10:48 +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 9e751dc7a0 mapfile: just have one place to store the mapfile
Having multiple possible locations and guessing where best to put the
file is too messy, confusing and makes locking problematic.

So just keep it in /dev/.mdadm/map.  It is a horrible place but it is
really all we have.  System integrators can change this easily at
build time.

Signed-off-by: NeilBrown <neilb@suse.de>
2010-08-06 14:54:10 +10:00
NeilBrown 925211e323 Grow: use raid_disks, not nr_disks
nr_disks is just wrong here - the arrays need room for all disk slots,
even if some are empty, plus spares, plus a possible backup file.
So raid_disks is correct.

Signed-off-by: NeilBrown <neilb@suse.de>
2010-08-06 14:40:53 +10:00
NeilBrown 7204495377 Fix writing of second backup superblock during grow
There 'rv' tests were confused and sometimes wrong.
This resulted in not writing the second bsb.

Also fix the test script so the the critical section is long enough
that we have some hope of interrupting it.

Signed-off-by: NeilBrown <neilb@suse.de>
2010-08-05 21:39:17 +10:00
NeilBrown 8d848be1ed udevadm settle in autodetect test
some udev activity was interfering with the partitioning.

Signed-off-by: NeilBrown <neilb@suse.de>
2010-08-05 16:50:03 +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 9aaada0530 Detail: clean up handing of the 'info' we load from superblock.
The loop for loading it was hard to follow, so restructure that
and avoid a theoretical use-before-set error.

Also there was a second 'info' structure which hid the first and was
pointless.

Signed-off-by: NeilBrown <neilb@suse.de>
2010-08-05 12:10:57 +10:00
NeilBrown c61c4dd01d Fix test for imsm prodigal member scenario
The 'container_enough' changes fliped the default from assembling
an array as soon as we possibly could, to assembling only when all
expected devices are present.
This broken 09imsm-assemble which expects the original default.
So change from "-I" to "-IR" to restore the expected behaviour.

Signed-off-by: NeilBrown <neilb@suse.de>
2010-08-05 11:44:26 +10:00
NeilBrown 69a3f12e6e Fix tests/layouts
some attributes files now return "new (old)", so allow for that when
reading the attr file.

Signed-off-by: NeilBrown <neilb@suse.de>
2010-07-29 14:20:35 +10:00
NeilBrown 5f6ca90a9b Fix restarting of reshaping arrays.
We cannot get stripe_cache_size until after the array have
been activated!!

Signed-off-by: NeilBrown <neilb@suse.de>
2010-07-29 13:50:15 +10:00
NeilBrown 510242aa48 Restore assembling of ddf containers.
The container_enough code change broke ddf as ddf never claimed
'enough' devices.  So change it to always claim 'enough' to
restore previous behaviour.

Signed-off-by: NeilBrown <neilb@suse.de>
2010-07-29 13:26:26 +10:00
NeilBrown b7e734fc22 Fix use of rv in Grow_reshape
1/ and extra local var was declared, which causes rv setting
   to be lost
2/ a -ve rv was left -ve while we should be return 1 on err.

Signed-off-by: NeilBrown <neilb@suse.de>
2010-07-29 13:16:01 +10:00
NeilBrown df65ac70ca Some fixes to the mapfile code.
- Update the comments
- use some defined names instead of magic numbers.
- restore /var/run/mdadm/map to have priority over /dev/.mdadm/map

Signed-off-by: NeilBrown <neilb@suse.de>
2010-07-28 17:41:39 +10:00
NeilBrown 9fdcb47192 Update man page info about files used by mdmon
A recent patch changed the location of files used by
mdmon, so update man page to match.

Signed-off-by: NeilBrown <neilb@suse.de>
2010-07-28 17:41:36 +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
NeilBrown 08415c46a8 Bugfix: mapfile locking is broken/racy
While we attempt to use a lockfile to grant exclusive access to the
mapfile, our implementation is buggy.  Specifically, we create a lockfile,
then lock it, at which point new instances can open the lockfile and
attempt to lock it, which will cause them to block.  However, when we are
ready to unlock it, we unlink the file.  This causes existing lock waiters
to get a lock on an unlinked inode while a different instance may now
create a new lockfile and get an exclusive lock on it.

There are several possible fixes.  The chosen one is to test if
->s_nlink is zero after we get the lock and to retry if it isn't.
This means:
  - failing to unlink a file doesn't leave a stale lock
  - we can block waiting to get a lock rather than busy-waiting
  - we don't need to leave a lock file permanently in place.
    
Reported-by: Doug Ledford <dledford@redhat.com>
Signed-off-by: NeilBrown <neilb@suse.de>
2010-07-28 17:40:54 +10:00
Doug Ledford 93c861ee57 Add warnings if we ever fail to get a lock on the mapfile.
Signed-off-by: Doug Ledford <dledford@redhat.com>
2010-07-22 10:16:31 -04:00
Doug Ledford 0155af90d8 Bugfix: don't issue a read larger than the buffer to hold it
Signed-off-by: Doug Ledford <dledford@redhat.com>
2010-07-22 10:16:31 -04:00
Doug Ledford 2913d9df16 udev rules: add watch option
The watch option to udev tells udev to watch our mdadm device file for
close events and on a close it rechecks the device.  This means that if,
for example, we use mdadm to --grow the array from a 4 disk to 5 disk
array, when mdadm closes the array, udev will re-read the superblock and
update its internal database with the new information.  This can also be
used to cause udev to create new device special files if, for example, a
partitioning program is used to modify the partition table on the actual
md device and that program does not call the syscall to reread the
partition table.

Signed-off-by: Doug Ledford <dledford@redhat.com>
2010-07-22 10:16:31 -04:00
Doug Ledford cfad27a937 Two Minor bug fixes to incremental support
One: a single character typo (of instead of or in an error printout)
Two: Audited usage of tfd file descriptor.  Make sure that the tfd file
is always closed after usage, and that the tfd variable is reset to -1
if we are going to continue in our loop (not necessary if we know we
will return from our function without going through the dv loop again).

Signed-off-by: Doug Ledford <dledford@redhat.com>
2010-07-22 10:16:31 -04: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
NeilBrown 8562409dd1 Merge branch 'master' of git://github.com/djbw/mdadm 2010-07-22 17:43:35 +10:00
NeilBrown c43f7d91cc Don't report Used Dev Size for RAID0.
This number isn't meaningful for RAID0 as a different amount of space
might be used from each device.
It isn't meaningful for linear either, but already was not reported
for linear.
Detail doesn't report it either.
So make --examine not report it.

Signed-off-by: NeilBrown <neilb@suse.de>
Reported-by: Mario 'BitKoenig' Holbe <Mario.Holbe@TU-Ilmenau.DE>
2010-07-22 15:45:18 +10:00
NeilBrown 3e4165619b Cast to long long before left-shifting too much.
When left-shifting we must be sure that the value being
shifted is large enough to not lose bits.
The 'chunkssize' in CreateBitmap is only 'long' so it
can overflow.  So cast to 'long long' first.

Also fix a similar issue in Detail even though it isn't currently
being compiled.

Signed-off-by: NeilBrown <neilb@suse.de>
Reported-by: Tomasz Chmielewski <mangoo@wpkg.org>
2010-07-22 15:35:54 +10:00
Dan Williams 1dccfff910 Incremental: restore assembly for inactive containers, block active
GET_ARRAY_INFO always succeeds on an inactive container, so we need to
be a bit more diligent about adding a disk to an active container.

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
2010-07-19 14:59:25 -07:00
NeilBrown 50526e9090 super-0.90: don't write bitmap larger than 60K
The 4K superblock can be as close as 64K from the end
of the device.  As the bitmap (with header) lives after
the superblock (with 0.90 metadata) there could be as
little as 60K of space.
So limit the bitmaps to 59.5K, and only write 60K including
the header.

The bug fixed here means that bitmaps cannot be created
on devices which are exact multiples of 64K in size

Signed-off-by: NeilBrown <neilb@suse.de>
2010-07-07 21:31:33 +10:00
NeilBrown 3d5279b053 Improve --re-add documentation
and add the fact that --test can now be used with --manage
operations.

Signed-off-by: NeilBrown <neilb@suse.de>
2010-07-07 13:35:07 +10:00
Dan Williams 569cc43ffb imsm: fix a -O2 build warning
super-intel.c: In function ‘imsm_add_spare’:
super-intel.c:4833: error: ‘array_start’ may be used uninitialized in this function
super-intel.c:4834: error: ‘array_end’ may be used uninitialized in this function

This is valid, if we don't find a spare candidate then array_{start,end}
will be uninitialized.

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
2010-07-06 12:48:59 -07: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
Marcin Labun 0ad6835c98 Fix the count of member devices in mdstat_read function.
Correction of the number of container or volume member devices (devcnt
in struct mdstat_ent). The number after the last devices was counted
towards member of devices.

Signed-off-by: Marcin Labun <marcin.labun@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
2010-07-06 18:02:22 +10:00
Przemyslaw Czarnowski aae3cdc35a fix: IncrementalRemove leaves open handle
Signed-off-by: Przemyslaw Czarnowski <przemyslaw.hawrylewicz.czarnowski@intel.com<mailto:przemyslaw.hawrylewicz.czarnowski@intel.com>>
2010-07-06 16:47:02 +10:00
NeilBrown 1538aca5cb Merge branch 'master' of git://github.com/djbw/mdadm 2010-07-06 14:46:47 +10:00
NeilBrown 7d2e6486e3 Add --test option to --re-add and similar
--test can be given in Manage mode.
This can be used when there is an attempt to fail or remove 'faulty',
'failed' or 'detached' devices, or to re-add 'missing' devices.
If no devices were failed, removed, or re-added, then mdadm will
exit with status '2'.

Signed-off-by: NeilBrown <neilb@suse.de>
2010-07-06 12:07:07 +10:00
NeilBrown a4e13010df Add support for "--re-add missing"
If the device name "missing" is given for --re-add, then mdadm will
attempt to find any device which should be a member of the array but
currently isn't and will --re-add it to the array.
This can be useful if a device disappeared due to a cabling problem,
and was then re-connected.
The appropriate sequence would be
  mdadm /dev/mdX --fail detached
  mdadm /dev/mdX --remove detached
  mdadm /dev/mdX --re-add missing

Signed-off-by: NeilBrown <neilb@suse.de>
2010-07-06 12:06:11 +10:00
NeilBrown 3a6ec29ad5 Don't let incremental add devices to active arrays.
Adding devices to active arrays in --incremental is a bit dubious.

Normally the array won't be activated until all expected devices are
present, so this situation would mean that the given device is not
expected, so is probably failed.  In that case it should only be added
by explicit sysadmin request.

However if --run was given, then quite possibly the array was
assembled earlier when not complete, so it is less clear whether it is
wrong to add this device or not.  In that case add it as that is
generally safest.

It would be nice to allow policy for this to be explicitly given by
sysadmin.

Signed-off-by: NeilBrown <neilb@suse.de>
2010-07-06 12:04:40 +10:00
NeilBrown e5c99c0811 Assemble: Fix honouring of 'auto' config line
commit 1ff9833928
broke the checking of metadata types via the 'auto' line.

Be moving 'load_super" before "conf_test_metadata" we left
tst->sb set even if conf_test_metadata fails, so the device will
actually be accepted and used.

So if we decide to reject the device, free the superblock so it is
clear that it is rejected.

Signed-off-by: NeilBrown <neilb@suse.de>
2010-07-06 11:57:09 +10:00
Dan Williams d19e3cfb66 Merge branch 'fixes' into for-neil 2010-07-01 17:36:11 -07:00
Dan Williams 8cfc801c72 Merge branch 'subarray' into for-neil
Conflicts:
	mdadm.h
	super-intel.c
2010-07-01 17:36:05 -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
NeilBrown b3b4e8a7a2 Avoid skipping devices where removing all faulty/detached devices.
When using 0.90 metadata, devices can be renumbered when
earlier devices are removed.
So when iterating all devices looking for 'failed' or 'detached'
devices, we need to re-check the same slot we checked last time
to see if maybe it has a different device now.

Reported-by: Jim Paris <jim@jtan.com>
Resolves-Debian-Bug: 587550
Signed-off-by: NeilBrown <neilb@suse.de>
2010-06-30 17:20:38 +10:00
NeilBrown 7efa6bc34f Update udev rules for hotplug support.
- split the rules for handling components of array to be clearly
  separate from rules for handling the arrays themselves.
- add call to "-If" when removing a device
- uncomment the --incremental call when adding a device.

Signed-off-by: NeilBrown <neilb@suse.de>
2010-06-30 16:55:17 +10:00