summaryrefslogtreecommitdiff
path: root/Manage.c
Commit message (Collapse)AuthorAge
* Manage: fix removal of non-existent devices.NeilBrown2014-08-11
| | | | | | | | | | | "--remove detached" and others stopped working a while back when I refactored some code. For 'remove' and 'fail', the device may not exist so if it is "MM:mm", (e.g. added by "detached"), just parse out the numbers. Reported-by: Killian De Volder <killian.de.volder@megasoft.be> Signed-off-by: NeilBrown <neilb@suse.de>
* Manage: simplify `rdev` handling in Manage_subdevs.NeilBrown2014-08-11
| | | | | | | | | The only use 'struct stat stb' to get the 'rdev', and sometimes we don't even use 'stat'. So make 'rdev' a stand-alone variable, and only declare stb' when we actually need it. Signed-off-by: NeilBrown <neilb@suse.de>
* Two small fixes related to enough()NeilBrown2013-12-05
| | | | | | | | | 1/ enough_fd doesn't use avail_disks any more, so discard it. 2/ Manage_Add increments 'found' at the wrong place, so it can waste time before calling enough(). Signed-off-by: NeilBrown <neilb@suse.de>
* Add support for --add-spareNeilBrown2013-10-31
| | | | | | | | | | --add-spare is like --add, but a --re-add is never attempted. So it is equivalent to two separate commands: --zero-metadata --add 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>
* Manage.c: fix small memory leakLukasz Dorau2013-09-10
| | | | | | | 'avail' is dynamically allocated, so it should be freed. Signed-off-by: Lukasz Dorau <lukasz.dorau@intel.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>
* Change "mdadm --run" to use the same code as "mdadm --IRs".NeilBrown2013-08-26
| | | | | | | | | | | Current "mdadm --run /dev/mdX" will not handle external metadata properly. mdmon won't be started etc. So use the code from "mdadm -IRs" instead - that already does all the right things. Reported-by: Francis Moreau <francis.moro@gmail.com> Signed-off-by: NeilBrown <neilb@suse.de>
* Fix bug with adding to 0.90 arrayNeilBrown2013-08-14
| | | | | | | | | commit 7ccc4cc4fc6889680bbe4ec673cab3f6aa49aad3 Manage: remove call to validate_geometry. used entirely the wrong number for "4TB" !! Signed-off-by: NeilBrown <neilb@suse.de>
* Manage: remove call to validate_geometry.NeilBrown2013-07-30
| | | | | | | | | | | | | | This call to validate_geometry is really rather gratuitous. It is purely about the fact that super0 cannot use more than 4TB. So just make it an explicit test - less confusing that way. With this, validate_geometry is only called from Create, which makes it easier to reason about. Also validate_geometry is now never passed NULL for the 'chunk' parameter, so we can remove those annoying tests for NULL. Signed-off-by: NeilBrown <neilb@suse.de>
* Manage: fix typo in error for "--with" handlingNeilBrown2013-07-24
| | | | Signed-off-by: NeilBrown <neilb@suse.de>
* Stop: fix up synchronising end of reshape to good boundary.NeilBrown2013-07-10
| | | | | | | | | | | If we stop too soon after reshape starts (probably only during testing), we can get confused by the status of the reshape. If that might be happening - sleep a bit longer. Also allow for reshape going unusually slowly (again, probably only during testing). Signed-off-by: NeilBrown <neilb@suse.de>
* Stop: improve synchronising of reshape with whole stripes.NeilBrown2013-07-02
| | | | | | | | | | | | It is possible for 'sync_completed' to be further ahead than we deduced from 'reshape_position'. However we cannot read it while the array is frozen, so it is hard to know. Once that array is unfrozen, check and if sync_completed is ahead of 'sync_max', push 'sync_max' well ahead if 'sync_completed' so it will all synchronise up properly. Signed-off-by: NeilBrown <neilb@suse.de>
* Manage: check alignment when stopping an array undergoing reshape.NeilBrown2013-07-01
| | | | | | | | | | | | | To be able to revert-reshape of raid4/5/6 which is changing the number of devices, the reshape must has been stopped on a multiple of the old and new stripe sizes. The kernel only enforces the new stripe size multiple. So we enforce the old-stripe-size multiple by careful use of "sync_max" and monitoring "reshape_position". 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>
* Manage: split Manage_runstop into Manage_run and Manage_stopNeilBrown2013-06-19
| | | | | | | The two branches have virtually nothing in common, so it is simpler if they are separate. Signed-off-by: NeilBrown <neilb@suse.de>
* Change some fprintf(stderrs to cont_err()NeilBrown2013-05-21
| | | | Signed-off-by: NeilBrown <neilb@suse.de>
* Remove open-coded use_udev().NeilBrown2013-05-13
| | | | | | | Manage_runstop has an open-coded version of use_udev() which is no longer correct. So make it use use_udev() explicitly. Signed-off-by: NeilBrown <neilb@suse.de>
* Manage: support --fail set-X and --remove set-XNeilBrown2013-05-13
| | | | | | | | A RAID10 array can have 'sets' of devices which are reported by --detail. They can now be collectively failed or removed. Signed-off-by: NeilBrown <neilb@suse.de>
* Manage_runstop: call flush_mdmon if O_EXCL fails on stopping mdmon array.NeilBrown2013-04-22
| | | | | | | | | When stopping an mdmon array, at reshape might be being aborted which inhibets O_EXCL. So if that is possible, call flush_mdmon to make sure mdmon isn't still busy. Reported-by: Pawel Baldysiak <pawel.baldysiak@intel.com> Signed-off-by: NeilBrown <neilb@suse.de>
* Ensure mddev_dev struct always zeroed on allocation.NeilBrown2013-03-05
| | | | | | | | There are a number of fields which should not be left uninitialised. e.g. attempt_re_add can get confused if ->writemostly is not set correctly. Signed-off-by: NeilBrown <neilb@suse.de>
* Enhance incremental removal.NeilBrown2013-03-05
| | | | | | | | | | | | | | | | | | | | | | | | | When asked to incrementally-remove a device, try marking the array read-auto first. That will delay recording the failure in the metadata until it is really relevant. This way, if the device are just unplugged when the array is not really in use, the metadata will remain clean. If marking the default as faulty fails because it is EBUSY, that implies that the array would be failed without the device. As the device has (presumably gone) - that means the array is dead. So try to stop it. If that fails because it is in use, send a uevent to report that it is gone. Hopefully whoever mounted it will now let go. This means that if you plug in some devices and they are auto-assembled, then unplugging them will auto-deassemble relatively cleanly. To be complete, we really need the kernel to disassemble the array after the last close somehow. Maybe if a REMOVE has failed and a STOP has failed and nothing else much has happened, it could safely stop the array on last close. 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>
* Manage: Add support for --re-add faultyNeilBrown2012-11-28
| | | | | | | | | mdadm /dev/mdXX --re-add faulty will identify any faulty devices in the array, remove them, and --re-add them. Signed-off-by: NeilBrown <neilb@suse.de>
* Fix "--remove faulty" and similar commands.NeilBrown2012-11-28
| | | | | | | | | | | A recent change to improve error messages for subdev management broken all use cases were device names like %d:%d were used. Re-arrange the code again so we use dev_open first - which understands those names - and then only try 'stat' if that failed. The important thing is to base the 'Cannot find' message on the result of 'stat', not on the result of 'open'. Signed-off-by: NeilBrown <neilb@suse.de>
* Manage: improve error message when given a non-block device.NeilBrown2012-10-24
| | | | | | | | | | As dev_open uses O_DIRECT it will fail on directories and such. So we never get to report that it isn't a block device. So do a 'stat' earlier and if it is a block device, report the error there. Signed-off-by: NeilBrown <neilb@suse.de>
* Add support for --replace and --withNeilBrown2012-10-23
| | | | | | | | | --replace can be used to replace a device without completely failing it. Once the replacement completes the device will be failed. --with can indicate which of several spares to use. Signed-off-by: NeilBrown <neilb@suse.de>
* Allow data-offset to be specified per-device for createNeilBrown2012-10-04
| | | | | | | | | mdadm --create /dev/md0 .... /dev/sda1:1024 /dev/sdb1:2048 ... The size is in K unless a suffix: K M G is given. The suffix 's' means sectors. Signed-off-by: NeilBrown <neilb@suse.de>
* Add data_offset arg to ->validate_geometry.NeilBrown2012-10-04
| | | | | | | This is needed to return correct available size. It isn't really used yet. Signed-off-by: NeilBrown <neilb@suse.de>
* Add data_offset arg to ->avail_sizeNeilBrown2012-10-04
| | | | | | | This is currently only useful for 1.x metadata and will allow an explicit --data-offset request on command line. Signed-off-by: NeilBrown <neilb@suse.de>
* Manage: fix checks for removal from a container.NeilBrown2012-09-24
| | | | | | | | | | | | | | | | | | We must only remove from a container if the device isn't a member of any member array. To check we look at the 'holders' directory in sysfs. We currently skip that check if ->devname is "detached", however that can never be true since the change that introduced add_detached(). Also sysfs_unique_holder returns status in 'errno' which isn't entirely safe as e.g. closedir() is probably allowed to clear it. So make sysfs_unique_holder return an unambigious value, and us it to decide what to report. Signed-off-by: NeilBrown <neilb@suse.de>
* Manage: zero metadata before adding to 'external' array.NeilBrown2012-08-15
| | | | | | | | | | 'external' arrays don't support --re-add yet so old metadata is no value, and 'ddf' gets confusing in mdmon if old metadata is found. So for now, zero out any old metadata found before adding a spare to an externally-managed array. Reported-by: Albert Pauw <albert.pauw@gmail.com> Signed-off-by: NeilBrown <neilb@suse.de>
* Manage.c: fix make everything compilation errorLukasz Dorau2012-08-14
| | | | | | | | | | This patch fixes the following make everything compilation error: Manage.c: In function ‘Manage_add’: Manage.c:538: error: ‘dev_st’ may be used uninitialized in this function make: *** [mdadm.Os] Error 1 Signed-off-by: Lukasz Dorau <lukasz.dorau@intel.com> Signed-off-by: NeilBrown <neilb@suse.de>
* Manage_subdevs: factor out Manage_deleteNeilBrown2012-08-13
| | | | | | Now Manage_subdevs is now small enough to be manageable. Signed-off-by: NeilBrown <neilb@suse.de>
* Manage_subdevs: split most of 'add' handling into Manage_add.NeilBrown2012-08-13
| | | | | | | This makes Manage_subdevs smaller, and makes the error-path handling for Manage_add much cleaner and probably less buggy. Signed-off-by: NeilBrown <neilb@suse.de>
* Manage: split out attempt_re_add.NeilBrown2012-08-13
| | | | | | | The indent level is way too deep here, and this is a well defined task, so split it out to a separate function. Signed-off-by: NeilBrown <neilb@suse.de>
* Manage_subdev: give 'st' a better name and narrower focus.NeilBrown2012-08-13
| | | | | | | | | | | | 'st' is use to examine the metadata on the device being added to see if a 're-add' is possible. However it is loaded long before the 're-add' attempt is made. So move the 'load_super' closer to were it is used - allowing us to discard a number of 'free_super' call - and rename it to 'dev_st' to emphasize that it related to the current device. Signed-off-by: NeilBrown <neilb@suse.de>
* Manage: minor cosmetic fixes.NeilBrown2012-08-13
| | | | Signed-off-by: NeilBrown <neilb@suse.de>
* Manage: simplify device searches in Manage_subdevsNeilBrown2012-07-09
| | | | | | | | | | | | We currently have rather hard-to-follow loop to iterate through all the matches for 'missing' or 'faulty' or 'detached'. Simplify it by creating a list of possible devices for each of those and splicing the new list into the device list. This removes the need for 'jnext' and 'next' and various other hacks. Signed-off-by: NeilBrown <neilb@suse.de>
* Convert 'quiet' to 'not verbose' in various places.NeilBrown2012-07-09
| | | | | | | | If we change some functions to accept 'verbose', where <0 means to be quiet, in place of 'quiet', then we will be able to merge 'quiet' and 'verbose' together for simplicity. 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>
* Relax restrictions on when --add is permitted.NeilBrown2012-04-18
| | | | | | | | | | | | | | | The restriction that --add was not allowed on a device which looked like a recent member of an array was overly harsh. The real requirement was to avoid using --add when the array had failed, and the device being added might contain necessary information which can only be incorporated by stopping and re-assembling with --force. So change the test to reflect the need. Reported-by: Doug Ledford <dledford@redhat.com> Signed-off-by: NeilBrown <neilb@suse.de>
* Raid limit of 1024 when scanning for devices.NeilBrown2012-04-18
| | | | | | | | When we can for devices using GET_DISK_INFO we currently limit to 1024. But some arrays can have more than this. So raise it to 4096 and make the constant a #define. Signed-off-by: NeilBrown <neilb@suse.de>
* Fix typo: wan -> wantNeilBrown2012-04-04
| | | | Signed-off-by: NeilBrown <neilb@suse.de>
* Manage: freeze recovery while adding multiple devices.NeilBrown2012-03-22
| | | | | | | | If the kernel supports it, freeze recovery over multiple adds, so that they can all be added to the array at the same time and be recovered in parallel. Signed-off-by: NeilBrown <neilb@suse.de>
* Manage: replace 'return 1' with 'goto abort'.NeilBrown2012-03-22
| | | | | | This will allow exit processing in next patch Signed-off-by: NeilBrown <neilb@suse.de>
* Manage: allow --re-add to failed array.NeilBrown2012-03-07
| | | | | | | | | | | If both "legs" of a RAID1 (or equivalent in RAID10) fail, then one of the becomes available again it maybe appropriate to re-add the failed device(s). So remove the restriction that an array must has 'enough' devices before being re-added, and if there is no-where to read a superblock from for matching, then assume the kernel will do necessary checks. Signed-off-by: NeilBrown <neilb@suse.de>
* Manage_ro(): Check pointer rather than dereferencing itJes Sorensen2011-11-03
| | | | | Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com> Signed-off-by: NeilBrown <neilb@suse.de>