Commit Graph

237 Commits

Author SHA1 Message Date
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
NeilBrown 5c64fcb535 Don't attempt a re-add if the device is marked as faulty.
If a device is marked as faulty, then a re-add will cause it to be
added as a faulty drive, which is not what it wanted.
So just refuse to try to re-add a device which is marked 'faulty'.

Signed-off-by: NeilBrown <neilb@suse.de>
2009-12-08 17:26:31 +11:00
NeilBrown 751fd6c093 Don't silently map --re-add to --add
As --add can destroy important data on a disk, and
--re-add is not suppose to, it is wrong to silently
try --add if --re-add fails.
So print a message and abort instead.

Signed-off-by: NeilBrown <neilb@suse.de>
2009-11-17 13:15:34 +11:00
NeilBrown 4a997737a1 Merge branch 'master' into devel-3.1 2009-10-22 11:13:13 +11:00
NeilBrown 0eb26465c0 Free some malloced memory that wasn't being freed.
As mdadm is normally a short-lived program it isn't always necessary
to free memory that was allocated, as the 'exit()' call will
automatically free everything.  But it is more obviously correct if
the 'free' is there.
So this patch add a few calls to 'free'

Signed-off-by: NeilBrown <neilb@suse.de>
2009-10-22 11:00:56 +11:00
NeilBrown ca4f89a3b7 Merge branch 'master' into devel-3.1
Conflicts:
	mdadm.8
2009-10-01 16:58:40 +10:00
NeilBrown d823a6c872 Remove Manage_reconfing in favour of Grow_reshape
Bother Manage_reconfig and Grow_reshape provide for changing
the 'layout' of a faulty array.  This is no necessary.
So discard Manage_reconfig and just use Grow_reshape

Signed-off-by: NeilBrown <neilb@suse.de>
2009-07-14 12:11:31 +10:00
NeilBrown 3b435195fc Merge branch 'master' into devel-3.0
Conflicts:
	super0.c
	super1.c
2009-06-02 15:28:36 +10:00
NeilBrown e736b62389 Update copyright dates and remove references to @cse.unsw.edu.au
Also removed 'paper' addresses.

Signed-off-by: NeilBrown <neilb@suse.de>
2009-06-02 14:35:45 +10:00
NeilBrown c7b474474c Monitor: support spare-group manipulation for 1.x metadata.
The code for moving spares around a spare-group currently
only works for 0.90 metadata.  Generalise it for 1.x metadata
as well.

Reported-by: "Garth Snyder" <garth@grsweb.us>
Signed-off-by NeilBrown <neilb@suse.de>
2009-05-12 09:49:45 +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 c9f39c1b9b re-add error check 2009-05-05 21:13:29 +10:00
NeilBrown 462906cdee incremental_container: preserve 'in_sync' flag when adding to existing array.
When building container members with -IR, we need to ensure that
devices added to an active array preserve the 'in_sync' status so they
don't needlessly get rebuilt.

So allow sysfs_add_disk to do this (only works in kernels since
2.6.30) and pass the relevant flag down.

Signed-off-by: NeilBrown <neilb@suse.de>
2009-04-14 10:19:02 +10:00
Dan Williams 85f9b5f798 Manage: permit '--remove detached' for containers
Skip the unique holder check in the detached case... pretty sure no one is
holding on to it if open() returns ENXIO.

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
2009-02-24 18:45:57 -07:00
NeilBrown 208933a7a8 Tidy error messages for add_to_super failure.
Make sure every failure from add_to_super prints a suitable
error message, and then don't print any error in the caller.

Signed-off-by: NeilBrown <neilb@suse.de>
2008-11-27 15:39:59 +11:00
Dan Williams f20c396836 allow add_to_super to return errors
Prepare add_to_super to validate disks against the platform capabilities

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
2008-11-27 15:30:39 +11:00
Dan Williams ef70b9f4ef fix remove_devices()
Don't write to 'pe' if 'path' was not specified

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
2008-11-08 16:03:07 -07:00
NeilBrown d49410d3ab Stop: drop any partitions that may be associated with an array when stopping it.
Not all kernels automatically discard partitions when the
array is stopped,  so call the RRPART ioctl to force it.

Signed-off-by: NeilBrown <neilb@suse.de>
2008-11-04 21:56:42 +11:00
NeilBrown 4ccad7b163 Manage: when stopping an array, delete all names from /dev.
This only applies if udev isn't installed or is disabled
by MDADM_NO_UDEV
We try to remove partitions too.
We find names to remove by looking in /var/run/mdadm/map

Signed-off-by: NeilBrown <neilb@suse.de>
2008-11-04 20:50:39 +11:00
NeilBrown 9759037678 Generate 'change' uevents when arrays change in non-obvious ways.
When a 'container' gets started, we need udev to notice, but the
kernel has no way of knowing that a KOBJ_CHANGE event is needed.  So
send one directly via the 'uevent' sysfs attribute.

Also, uevents don't get generated when md arrays are stopped (prior to
2.6.28) so send 'change' events then too.

Signed-off-by: NeilBrown <neilb@suse.de>
2008-11-04 20:50:39 +11:00
NeilBrown b01b06bda8 Merge branch 'master' into devel-3.0
Conflicts:

	Create.c
	Manage.c
2008-10-27 10:10:08 +11:00
NeilBrown b3d3195538 Allow WRITEMOSTLY to be cleared on --readd using --readwrite.
Previously it was possible to set the WRITEMOSTLY flag when
adding a device to an array, but not to clear the flag when re-adding.
This is now possible with --readwrite.

Signed-off-by: NeilBrown <neilb@suse.de>
2008-10-25 18:20:49 +11:00
NeilBrown 492350045c Merge branch 'master' into devel-3.0
Conflicts:

	Manage.c
2008-10-17 12:46:23 +11:00
NeilBrown 2a528478c7 Manage: allow adding device that is just large enough to v1.x array.
When adding a device to an array, we check that it is large enough.

Currently the check makes sure there is also room for a reasonably
sized bitmap.  But if the array doesn't have a bitmap, then this test
might be too restrictive.
So when adding, only insist there is enough space for the current
bitmap.
When Creating, still require room for the standard sized bitmap.

This resolved Debian Bug 500309
2008-10-13 16:15:16 +11:00
NeilBrown 0e60042683 Compile fixes, particularly moving more stuff under MDASSEMBLE
Now 'make everything' works again.
2008-09-18 15:04:47 +10:00
Dan Williams 313a4a82f1 ping_manager() to prevent 'add' before 'remove' completes
It is currently possible to remove a device and re-add it without the
manager noticing, i.e. without detecting a mdstat->devcnt
container->devcnt mismatch.  Introduce ping_manager() to arrange for
mdmon to run manage_container() prior to mdadm dropping the exclusive
open() on the container.  Despite these precautions sysfs_read() may
still fail.  If this happens invalidate container->devcnt to ensure
manage_container() runs at the next event.

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
2008-09-15 20:58:43 -07:00
Dan Williams c94709e83f Add ping_monitor() to mdadm --wait
The action we are waiting for may not be complete until the monitor has
had a chance to take action on the result.

The following script can now remove the device on the first attempt,
versus a few attempts with the original Wait():
#!/bin/bash
#export MDADM_NO_MDMON=1
export IMSM_DEVNAME_AS_SERIAL=1
./mdadm -Ss
./mdadm --zero-superblock /dev/loop[0-3]
echo 2 > /proc/sys/dev/raid/speed_limit_max
./mdadm --create /dev/imsm /dev/loop[0-3] -n 4 -e imsm -a md
./mdadm --create /dev/md/r1 /dev/loop[0-3] -n 4 -l 5 --force -a mdp
./mdadm --fail /dev/md/r1 /dev/loop3
./mdadm --wait /dev/md/r1
x=0
while  ! ./mdadm --remove /dev/imsm /dev/loop3 > /dev/null 2>&1
do
        x=$((x+1))
done
echo "removed after $x attempts"
./mdadm --add /dev/imsm /dev/loop3

Include 2 small cleanups:
* remove the almost open coded fd2devnum() in Wait() by introducing a
  new utility routine stat2devnum()
* teach connect_monitor() to parse the container device from a subarray
  string

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
2008-09-15 20:58:42 -07:00
NeilBrown e9dd159873 Allow an externally managed array to be marked readonly
If the metadata_version is
    -mdXXX/whatever
rather than
    /mdXXX/whatever

then the array is readonly and should be left alone by mdmon.

Signed-off-by: NeilBrown <neilb@suse.de>
2008-08-19 17:55:15 +10:00
NeilBrown 3c558363a1 Factor out test for subarray version string.
We are about to change the syntax of the version string
for 'subarray's.  So factor out the test into a single function.

Signed-off-by: NeilBrown <neilb@suse.de>
2008-08-19 17:55:15 +10:00
Dan Williams 43dad3d6fb mdadm: add device to a container
Adding a device updates the container and then mdmon takes action upon
noticing a change in devices.  This reuses the container version of
add_to_super to create a new record for the device.

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
2008-08-19 17:19:51 +10:00
NeilBrown 37ea3936a6 Merge branch 'master' into from-stable
Conflicts:

	Create.c
	Manage.c
2008-08-07 14:12:25 +10:00
NeilBrown ada6c2390a Manage: sync with mdmon before stopping containers.
mdmon sometimes opens the container.  That will prevent 'stop'
from working.  So sync with mdmon first.

Signed-off-by: Neil Brown <neilb@suse.de>
2008-07-18 16:37:25 +10:00
NeilBrown 4b9d39fc17 Manage: fixed some error message in --stop
Explain the meaning of 'quiet' explicitly, and fix some grammar
and formatting.

Signed-off-by: Neil Brown <neilb@suse.de>
2008-07-18 16:37:24 +10:00
Neil Brown daf7a3ce96 Stop managed arrays more carefully.
If an array is being managed by mdmon, then just
write "inactive" to stop it, and let mdmon do the
final "clear".  This makes sure mdmon has a chance
to read the final state and update the metadata properly.

After writing "inactive" with use "ping_monitor" to synchronise
with mdadm, then STOP the array just in case it is still running,
else we will get into an infinite loop in "mdadm -Ss".

Signed-off-by: Neil Brown <neilb@suse.de>
2008-07-18 16:37:09 +10:00
Neil Brown 6416d5275d Use O_DIRECT for all IO to devices.
Using buffered IO risks non-atomic updates to parts of the
device that we don't actually want to write to.  This isn't in
general safe.
So switch to O_DIRECT for all that IO and make sure we have
properly aligned buffers.
2008-07-12 20:28:33 +10:00
Neil Brown f94d52f43e Handle device removal from container
This really should be done in mdadm, not mdmon.
We ensure the device won't be suddenly commited as a hot-spare
using O_EXCL, then check the 'holders' sysfs directory
to make sure it is only in use once.
2008-07-12 20:27:40 +10:00
Neil Brown f7e7067b47 Add subarray field to supertype.
When loading the metadata for a subarray (super_by_fd), we set
->subarray to be the name read from md/metadata_version so that
getinfo_super can return info about the correct array.

With this we can differentiate between a container and
an array within the container by looking at ->subarray[0].
2008-07-12 20:27:38 +10:00
Neil Brown d927f3c4db Improve error message when mdadm fails to stop an array.
Signed-off-by: Neil Brown <neilb@suse.de>
2008-06-26 09:27:15 +10:00
Dan Williams f7dd881f90 handle Manage_subdevs() for 'external' arrays
From: Dan Williams <dan.j.williams@intel.com>

1/ Block attempts to add/remove devices from container members
2/ Forward add/remove requests to containers

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
2008-05-15 16:48:35 +10:00
Neil Brown 111d01fcc7 Change write_init_super to be called only once.
The current model for creating arrays involves writing
a superblock to each device in the array.
With containers (as with DDF), that model doesn't work.
Every device in the container may need to be updated
for an array made from just some the devices in a container.

So instead of calling write_init_super for each device,
we call it once for the array and have it iterate over
all the devices in the array.

To help with this, ->add_to_super now passes in an 'fd' and name for
the device.  These get saved for use by write_init_super.  So
add_to_super takes ownership of the fd, and write_init_super will
close it.
This information is stored in the new 'info' field of supertype.

As part of this, write_init_super now removes any old traces of raid
metadata rather than doing this in common code.
2008-05-15 16:48:12 +10:00
Neil Brown 7a3be72fc6 Fix problems with array.size overflowing on large arrays.
array.size is 32bits and counts K.  So for arrays with
more than 4Terrabytes, it can overflow.
The correct number can be read from sysfs, but there are still
a few places that use array.size and risk truncation.  What is worse.
they compare a number of kilobytes with a number of sectors !!

So use get_component_size() to read the sysfs information, and be
more consistent about units.
2008-04-28 16:29:37 +10:00
Neil Brown 1686dc25ec Find super from fd on an array.
We used to use the major/minor numbers, but that isn't sufficient
any more, so pass the fd, and possibly check 'text' version.
2007-12-14 20:14:38 +11:00
Neil Brown 3da92f272d Drop the superblock arg from all metadata methods.
It is now in the 'supertype'
2007-12-14 20:14:33 +11:00
Neil Brown 68c7d6d790 Add 'supertype' arg to almost all metadata methods.
The 'superblock' will be moved into this structure soon.
2007-12-14 20:14:16 +11:00
Neil Brown aba69144fd Remove spaces/tabs from ends of lines. 2007-12-14 20:13:43 +11:00
Neil Brown 25037aa872 Remove partitions from a device before adding it to an array.
The 'remove_partitions' call is in the wrong place and applying
to the wrong file.
2007-10-19 14:03:17 +10:00
Neil Brown 4d20d744cb Make "--write-mostly" effective when re-adding a device to an array.
Fixes Debian Bug 442874

When we discover that we can 're-add' a drive, we forget to check the
write-mostly flag.
This highlights the fact that you cannot turn 'off' the write-mostly
flag at this point.  I wonder if that is a problem...
2007-09-24 13:14:13 +10:00
Neil Brown 1f48664b8e Add --auto-detect for in-kernel autodetect.
This is equivalent to raidautorun that some distros provide.
2007-05-21 14:25:44 +10:00
Neil Brown b80da66161 Support failing and removed of detached and faulty devices.
This if you unplug a device and udev removes the entry from /dev,
you can still remove the device.
2007-05-11 16:13:03 +10:00
Neil Brown 8382f19bdc Add new mode: --incremental
--incremental allows arrays to be assembled one device at a time.
This is expected to be used with udev.
2006-12-21 17:10:52 +11:00
Neil Brown beae1dfe2e Central calls to ioctl BLKGETSIZE
Instead of opencoding the same thing everywhere.
2006-12-14 17:32:57 +11:00
Neil Brown 4a39c6f236 Check device is large enough before hot-add.
This improves quality of error message.
2006-12-14 17:32:49 +11:00
Luca Berra 435d4ebb2e Mdassemble improvements
From: Luca Berra <bluca@comedia.it>

- Fix a bug where mdassemble didn't close a filedescriptor and so couldn't assembele
  stacked arrays.
- Allow mdassemble, when run a second time, to mark all arrays as writable.
  This is useful if they are started read-only as is best at boot-time.
2006-10-16 15:26:53 +10:00
Neil Brown 0430ed4868 Remove partitions from components of an md array
They do nothing but cause confusion.
2006-10-13 09:02:35 +10:00
Neil Brown 7eae7080e2 Work around bug in --add handling for version-1 superblocks
In 2.6.17 (and prior), the dev_number is ignored when a device
is added to an active array.  Rather the first free number is used.
So we work around this by making sure we use the first free
number for dev_number.

Description...
2006-06-26 12:26:09 +10:00
Neil Brown ab56093f3b Get --stop to honour --quiet
And as a side effect, if --quiet isn't given, stopped devices are
reported.

Signed-off-by: Neil Brown <neilb@suse.de>
2006-06-02 05:53:22 +00:00
Neil Brown 4f589ad0c5 Just updaqte copyright dates and email address
Signed-off-by: Neil Brown <neilb@suse.de>
2006-05-19 05:25:11 +00:00
Neil Brown d8def61cfa fix write mostly for add and re-add
The following patch makes it possible to tag a device as write-mostly on
--add and --re-add with a non-persistent superblock array. Previously,
this was not working.

Signed-Off-By: Paul Clements <paul.clements@steeleye.com>
Signed-off-by: Neil Brown <neilb@suse.de>
2006-04-03 00:11:51 +00:00
Neil Brown 16c6fa807c Create missing /dev files where needed.
Whenever we need a device file to open, if one cannot be found in /dev,
create a temporary one.

Signed-off-by: Neil Brown <neilb@suse.de>
2006-03-28 06:26:53 +00:00
Neil Brown 313176636e Remove ident arg from getinfo_super;
Add a 'name' field to 'info' to compensate.

Signed-off-by: Neil Brown <neilb@suse.de>
2006-03-27 04:34:38 +00:00
Neil Brown 308e1801ba Fix assembling of array with spares when verion-1 superblock is used.
As spared don't have a position in the raid array with verion-1 superblocks,
we need to handle them a bit differently.

Signed-off-by: Neil Brown <neilb@suse.de>
2005-09-12 05:23:11 +00:00
Neil Brown 1bf4e2d962 Passes all tests, nearly ready for release.
Signed-off-by: Neil Brown <neilb@cse.unsw.edu.au>
2005-08-26 06:08:28 +00:00
Neil Brown 34163fc7cf Support internal bitmaps with format-1 superblocks.
Signed-off-by: Neil Brown <neilb@cse.unsw.edu.au>
2005-08-25 04:31:44 +00:00
Neil Brown fe80f49b6e Assorted fixes
Support "--build"ing arrays with bitmaps.
hot-removal of bitmaps
--re-add of drives recently removed.
assorted extra tests

Signed-off-by: Neil Brown <neilb@cse.unsw.edu.au>
2005-08-16 06:45:23 +00:00
Neil Brown dab6685f3d Add 'quite' option and tidy up some tests.
Signed-off-by: Neil Brown <neilb@cse.unsw.edu.au>
2005-08-15 06:14:27 +00:00
Neil Brown dfd4d8ee42 Add write-behind support
Currently this includes
  --write-behind  to set level of write-behind supported
  --write-mostly  to flag devices as write-mostly.

Signed-off-by: Neil Brown <neilb@cse.unsw.edu.au>
2005-08-09 04:25:47 +00:00
Neil Brown f277ce3671 Assorted Fixes for multiple bugs.
Assemble would crash, or just not work.
A few other problem found by a new test-suite.

Signed-off-by: Neil Brown <neilb@cse.unsw.edu.au>
2005-08-04 04:41:12 +00:00
Neil Brown 60d9a17455 Make hot-add work with v 1.0.1 superblocks
Just some carelessness

Signed-off-by: Neil Brown <neilb@cse.unsw.edu.au>
2005-07-29 00:19:25 +00:00
Neil Brown f0da9e8fcf Make sure we try hard enough to find a component device..
Signed-off-by: Neil Brown <neilb@cse.unsw.edu.au>
2005-07-06 23:12:04 +00:00
Neil Brown 91f068bf5c Retry --stop --scan until all stoppable devices have been stopped
This is needed to reliably stop stacked arrays

Signed-off-by: Neil Brown <neilb@cse.unsw.edu.au>
2005-06-14 06:32:18 +00:00
Neil Brown f5e166fee3 Support --grow --bitmap=internal
Adding a filebased bitmap is not yet supported, and
this code is still under development.

Signed-off-by: Neil Brown <neilb@cse.unsw.edu.au>
2005-06-07 23:03:46 +00:00
Neil Brown 892debc820 Use ADD_NEW_DISK to hot-add to non-version-0 arrays
Signed-off-by: Neil Brown <neilb@cse.unsw.edu.au>
2005-06-07 23:16:32 +00:00
Neil Brown 0fbf459d0d Fix embarassing bug in 1.10.0 which broke --add
Use a different variable to old result of open

Signed-off-by: Neil Brown <neilb@cse.unsw.edu.au>
2005-04-11 00:20:03 +00:00
Neil Brown d7eaf49f65 Use O_EXCL when opening component devices to be assembled into an array
In 2.6, this will fail if the device is already in use, so we can detect this error
more easily.

Signed-off-by: Neil Brown <neilb@cse.unsw.edu.au>
2005-04-04 06:02:49 +00:00
Neil Brown 0df46c2ad8 Change MAJOR() etc to major() etc
This allows for larger device number if glibc supports
it (requires 2.3.3).
Also fail before creating larger device number if glibc
support isn't present.

Signed-off-by: Neil Brown <neilb@cse.unsw.edu.au>
2005-04-04 05:16:13 +00:00
Neil Brown b5e6464503 mdadm-1.8.0 2004-11-01 04:49:34 +00:00
Neil Brown dd0781e505 mdadm-1.6.0 2004-06-04 12:03:19 +00:00
Neil Brown aa88f531b4 mdadm-1.3.0 2003-07-28 23:59:00 +00:00
Neil Brown b83d95f362 mdadm-0.8.2 2002-04-11 01:36:14 +00:00
Neil Brown c913b90e6d mdadm-0.8.1 2002-04-05 22:00:28 +00:00
Neil Brown e0d1903663 mdadm-0.8 2002-04-04 01:58:32 +00:00
Neil Brown 9a9dab3670 mdadm-0.7 2002-03-08 00:03:52 +00:00
Neil Brown cd29a5c835 mdctl-0.6 2002-03-06 23:17:40 +00:00
Neil Brown 5282684628 mdctl-0.5 2001-08-23 02:33:20 +00:00
Neil Brown 82b27616de mdctl-v0.4 2001-07-26 07:00:09 +00:00
Neil Brown 682c705194 mdctl-v0.3 2001-06-14 05:33:53 +00:00
Neil Brown 64c4757e27 mdctl-v0.2 2001-06-08 02:36:23 +00:00