summaryrefslogtreecommitdiff
path: root/Assemble.c
Commit message (Collapse)AuthorAge
* Assemble: Only fail auto-assemble in face of mdadm.conf conflicts.NeilBrown2014-07-29
| | | | | | | | | We should never auto-assemble things that conflict with mdadm.conf However explicit assembly requests should be allowed. Reported-by: olovopb Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1070245 Signed-off-by: NeilBrown <neilb@suse.de>
* IMSM: Add warning message when assemble spanned containerPawel Baldysiak2014-07-08
| | | | | | | | | | | Due to several changes in code assemble with disks spanned between different controllers can be obtained in some cases. After IMSM container will be assembled, check HBA of disks, and print proper warning if mismatch is detected. Signed-off-by: Pawel Baldysiak <pawel.baldysiak@intel.com> Signed-off-by: Artur Paszkiewicz <artur.paszkiewicz@intel.com> Signed-off-by: NeilBrown <neilb@suse.de>
* Incremental: remove old devices when assembling in container.NeilBrown2014-06-05
| | | | | | | | | | | | | | | | | When assembling a native array we just give all devices to the kernel and leave it to discard the 'old' ones (based on sequence/event number). For external/container arrays, mdadm needs to do that. So in assemble_container_content, get list of current devices in array and discard any that aren't in the 'content' given. They must have been rejected by metadata manager. If we cannot discard old devices the array must already be active, so just leave it alone, but with a message. Signed-off-by: NeilBrown <neilb@suse.de>
* Grow: fix resent grow_continue breakage.NeilBrown2014-05-22
| | | | | | | | | | | | | | | | | Commit 5e76dce1acd906e8fc8af04973c3a129cdc77fd6 changed Grow_continue to assume a fork had already happened, so that mdadm --grow --continue didn't fork. This is good, but it means that if Grow_continue is run from Assemble, then mdadm --assemble .... can misbehave if the array was in the middle of a reshape. So introduce finer control. Grow_continue only assumes it has already forked if run from "mdadm --grow --continue". Signed-off-by: NeilBrown <neilb@suse.de>
* Grow: store a link to current backup file in /run/mdadm or similar.NeilBrown2014-05-15
| | | | | | | | | | | | | | Subsequent patch will allow the background part of "mdadm --grow" to be run from systemd. This can require the passing of a backup file name. To do this, store that name as a symlink in /run/mdadm (or MAP_DIR) and look for it when appropriate. It might be useful to also store the name across reboot, but that would be a different patch. We would need to use the uuid to identify it, and store it in stable storage. Signed-off-by: NeilBrown <neilb@suse.de>
* Assemble: change load_devices to return most_recent 'st' value.NeilBrown2014-02-25
| | | | | | | | | | | | | This means that st->ss->getinfo_super(st, content, NULL); clean = content->array.state & 1; will get an up-to-date value for 'clean'. This fix allows tests/03r5assem-failed to work. Signed-off-by: NeilBrown <neilb@suse.de>
* Assemble: re-arrange freeing of 'tst' in load_devices().NeilBrown2014-02-25
| | | | | | | | | | | | | When we return in error, we need to free(tst), and ->free_super(tst); Sometimes we didn't. Also the final ->free_super(tst) should be followed by free(tst) but wasn't. Move that file free forward in the code a bit as we will want to use the tst there in the next patch. Signed-off-by: NeilBrown <neilb@suse.de>
* Assemble: allow load_devices to change the 'st' which is passed in.NeilBrown2014-02-25
| | | | | | | The given 'st' might not be best. Making this interface change will allow load_devices to return a better 'st'. Signed-off-by: NeilBrown <neilb@suse.de>
* Assemble: avoid infinite loop when auto-assembling partial container.NeilBrown2014-01-20
| | | | | | | | | | | | | | When auto-assembling we loop until we get no successes. If a device is found that look like it is part of an already-existing container, but we subsequently fail to add that device, then the fact that the container is running looks like a success. This can result in infinite looping. So if a container was already partially assemble, and is still only partially assembled after we try to add devices, then don't treat that as success. Signed-off-by: NeilBrown <neilb@suse.de>
* Assemble/Incremental: don't hold O_EXCL on mddev after assembly.NeilBrown2013-12-05
| | | | | | | As soon as the array is assembled, udev or systemd might run fsck and mount it. So we need to drop O_EXCL promptly. Signed-off-by: NeilBrown <neilb@suse.de>
* Incremental: add --export handling.NeilBrown2013-11-28
| | | | | | | | | | | | | | | | | | | | | | | | | | If --export is given with --incremental, then MD_DEVNAME is output which gives the name of the device (in /dev/md) that is the array (or container) that the device would be added to. Also MD_STARTED is set to one of no unsafe yes nothing to indicate if the array was started. IF MD_STARTED=unsafe then it may be appropriate to run mdadm -R /dev/md/$MD_DEVNAME after a timeout to ensure newly degraded array are started. If MD_FOREIGN=yes it might be appropriate to suppress this as the array is probably not critical. Signed-off-by: NeilBrown <neilb@suse.de>
* Restructure assemble_container_content and improve messages.NeilBrown2013-11-28
| | | | | | | | We lose one level of indent, and now get told the difference between 'not assemble because not safe' and 'not assembled because not enough devices'. Signed-off-by: NeilBrown <neilb@suse.de>
* Assembe: fix bug in force_array - it wasn't forcing properly.NeilBrown2013-10-22
| | | | | | | | | | | Since 'best' was expanded to hold replacement devices, we might need to go up to raid_disks*2 to find devices to force. Also fix another place when considering replacement drives would be wrong (the 'chosen' device should never be a replacement). Reported-by: John Yates <jyates65@gmail.com> Signed-off-by: NeilBrown <neilb@suse.de>
* Make -IRs and --run work properly for containers.NeilBrown2013-09-13
| | | | | | | | We really need to make sure assemble_container_content() gets called to finished the assembly of these. Reported-by: Francis Moreau <francis.moro@gmail.com> Signed-off-by: NeilBrown <neilb@suse.de>
* Release mdadm-3.3NeilBrown2013-09-03
| | | | | | (and various cosmetic fixes) Signed-off-by: NeilBrown <neilb@suse.de>
* Assemble: don't ever consider a 'spare' to be the 'most recent'.NeilBrown2013-09-02
| | | | | | | | | | | | If all devices have the same event count and the first one is a spare, then that spare will be the 'most_recent'. However then other devices will think the 'most_recent' has failed (for v0.90 metadata) and will be rejected from the array. So never consider a 'spare' to be 'most recent'. Reported-by: Andreas Baer <synthetic.gods@gmail.com> Signed-off-by: NeilBrown <neilb@suse.de>
* Don't set 'hold' option for mdstat_read if not needed.NeilBrown2013-07-10
| | | | | | | | We only need 'hold' if we want to mdstat_wait for a change. These two callers don't care about a change, so they shouldn't use the 'hold' flag. Signed-off-by: NeilBrown <neilb@suse.de>
* Assemble: avoid a consistency check when --force is given.NeilBrown2013-07-08
| | | | | | | | | | | | | | | | | | | | mdadm will normally not include a device into an array if that device reports that the "best" device has failed, as this normally implies some sort of inconsistency. However when --force is given it means that the given drives really should be assembled if at all possible so in that case the test should be avoided. The particular case where this was a problem was a RAID5 were all devices had the same event count but three of them reported that the first two had failed. As they all had the same event count the first was taken as the 'best' and that caused the later ones to be excluded. Listing one of the later ones first allowed the array to be assembled. So in this case the test clearly just got in the way and did nothing useful. Reported-by: "Marek Jaros" <mjaros1@nbox.cz> Signed-off-by: NeilBrown <neilb@suse.de>
* Assemble: improve messages when restarting a reshape.NeilBrown2013-07-02
| | | | | | | | If the restarted reshape needs a backup file and we don't have one, that should be reported before we try to start the array. Also we shouldn't say the "Cannot grow" but "cannot complete". Signed-off-by: NeilBrown <neilb@suse.de>
* Assemble: ignore devices= if container= is present.NeilBrown2013-07-02
| | | | | | | | | | | | | | If "container=" is present, then we are going to assemble from the given container where that container is made of those devices or not. So in this case the "devices=" is purely documentation and is best ignored. As part of this, move the test on the "container=" value when that start with "/" up before the device is opened. There sooner we test things, the better. Reported-by: Martin Wilck <mwilck@arcor.de> Signed-off-by: NeilBrown <neilb@suse.de>
* Assemble: write raid-disks should be less fatal.NeilBrown2013-07-02
| | | | | | | | If the container metadata doesn't know how many device to expect (as is the case with IMSM), don't fail an --assemble which over-specifies the number of devices. Signed-off-by: NeilBrown <neilb@suse.de>
* Assemble: remove some stray tracing.NeilBrown2013-06-27
| | | | | | | Was introduced in: Assemble: when forcing a single-degraded RAID6 array, trigger a 'repair'. Signed-off-by: NeilBrown <neilb@suse.de>
* Add test for interaction of --assemble with --incrNeilBrown2013-06-19
| | | | | | | and fix the bug that it found. The refactor of start_array() missed a test. Signed-off-by: NeilBrown <neilb@suse.de>
* Remove lots of unnecessary white space.NeilBrown2013-06-19
| | | | | | | Now that I am using white-space mode in Emacs I can see all of this, and I don't like it :-) Signed-off-by: NeilBrown <neilb@suse.de>
* Assemble: when forcing a single-degraded RAID6 array, trigger a 'repair'.NeilBrown2013-06-19
| | | | | | | | | | | | | | | | When an active/degraded RAID6 array is force-started we clear the 'active' flag, but it is still possible that some parity is no in sync. This is because there are two parity block. It would be nice to be able to tell the kernel "P is OK, Q maybe not". But that is not possible. So when we force-assemble such an array, trigger a 'repair' to fix up any errant Q blocks. This is not ideal as a restart during the repair will not be continued after the restart, but it is the best we can do without kernel help. Signed-off-by: NeilBrown <neilb@suse.de>
* Assemble/Incr: Don't include spares with too-high event count.NeilBrown2013-06-17
| | | | | | | | | | | Some failure scenarios can leave a spare with a higher event count than an in-sync device. Assembling an array like this will confuse the kernel. So detect spares with event counts higher than the best non-spare event count and exclude them from the array. Reported-by: Alexander Lyakas <alex.bolshoy@gmail.com> Signed-off-by: NeilBrown <neilb@suse.de>
* Make sure NOFILE resource limit is big enough.NeilBrown2013-05-30
| | | | | | | | | | Some people want to create truely enormous arrays. As we sometimes need to hold one file descriptor for each device, this can hit the NOFILE limit. So raise the limit if it ever looks like it might be a problem. Signed-off-by: NeilBrown <neilb@suse.de>
* Assemble: --update=metadata converts v0.90 to v1.0NeilBrown2013-05-28
| | | | | | | | | | This allows the smooth conversion of legacy 0.90 arrays to 1.0 metadata. Old metadata is likely to remain but will be ignored. It can be removed with mdadm --zero-superblock --metadata=0.90 /dev/whatever Signed-off-by: NeilBrown <neilb@suse.de>
* Discard devnum in favour of devnmNeilBrown2013-02-21
| | | | | | | | | | | | | | We widely use a "devnum" which is 0 or +ve for md%d devices and -ve for md_d%d devices. But I want to be able to use md_%s device names. So get rid of devnum (a number) and use devnm (a 32char string). eg. md0 md_d2 md_home Signed-off-by: NeilBrown <neilb@suse.de>
* Assemble: fix spelling: report_missmatch -> report_mismatchNeilBrown2012-12-05
| | | | Signed-off-by: NeilBrown <neilb@suse.de>
* Assemble: Don't auto-assemble arrays which conflict with mdadm.confNeilBrown2012-12-05
| | | | | | | | | | | | | When auto-assembling we might find an array which appear in mdadm.conf. This can happen if the array (based on UUID) doesn't match what is in mdadm.conf. For consistency we should avoid auto-assembling such an array just as we avoid regular-assembling of the array. Reported-by: Ross Boylan <ross@biostat.ucsf.edu> Signed-off-by: NeilBrown <neilb@suse.de>
* Assemble: ensure that <ignore>d arrays are not auto-assembled.NeilBrown2012-11-22
| | | | | | | | | | | It isn't enough to simply not assemble arrays found to be called <ignore>, as the final stage of auto-assemble doesn't check for names in mdadm.conf. So add a check to Assemble, similar to the check in Incremental() Reported-by: Mike Frysinger <vapier@gentoo.org> Signed-off-by: NeilBrown <neilb@suse.de>
* Assemble: fix call to wait_forNeilBrown2012-11-20
| | | | | | | | | Recent patch closed 'mdfd' before calling wait_for, which means it doesn't work. Put the close back in the right place. Signed-off-by: NeilBrown <neilb@suse.de>
* Assemble: Fix critical-section-recovery when assembling a growing array.NeilBrown2012-11-20
| | | | | | | | | | | commit aacb2f816afbddf56c406039b8e2e6c0dbc8a8a0 Assemble: add support for replacement devices. broke the restoring of the 'critical section' because it messed up the list of file descriptors passed to Grow_restart. Put it back the way it should be. Signed-off-by: NeilBrown <neilb@suse.de>
* IMSM - allow assembling any imsm array even without OROM.NeilBrown2012-11-20
| | | | | | | | | | | | | | | | It is important to check for compatibility with 'platform' or Option ROM when creating or changing and array. However there is no real need when simply assembling the array. On some systems there are situations where the platform information is not available. e.g. on some UEFI systems, UEFI is not available during 'kdump' handling. This makes it impossible to assemble an IMSM array to receive the dump. So remove the requirements that the platform be visible to assemble an IMSM array. Signed-off-by: NeilBrown <neilb@suse.de>
* Assemble: add support for replacement devices.NeilBrown2012-10-24
| | | | | | | Need to possibly collect 2 devices for each slot, and original and a replacement. Signed-off-by: NeilBrown <neilb@suse.de>
* Assemble.c - re-indent file.NeilBrown2012-10-22
| | | | | | Make sure spaces and indents are consistent. Signed-off-by: NeilBrown <neilb@suse.de>
* Assemble: remove support for assembling arrays with ancient kernel.NeilBrown2012-10-22
| | | | | | | | Using "START_ARRAY" ioctl never really worked reliably, was removed a decade ago, and just clutters the code. So remove it. Signed-off-by: NeilBrown <neilb@suse.de>
* Assemble: split out "start_array()" function.NeilBrown2012-10-22
| | | | | | | | | | | Apart from code movement, there is a small functional change here. If the array is not successfully started, it is stopped. Previously we would sometimes leave the array in a partially-assembled but inactive state. This just causes confusion. "--incremental" can be used to partially assemble arrays. Signed-off-by: NeilBrown <neilb@suse.de>
* Assemble: split out force_array()NeilBrown2012-10-18
| | | | | | | force_array() is called if --force was specified to update and metadata necessary to make the array assemble. Signed-off-by: NeilBrown <neilb@suse.de>
* Assemble: split out load_devices() functionality.NeilBrown2012-10-18
| | | | | | | | Once we have found the devices we want, we need to load the metadata from them and store it. This new function extracts that functionality out of Assemble() Signed-off-by: NeilBrown <neilb@suse.de>
* Assemble: split out select_devices function.NeilBrown2012-10-18
| | | | | | | | | Assemble() is way too big. This patch starts cleaning it up by pulling the 'select_devices()' function. This examines the device to make sure they all belong to one array, or select those that do (depending on exact use case). Signed-off-by: NeilBrown <neilb@suse.de>
* Fix up interactions between --assemble and --incrementalNeilBrown2012-10-10
| | | | | | | | | | | | | | If --incremental has partly assembled an array and --assemble is asked to assemble it, the just finds remaining devices and makes a new array. Not good. So: 1/ modify locking policy so that assemble can be sure that no --incremental is running once it locks the map file 2/ Assemble() checks the map file for a duplicate and adds to that array instead of creating a new one. Signed-off-by: NeilBrown <neilb@suse.de>
* New RESHAPE_NO_BACKUP flag to track when backup action is needed.NeilBrown2012-10-04
| | | | | | | | | | | | Some arrays (raid10) never need a backup file, so during assembly we can avoid the whole Grow_continue check in that case. Achieve this using a flag set by the metadata handler. Also get "mdadm -I" to fail if a backup process would be needed. It currently does fail as the kernel rejects things, but it is nicer to have this explicit. Signed-off-by: NeilBrown <neilb@suse.de>
* Assemble: don't leak memory with fdlist.NeilBrown2012-07-09
| | | | | | We should free fdlist when finished with it. Signed-off-by: NeilBrown <neilb@suse.de>
* Change Incremental and related functions to take struct contextNeilBrown2012-07-09
| | | | Signed-off-by: NeilBrown <neilb@suse.de>
* Convert Assemble() to take a context rather than a list of options.NeilBrown2012-07-09
| | | | 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>
* 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>