summaryrefslogtreecommitdiff
path: root/mdadm.c
Commit message (Collapse)AuthorAge
...
* Create 'struct context' for ad hoc context option.NeilBrown2012-07-09
| | | | | | | | | | Rather than passing a long list of little flags etc to various functions we will soon pass a small collection of structures. This first step combines a collection of variables local to 'main' into a single structure. Signed-off-by: NeilBrown <neilb@suse.de>
* Create parse_num() function.NeilBrown2012-07-09
| | | | | | | | Instead of open-coding this several times, just do it once. The frees up the name 'c' which I'm about to use. Signed-off-by: NeilBrown <neilb@suse.de>
* Create: support --readonly flag.NeilBrown2012-07-09
| | | | | | Allow array to be created read-only Signed-off-by: NeilBrown <neilb@suse.de>
* Assemble: allow arrays to be assembled read-only.NeilBrown2012-07-09
| | | | | | The option was there, but never used. Signed-off-by: NeilBrown <neilb@suse.de>
* Remove scattered checks for malloc success.NeilBrown2012-07-09
| | | | | | | | | | | | | | malloc should never fail, and if it does it is unlikely that anything else useful can be done. Best approach is to abort and let some super-daemon restart. So define xmalloc, xcalloc, xrealloc, xstrdup which don't fail but just print a message and exit. Then use those removing all the tests for failure. Also replace all "malloc;memset" sequences with 'xcalloc'. Signed-off-by: NeilBrown <neilb@suse.de>
* Remove re_add flag in favour of new disposition.NeilBrown2012-07-09
| | | | | | | | | | | Instead of disposition == 'a' re_add == 1 use disposition == 'A' to record that a re-add was requested. Signed-off-by: NeilBrown <neilb@suse.de>
* Introduce pr_err for printing error messages.NeilBrown2012-07-09
| | | | | | | 'pr_err("' is a lot shorter than 'fprintf(stderr, Name ": ' cont_err() is also available. Signed-off-by: NeilBrown <neilb@suse.de>
* Help: use an array to choose which help matches which mode.NeilBrown2012-07-09
| | | | | | Looks cleaner than a big switch statement. Signed-off-by: NeilBrown <neilb@suse.de>
* main: extract more functions.NeilBrown2012-07-09
| | | | | | | extract misc_scan stop_scan misc_list from main to try to make main() a little more manageable. Signed-off-by: NeilBrown <neilb@suse.de>
* main: split scan_assemble into a separate functionNeilBrown2012-07-09
| | | | | | main is too big. This makes it a little more manageable. Signed-off-by: NeilBrown <neilb@suse.de>
* mdadm.c: various minor clean-upsNeilBrown2012-07-09
| | | | Signed-off-by: NeilBrown <neilb@suse.de>
* Use explicit non-char opt for --zero-superNeilBrown2012-07-09
| | | | | | | | As we don't allow '-K' for '--zero-super' there is no point using it internally. Just define a 'KillOpt' like with other options. Signed-off-by: NeilBrown <neilb@suse.de>
* Add --prefer option for --detail and --monitorNeilBrown2012-04-18
| | | | | | | | | | | | | | | | | Both --detail and --monitor can report the names of member devices on an array, and do so by searching /dev and finding the shortest name that matches. If --prefer=foo is given, they will instead prefer a name that contain /foo/. So mdadm --detail /dev/md0 --prefer=by-path will list the component devices via their /dev/disk/by-path/xxx names. Signed-off-by: NeilBrown <neilb@suse.de>
* parse_size: distinguish between 0 and error.NeilBrown2012-04-04
| | | | | | | | | | | | It isn't sufficient to use '0' for 'error' as well will later have fields that can validly be '0'. So return "-1" on error. Also fix parsing of --bitmap_check so that '0' is treated as an error: we don't support 512B anyway. Signed-off-by: NeilBrown <neilb@suse.de>
* Spawn mdmon with --offroot if mdadm was launched with --offrootJes Sorensen2012-01-30
| | | | | | Acked-by: Doug Ledford <dledford@redhat.com> Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com> Signed-off-by: NeilBrown <neilb@suse.de>
* Add --offroot argument to mdadmJes Sorensen2012-01-30
| | | | | | | | | | | When --offroot is specified, mdadm will change the first character of argv[0] to '@'. This is used to signal to systemd that mdadm was launched from initramfs and should not be shut down before returning to the initramfs. Acked-by: Doug Ledford <dledford@redhat.com> Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com> Signed-off-by: NeilBrown <neilb@suse.de>
* allow --monitor to be run by non-privileged use.NeilBrown2011-12-23
| | | | | | | | | | | | Providing --no-sharing is given, monitoring should be permitted. Unfortunately the kernel current rejects GET_DISK_INFO and GET_ARRAY_INFO for non-privileged users which is unjustified. The info is available in sysfs and we could get it from there, but for now, require the kernel to be fixed. Reported-by: Raphael Hertzog <hertzog@debian.org> Signed-off-by: NeilBrown <neilb@suse.de>
* fix: Allowed to assemble 2 volumes with the same names from config file.Lukasz Orlowski2011-11-07
| | | | | | | | | | | | | mdadm allowes to assemble 2 volumes with the same names based on the config file. The issue is fixed by iterating over the list of md device identifiers and comparing the names of md devices against each other, detecting identical names and blocking the assembly should the same names be found. Now having detected duplicate names, mdadm terminates without assembling the container, displaying appropriate prompt. Signed-off-by: Lukasz Orlowski <lukasz.orlowski@intel.com> Signed-off-by: NeilBrown <neilb@suse.de>
* mdadm: Rearrange option parsing for KillSubarray and UpdateSubarrayJes Sorensen2011-11-03
| | | | | | | | | | | | Extracting the 'subarray' arg for these options was being done at the wrong place which lead to the code being a bit confusing and looking wrong. So reformat that code a bit better and move the extraction of 'subarray' down to the main parsing of these options rather than the mode setting. Signed-off-by: NeilBrown <neilb@suse.de>
* Hold the map lock while performing Assemble to avoid races with udevJes Sorensen2011-10-22
| | | | | Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com> Signed-off-by: NeilBrown <neilb@suse.de>
* Add continue option to grow commandAdam Kwolek2011-10-03
| | | | | | | | | | | | | To allow for reshape continuation '--continue' option is added to grow command. Function that will be executed in grow-continue case doesn't require information about reshape geometry. All required information are read from metadata. For external metadata reshape can be run for monitored array/container only. In case when array/container is not monitored run mdmon for it. Signed-off-by: Adam Kwolek <adam.kwolek@intel.com> Signed-off-by: NeilBrown <neilb@suse.de>
* Do not continue reshape during initrd phaseAdam Kwolek2011-10-03
| | | | | | | | | | | | | | During initrd phase continuing reshape will cause file system context lost. This blocks ability to control reshape using checkpoints. To avoid this, during initrd phase assemble has to be executed with '--freeze-reshape' option. This causes that mdadm restores reshape critical section only. Reshape can be continued later after system full boot. Signed-off-by: Adam Kwolek <adam.kwolek@intel.com> Signed-off-by: NeilBrown <neilb@suse.de>
* Monitor: --oneshot must imply --no-sharingNeilBrown2011-09-19
| | | | | | | | | | | | | Moving spares is not the purpose of '--oneshot' and without currently --oneshot doesn't work as the check against multiple spare-sharers prevents it. So make --oneshot imply --no-sharing. This is sensible and allows --oneshot to work again. Reported-by: Jamie Heilman <jamie@audible.transient.net> Resolves-Debian-Bug: 641886 Signed-off-by: NeilBrown <neilb@suse.de>
* Discourage large devices from being added to 0.90 arrays.NeilBrown2011-09-08
| | | | | | | | 0.90 arrays can only use up to 4TB per device. So when a larger device is added, complain a bit. Still allow it if --force is given as there could be a valid use. Signed-off-by: NeilBrown <neilb@suse.de>
* Grow: accept --assume-clean with --grow --sizeNeilBrown2011-05-16
| | | | | | | When an array is resized to have larger members, --assume-clean will disable any resync if the kernel supports it (2.6.40 and later). Signed-off-by: NeilBrown <neilb@suse.de>
* Create: allow chunksize to be non-power-of-2.NeilBrown2011-05-10
| | | | | | | RAID0 has accepted chunksizes that are not a power of 2 since 2.6.30. So it time mdadm allowed that to be used. Signed-off-by: NeilBrown <neilb@suse.de>
* Give suitable error for mdadm /dev/md0 --stopNeilBrown2011-05-10
| | | | | | | | | Options like --stop must come before the device that is being stopped. If (in --misc mode) a device does not have an option, nothing will be done to it, which can be confusing. So report an error in this case. Signed-off-by: NeilBrown <neilb@suse.de>
* config: restore the possibility of a NULL homehostNeilBrown2011-05-10
| | | | | | | | | | | | | As homehost defaults to the system name it is not possible to specify a NULL homehost. This patch restored this ability with either --homehost="" or --homehost="<none>". This allows the creation of v1.x arrays without a "hostname:" prefix in the name. Signed-off-by: NeilBrown <neilb@suse.de>
* Finally remove auto-home-hostNeilBrown2011-04-27
| | | | | | | | This was #if-ed out for 3.0, but it really should go. Gcc 4.6.0 complains that auto_update_home is set but not used (which is true). Reported-by: Tobias Powalowski <t.powa@gmx.de>
* Fix regression when using 'grow' to add a bitmap.NeilBrown2011-03-15
| | | | | | | | | | When we allowed a devlist to accompany some --grow modes - but not --bitmap - we made --bitmap always fail, in stead of fail of a device was given to add. As 'devs_found' includes the md device, we need to compare against '1'. Signed-off-by: NeilBrown <neilb@suse.de>
* Grow: support reshape of RAID0 arrays.NeilBrown2011-03-10
| | | | | | | | | | This is done via conversion to RAID4 and back. To grow the array, extra devices will be needed which cannot already be present as spares - so allow a list of new devices to be included in grow request which changed the number of devices. Signed-off-by: NeilBrown <neilb@suse.de>
* Dynamic hot-plug udev rules for policiesLabun, Marcin2011-01-27
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Neil, Please consider this patch that once was discussed and I think agreed with in general direction. It was sent a while ago but somehow did not merged into your devel3-2. This patch enables hot-plug of so called bare devices (as understand by domain policies rules in mdadm.conf). Without this patch we do NOT serve hot-plug of bare devices at all. Thanks, Marcin Labun Subject was: FW: Autorebuild, new dynamic udev rules for hot-plugs >>From c0aecd4dd96691e8bfa6f2dc187261ec8bb2c5a2 Mon Sep 17 00:00:00 2001 From: Przemyslaw Czarnowski <przemyslaw.hawrylewicz.czarnowski@intel.com> Date: Thu, 23 Dec 2010 16:35:01 +0100 Subject: [PATCH] Dynamic hot-plug udev rules for policies Cc: linux-raid@vger.kernel.org, Williams, Dan J <dan.j.williams@intel.com>, Ciechanowski, Ed <ed.ciechanowski@intel.com> When introducing policies, new hot-plug rules were added to support bare disks. Mdadm was started for each hot plugged block device to determine if it could be used as spare or as a replacement member for degraded array. This patch introduces limitation of range of devices that are handled by mdadm. It limits them to the ones specified in domains associated with the actions: spare-same-port, spare and spare-force. In order to enable hot-plug for bare disks one must update udev rules with command mdadm --activate-domains[=filename] Above command writes udev rule configuration to stdout. If 'filename' is given output is written to the file provided as parameter. It is up to system administrator what should be done later. To make such rule permanent (i.e. remain after reboot) rule should be writen to /lib/udev/rules.d directory. Other cases will just need to write it to /dev/.udev/rules.d directory where temporary rules lies. One should be aware of the meaning of names/priorities of the udev rules. After mdadm.conf is changed one is obliged to re-run "mdadm --activate-domains" command in order to bring the system configuration up to date. All hot-plugged disks containing metadata are still handled by existing rules. Signed-off-by: Przemyslaw Czarnowski <przemyslaw.hawrylewicz.czarnowski@intel.com> Signed-off-by: NeilBrown <neilb@suse.de>
* Allow --update=devicesize with --re-addNeilBrown2010-12-09
| | | | | | | | | | This is useful with 1.1 and 1.2 metadata to update the metadata if the device size has changed. The same functionality can be achieved by writing to the device size in sysfs after re-adding normally, but in some cases this might be easier. Signed-off-by: NeilBrown <neilb@suse.de>
* Grow: warn if growing an array will make it degraded.NeilBrown2010-12-09
| | | | | | | | | Growing an array when there aren't enough spares can make the array degraded. This works but might not be what is wanted. So warn the user in this case and require a --force to go ahead with the reshape. Signed-off-by: NeilBrown <neilb@suse.de>
* Create/grow: improve checks on number of devices.NeilBrown2010-12-01
| | | | | | | | | | Check on upper limit of number of devices was in the wrong place. Result was could not create array with more than 27 devices without explicitly setting metadata, even though default metadata allows more. Fixed, and also perform check when growing an array. Signed-off-by: NeilBrown <neilb@suse.de>
* Assemble: allow an array undergoing reshape to be started without backup fileNeilBrown2010-12-01
| | | | | | | | | Though not having the proper backup file can cause data corruption, it is not enough to justify not being able to start the array at all. So allow "--invalid-backup" to be specified which says "just continue even if a backup cannot be restored". Signed-off-by: NeilBrown <neilb@suse.de>
* Assemble: add --update=no-bitmapNeilBrown2010-11-30
| | | | | | | This allows an array with a corrupt internal bitmap to be assembled without the bitmap. Signed-off-by: NeilBrown <neilb@suse.de>
* Allow K,M,G suffix on chunk sizes as well as device/array sizes.NeilBrown2010-11-30
| | | | | | | | | | We already allow K,M,G suffixes for --size and --array-size. Allow it for --chunk and --bitmap-chunk as well. Also add this info to man page, and remove the duplication of info about --array-size. Signed-off-by: NeilBrown <neilb@suse.de>
* Improve opt parsing, and distinguish long from short.NeilBrown2010-11-25
| | | | | | | | | | | | | | In several cases, two different long options map to the same short option. So e.g. you could give '--brief' and it would be interpreted as '--bitmap'. That isn't really good. So for every shared short option, define an option number and return that for the long option instead. Then always check for both the short and long options. Also give some bugs like " mode == 'G'" which should be '== GROW'. Signed-off-by: NeilBrown <neilb@suse.de>
* fix a get_linux_version() comparison typoDan Williams2010-11-23
| | | | | Signed-off-by: Dan Williams <dan.j.williams@intel.com> Signed-off-by: NeilBrown <neilb@suse.de>
* mdadm: added --no-sharing option for Monitor modeAnna Czarnowska2010-11-22
| | | | | | | | | | | | --no-sharing option disables moving spares between arrays/containers. Without the option spares are moved if needed according to config rules. We only allow one process moving spares started with --scan option. If there is such process running and another instance of Monitor is starting without --scan, then we issue a warning but allow it to continue. Signed-off-by: Anna Czarnowska <anna.czarnowska@intel.com> Signed-off-by: NeilBrown <neilb@suse.de>
* added --path <path_id> to give the information on the 'path-id' of removed ↵Przemyslaw Czarnowski2010-11-22
| | | | | | | | | | | | | | | | device <path-id> allows to identify the port to which given device is plugged in. In case of hot-removal, udev can pass this information for future use (eg. write this name as 'cookie' allowing to detect the fact of reinserting device to the same port). --path <path-id> parameter has been added to device removal handle (and char *path has been added to IncrementalRemove() to pass this value) in order to pass path-id to this handler. Signed-off-by: Przemyslaw Czarnowski <przemyslaw.hawrylewicz.czarnowski@intel.com> Signed-off-by: NeilBrown <neilb@suse.de>
* Remove content from mddev_devNeilBrown2010-11-22
| | | | | | | | Now that the next_member loop is much smaller it is easy to just use 'content' rather than stashing it in 'tmpdev->content'. So we can remove the 'content' field from 'struct mddev_dev'. Signed-off-by: NeilBrown <neilb@suse.de>
* Improve type names for mddev_devNeilBrown2010-11-22
| | | | | | | | | Remove the _t pointer typedef and remove the _s suffix for the structure, These things do not help readability. Signed-off-by: NeilBrown <neilb@suse.de>
* Improve mddev_ident type definitions.NeilBrown2010-11-22
| | | | | | | | Remove the _t typedef and remove the _s suffix from the struct name. These things do not help readability. Signed-off-by: NeilBrown <neilb@suse.de>
* Incremental: accept '--no-degraded' as a deprecated optionDan Williams2010-08-12
| | | | | | | | | | | | | | 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>
* Merge branch 'master' of git://github.com/djbw/mdadmNeilBrown2010-07-06
|\
| * Merge branch 'fixes' into for-neilDan Williams2010-07-01
| |\
| * | Rename subarray v2Dan Williams2010-06-22
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Allow the name of the array stored in the metadata to be updated. In some cases the metadata format may not be able to support this rename without modifying the UUID. In these cases the request will be blocked. Otherwise we allow the rename to take place, even for active arrays. This assumes that the user understands the difference between the kernel node name, the device node symlink name, and the metadata specific name. Anticipating further need to modify subarrays in-place, introduce the ->update_subarray() superswitch method. A future potential use case is setting storage pool (spare-group) identifiers. Signed-off-by: Dan Williams <dan.j.williams@intel.com>
| * | Kill subarray v2Dan Williams2010-06-15
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Support for deleting a subarray out of a container. When all subarrays are deleted the component devices are converted back into spares, a --zero-superblock is still needed to kill the remaining metadata at this point. This operation is blocked when the subarray is active and may also be blocked by the metadata handler when deleting the subarray might change the uuid of other active subarrays. For example, with imsm, deleting subarray 'n' may change the uuid of subarrays with indexes > n. Deleting a subarray needs to be a container wide event to ensure disks that record the modified subarray list perceive other disks that did not receive this change as out of date. Notes: The st->subarray parsing in super-intel.c and super-ddf.c is updated to be more strict now that we are reading user supplied subarray values. Offline container modification shares actions that mdmon typically handles so promote is_container_member() and version_to_superswitch() (formerly find_metadata_methods()) to generic utility functions for the cases where mdadm performs the operation. Signed-off-by: Dan Williams <dan.j.williams@intel.com>