summaryrefslogtreecommitdiffstats
path: root/Manage.c
Commit message (Collapse)AuthorAgeFilesLines
* Don't silently map --re-add to --addNeilBrown2009-11-171-0/+6
| | | | | | | | | 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>
* Merge branch 'master' into devel-3.1NeilBrown2009-10-221-1/+3
|\
| * Free some malloced memory that wasn't being freed.NeilBrown2009-10-221-1/+3
| | | | | | | | | | | | | | | | | | | | 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>
* | Merge branch 'master' into devel-3.1NeilBrown2009-10-011-10/+9
|\| | | | | | | | | Conflicts: mdadm.8
| * Merge branch 'master' into devel-3.0NeilBrown2009-06-021-3/+7
| |\ | | | | | | | | | | | | | | | Conflicts: super0.c super1.c
| | * Monitor: support spare-group manipulation for 1.x metadata.NeilBrown2009-05-121-2/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
| * | Update copyright dates and remove references to @cse.unsw.edu.auNeilBrown2009-06-021-7/+2
| | | | | | | | | | | | | | | | | | Also removed 'paper' addresses. Signed-off-by: NeilBrown <neilb@suse.de>
* | | Remove Manage_reconfing in favour of Grow_reshapeNeilBrown2009-07-141-18/+0
|/ / | | | | | | | | | | | | | | 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>
* | Merge branch 'master' into devel-3.0NeilBrown2009-05-111-0/+5
|\| | | | | | | | | | | | | | | Conflicts: Build.c mdadm.c mdadm.h super1.c
| * re-add error checkNeilBrown2009-05-051-0/+5
| |
* | incremental_container: preserve 'in_sync' flag when adding to existing array.NeilBrown2009-04-141-1/+1
| | | | | | | | | | | | | | | | | | | | | | 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>
* | Manage: permit '--remove detached' for containersDan Williams2009-02-241-1/+8
| | | | | | | | | | | | | | | | 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>
* | Tidy error messages for add_to_super failure.NeilBrown2008-11-271-2/+0
| | | | | | | | | | | | | | 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>
* | allow add_to_super to return errorsDan Williams2008-11-271-2/+7
| | | | | | | | | | | | Prepare add_to_super to validate disks against the platform capabilities Signed-off-by: Dan Williams <dan.j.williams@intel.com>
* | fix remove_devices()Dan Williams2008-11-081-4/+6
| | | | | | | | | | | | Don't write to 'pe' if 'path' was not specified Signed-off-by: Dan Williams <dan.j.williams@intel.com>
* | Stop: drop any partitions that may be associated with an array when stopping it.NeilBrown2008-11-041-1/+4
| | | | | | | | | | | | | | 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>
* | Manage: when stopping an array, delete all names from /dev.NeilBrown2008-11-041-6/+59
| | | | | | | | | | | | | | | | | | 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>
* | Generate 'change' uevents when arrays change in non-obvious ways.NeilBrown2008-11-041-2/+7
| | | | | | | | | | | | | | | | | | | | | | 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>
* | Merge branch 'master' into devel-3.0NeilBrown2008-10-271-3/+5
|\| | | | | | | | | | | | | Conflicts: Create.c Manage.c
| * Allow WRITEMOSTLY to be cleared on --readd using --readwrite.NeilBrown2008-10-251-3/+5
| | | | | | | | | | | | | | | | 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>
* | Merge branch 'master' into devel-3.0NeilBrown2008-10-171-7/+9
|\| | | | | | | | | | | Conflicts: Manage.c
| * Manage: allow adding device that is just large enough to v1.x array.NeilBrown2008-10-131-8/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | 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
* | Compile fixes, particularly moving more stuff under MDASSEMBLENeilBrown2008-09-181-1/+4
| | | | | | | | Now 'make everything' works again.
* | ping_manager() to prevent 'add' before 'remove' completesDan Williams2008-09-151-0/+17
| | | | | | | | | | | | | | | | | | | | | | | | 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>
* | Add ping_monitor() to mdadm --waitDan Williams2008-09-151-6/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* | Allow an externally managed array to be marked readonlyNeilBrown2008-08-191-0/+43
| | | | | | | | | | | | | | | | | | | | | | 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>
* | Factor out test for subarray version string.NeilBrown2008-08-191-2/+2
| | | | | | | | | | | | | | 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>
* | mdadm: add device to a containerDan Williams2008-08-191-7/+59
| | | | | | | | | | | | | | | | | | 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>
* | Merge branch 'master' into from-stableNeilBrown2008-08-071-1/+6
|\| | | | | | | | | | | | | Conflicts: Create.c Manage.c
| * Improve error message when mdadm fails to stop an array.Neil Brown2008-06-261-1/+6
| | | | | | | | Signed-off-by: Neil Brown <neilb@suse.de>
* | Manage: sync with mdmon before stopping containers.NeilBrown2008-07-181-0/+9
| | | | | | | | | | | | | | mdmon sometimes opens the container. That will prevent 'stop' from working. So sync with mdmon first. Signed-off-by: Neil Brown <neilb@suse.de>
* | Manage: fixed some error message in --stopNeilBrown2008-07-181-6/+11
| | | | | | | | | | | | | | Explain the meaning of 'quiet' explicitly, and fix some grammar and formatting. Signed-off-by: Neil Brown <neilb@suse.de>
* | Stop managed arrays more carefully.Neil Brown2008-07-181-3/+37
| | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* | Use O_DIRECT for all IO to devices.Neil Brown2008-07-121-2/+2
| | | | | | | | | | | | | | | | 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.
* | Handle device removal from containerNeil Brown2008-07-121-54/+59
| | | | | | | | | | | | | | 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.
* | Add subarray field to supertype.Neil Brown2008-07-121-2/+2
| | | | | | | | | | | | | | | | | | 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].
* | handle Manage_subdevs() for 'external' arraysDan Williams2008-05-151-1/+62
| | | | | | | | | | | | | | | | | | 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>
* | Change write_init_super to be called only once.Neil Brown2008-05-151-3/+6
|/ | | | | | | | | | | | | | | | | | | | | 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.
* Fix problems with array.size overflowing on large arrays.Neil Brown2008-04-281-2/+11
| | | | | | | | | | | 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.
* Find super from fd on an array.Neil Brown2007-12-141-4/+2
| | | | | We used to use the major/minor numbers, but that isn't sufficient any more, so pass the fd, and possibly check 'text' version.
* Drop the superblock arg from all metadata methods.Neil Brown2007-12-141-24/+30
| | | | It is now in the 'supertype'
* Add 'supertype' arg to almost all metadata methods.Neil Brown2007-12-141-4/+4
| | | | The 'superblock' will be moved into this structure soon.
* Remove spaces/tabs from ends of lines.Neil Brown2007-12-141-6/+6
|
* Remove partitions from a device before adding it to an array.Neil Brown2007-10-191-1/+1
| | | | | The 'remove_partitions' call is in the wrong place and applying to the wrong file.
* Make "--write-mostly" effective when re-adding a device to an array.Neil Brown2007-09-241-3/+5
| | | | | | | | | 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...
* Add --auto-detect for in-kernel autodetect.Neil Brown2007-05-211-0/+13
| | | | This is equivalent to raidautorun that some distros provide.
* Support failing and removed of detached and faulty devices.Neil Brown2007-05-111-17/+91
| | | | | This if you unplug a device and udev removes the entry from /dev, you can still remove the device.
* Add new mode: --incrementalNeil Brown2006-12-211-0/+14
| | | | | --incremental allows arrays to be assembled one device at a time. This is expected to be used with udev.
* Central calls to ioctl BLKGETSIZENeil Brown2006-12-141-12/+1
| | | | Instead of opencoding the same thing everywhere.
* Check device is large enough before hot-add.Neil Brown2006-12-141-1/+35
| | | | This improves quality of error message.