summaryrefslogtreecommitdiff
Commit message (Collapse)AuthorAge
* Create: cleanup/unify default geometry handlingDan Williams2010-11-23
| | | | | | | | Support metadata specific level, layout and chunksize defaults. Kill an uneeded superswitch methods ahead of adding more for the reshape case. Signed-off-by: Dan Williams <dan.j.williams@intel.com> 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>
* Grow: fix check for raid6 layout normalizationDan Williams2010-11-23
| | | | | | | | If the user does not specify a layout, don't skip asking about retaining the non-standard raid6 layout which may be implicitly changed. Signed-off-by: Dan Williams <dan.j.williams@intel.com> Signed-off-by: NeilBrown <neilb@suse.de>
* Assemble: fix assembly in the delta_disks > max_degraded caseDan Williams2010-11-23
| | | | | | | | | | | | Incremental assembly works on such an array because the kernel sees the disk as in-sync and that the array is reshaping. Teach Assemble() the same assumptions. This is only needed on kernels that do not initialize ->recovery_offset when activating spares for reshape. Signed-off-by: Dan Williams <dan.j.williams@intel.com> Signed-off-by: NeilBrown <neilb@suse.de>
* Grow: mark some functions staticDan Williams2010-11-23
| | | | | | | | Going through the Grow api found some local routines that could be marked static. Signed-off-by: Dan Williams <dan.j.williams@intel.com> Signed-off-by: NeilBrown <neilb@suse.de>
* Manage: allow manual control of external raid0 readonly flagDan Williams2010-11-23
| | | | | | | | | mdadm --readwrite <subarray> will clear the external readonly flag ('-' to '/'), but only for redudant arrays. Allow raid0 arrays as well so the user has a simple helper to control this flag. Signed-off-by: Dan Williams <dan.j.williams@intel.com> Signed-off-by: NeilBrown <neilb@suse.de>
* block monitor: freeze spare assignment for external arraysDan Williams2010-11-23
| | | | | | | | | | | | | | | | | | | | | | | In order to support reshape and atomic removal of spares from containers we need to prevent mdmon from activating spares. In the reshape case we additionally need to freeze sync_action while the reshape transaction is initiated with the kernel and recorded in the metadata. When reshaping a raid0 array we need to freeze the array *before* it is transitioned to a redundant raid level. Since sync_action does not exist at this point we extend the '-' prefix of a subarray string to flag mdmon not to activate spares. Mdadm needs to be reasonably certain that the version of mdmon in the system honors this 'freeze' indication. If mdmon is not already active then we assume the version that gets started is the same as the mdadm version. Otherwise, we check the version of mdmon as returned by the extended ping_monitor() operation. This is to catch cases where mdadm is upgraded in the filesystem, but mdmon started in the initramfs is from a previous release. Signed-off-by: Dan Williams <dan.j.williams@intel.com> Signed-off-by: NeilBrown <neilb@suse.de>
* Provide a mdstat_ent to subarray helperDan Williams2010-11-23
| | | | | | | ...before introducing another open coded instace of this conversion. Signed-off-by: Dan Williams <dan.j.williams@intel.com> Signed-off-by: NeilBrown <neilb@suse.de>
* Assemble: get content before testing it.NeilBrown2010-11-23
| | | | | | | | | When checking that a container matches the required uuid, we need to call 'getinfo_super' before we have a 'content' to test. Reported-by: "Czarnowska, Anna" <anna.czarnowska@intel.com> Signed-off-by: NeilBrown <neilb@suse.de>
* Monitor: check spare group is non-NULL before adding to domain listNeilBrown2010-11-23
| | | | | | | ... otherwise we crash. Reported-by: "Labun, Marcin" <Marcin.Labun@intel.com> Signed-off-by: NeilBrown <neilb@suse.de>
* Policy is aware of metadata disk's controller domains.Marcin Labun2010-11-22
| | | | | | | | | | | | | | | | | Platform (metadata) domain let the metadata handlers differentiate disk domains based on controllers that the disk belongs to. Platform domain is sub-domain inside user specified domain in mdadm.conf configuration files inheriting all parameters from it. The metadata domain name is used disk domain matching functions. The disk with the same metadata domain name belong to the same metadata domain. New metadata handler is added that retrieves platform domain string based on disk path: const char *(*get_disk_controller_domain)(const char *path); Signed-off-by: Marcin Labun <marcin.labun@intel.com> Signed-off-by: NeilBrown <neilb@suse.de>
* Monitor: Allow metadata to set minimum size for spare to migrate in.Anna Czarnowska2010-11-22
| | | | | Signed-off-by: Anna Czarnowska <anna.czarnowska@intel.com> Signed-off-by: NeilBrown <neilb@suse.de>
* Monitor: teach spare migration about containersNeilBrown2010-11-22
| | | | | | | | | | When trying to move a spare, move to the container of a degraded array, not to the array itself. And don't try to move from a subarray, only from a native or container array. And don't move from a container which contains degraded subarrays. Signed-off-by: NeilBrown <neilb@suse.de>
* Monitor: policy based spare migration.NeilBrown2010-11-22
| | | | | | | | | | | Rather than only migrating between arrays with the same spare_group, we now migrate based on domains set in the policy. In order for spare_group to continue to work, we treat it as a domain of the destination array, and a domain of any device we might remove from a source array. Signed-off-by: NeilBrown <neilb@suse.de>
* Monitor: split out check_donorNeilBrown2010-11-22
| | | | | | | | Checking compatibility between arrays for spare migration is going to become a little more complicated, so split it out into a separate function. Signed-off-by: NeilBrown <neilb@suse.de>
* Monitor: split out move_spare in spare migration.NeilBrown2010-11-22
| | | | | | This is a simple refactoring with no functionality change. Signed-off-by: NeilBrown <neilb@suse.de>
* Monior: create struct for holding alert info.NeilBrown2010-11-22
| | | | | | | Rather than passing mailaddr, mailfrom, cmd, dosyslog around in argument lists, create a structure to hold them all. Signed-off-by: NeilBrown <neilb@suse.de>
* Monitor: use calloc rather than mallocNeilBrown2010-11-22
| | | | | | | calloc zeros the memory allocated, which is safer, particularly as we add more things to struct state. Signed-off-by: NeilBrown <neilb@suse.de>
* Monitor: minor optimisation to spare migration.NeilBrown2010-11-22
| | | | | | | Only try spare migration if we know that at least one array is degraded. Signed-off-by: NeilBrown <neilb@suse.de>
* imsm: create mdinfo list of disks in a container from supertypeAnna Czarnowska2010-11-22
| | | | | | | | | | | | | | | | | | | If getinfo_super is called on a container supertype we only get information on first disk. As a parameter it uses reference to preallocated mdinfo structure. Amending getinfo_super to return full list of disks would require ammending all previous calls and subsequently freeing memory allocated for mdinfo list. Function container_content that returns a mdinfo list is written specifically for assembly, performing actions not needed to just fill mdinfo. It also does not include spares so is unsuitable. As an alternative a new function getinfo_super_disks is created to obtain information about all disks states in array. Existing function sysfs_free is used to free memory allocated by getinfo_super_disks. Signed-off-by: Anna Czarnowska <anna.czarnowska@intel.com> Signed-off-by: Marcin Labun <marcin.labun@intel.com> Signed-off-by: NeilBrown <neilb@suse.de>
* Monitor: link containers with subarrays in statelistMarcin Labun2010-11-22
| | | | | | | | | Each containers has list of its subarrays. Each subarray has back link to its parent container. Signed-off-by: Marcin Labun <marcin.labun@intel.com> Signed-off-by: Anna Czarnowska <anna.czarnowska@intel.com> Signed-off-by: NeilBrown <neilb@suse.de>
* Break Monitor into smaller functions.NeilBrown2010-11-22
| | | | | | | Monitor() has become way too big. Break it up into multiple smaller functions that are all called from the main loop. Signed-off-by: NeilBrown <neilb@suse.de>
* Monitor: track metadata type or parent/container of arrays.NeilBrown2010-11-22
| | | | | | | | | | For subarrays, record the devid of the parent. For others arrays, record the metadata type. This will be used in a subsequent patch to link related arrays together and allow spare migration between containers. Signed-off-by: NeilBrown <neilb@suse.de>
* Monitor: include containers in scan modeAnna Czarnowska2010-11-22
| | | | | Signed-off-by: Marcin Labun <marcin.labun@intel.com> Signed-off-by: NeilBrown <neilb@suse.de>
* Monitor: avoid skipping checks on external arraysNeilBrown2010-11-22
| | | | | | | | utime is not correct for external metadata so we must not risk the observed time ever matching the old time. Reported-by: Anna Czarnowska <anna.czarnowska@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>
* Monitor: set err on arrays not in mdstatAnna Czarnowska2010-11-22
| | | | | | | | | | | | | | | mse can be NULL when the array was not in mdstat when we read it but existed in statelist and was recreated after reading mdstat. In this case we set err as we can't get full update on this array this time. If the same array is given twice in command line it appears twice in statelist. The first one will mark mse->devnum=INT_MAX so the second one can't find mse. We set err on the second one as it's not needed. Also if it becomes degraded we would look for spares twice for the same array. Signed-off-by: Anna Czarnowska <anna.czarnowska@intel.com> Signed-off-by: NeilBrown <neilb@suse.de>
* Util: get device size from idAnna Czarnowska2010-11-22
| | | | | Signed-off-by: Anna Czarnowska <anna.czarnowska@intel.com> Signed-off-by: NeilBrown <neilb@suse.de>
* Add action=spare-same-slot policy.NeilBrown2010-11-22
| | | | | | | | | | | | | | | | | | | | | | When "mdadm -I" is given a device with no metadata, mdadm tries to add it as a 'spare' somewhere based on policy. This patch changes the behaviour in two ways: 1/ If the device is at a 'path' where a previous device was removed from an array or container, then we preferentially add the spare to that array or container. 2/ Previously only 'bare' devices were considered for adding as spares. Now if action=spare-same-slot is active, we will add non-bare devices, but *only* if the path was previously in use for some array, and the device will only be added to that array. Based on code From: Przemyslaw Czarnowski <przemyslaw.hawrylewicz.czarnowski@intel.com> Signed-off-by: Przemyslaw Czarnowski <przemyslaw.hawrylewicz.czarnowski@intel.com> Signed-off-by: NeilBrown <neilb@suse.de>
* incr/spare: recheck allowed action for each metadata.NeilBrown2010-11-22
| | | | | | | | | The current act_spare tests only test if it is allowed for some metadata. As we check each array or partitioning type, we need to double-check that sparing is allowed for that array or partitioning type. Signed-off-by: NeilBrown <neilb@suse.de>
* Incr/spare: make sure failure to identify metadata if handled gracefully.NeilBrown2010-11-22
| | | | Signed-off-by: NeilBrown <neilb@suse.de>
* Incr: fix up return value in try_spareNeilBrown2010-11-22
| | | | | | | We only want to try partition_try_spare if array_try_spare failed. If it succeeded, there is nothing more to try. Signed-off-by: NeilBrown <neilb@suse.de>
* Factor out is_bare test.NeilBrown2010-11-22
| | | | | | | | | | Instead of open coding (and using horrible gotos), make this a separate function. Also fix the check for end of device - SEEK_END doesn't work on block devices. Signed-off-by: NeilBrown <neilb@suse.de>
* extension of IncrementalRemove to store location (path-id) of removed devicePrzemyslaw Czarnowski2010-11-22
| | | | | | | | | | | | | | | | If the disk is taken out from its port this port information is lost. Only udev rule can provide us with this information, and then we have to store it somehow. This patch adds writing 'cookie' file in /dev/.mdadm/failed-slots directory in form of file named with value of f<path-id> containing the metadata type and uuid of the array (or container) that the device was a member of. The uuid is in exactly the same format as in the mapfile. FAILED_SLOTS_DIR constant has been added to hold the location of cookie files. Signed-off-by: Przemyslaw Czarnowski <przemyslaw.hawrylewicz.czarnowski@intel.com> Signed-off-by: NeilBrown <neilb@suse.de>
* Teach IncrementalRemove about containers.NeilBrown2010-11-22
| | | | | | | When we -I -R a device in a container, we must first fail it from each member array before we can remove it from the container. Signed-off-by: NeilBrown <neilb@suse.de>
* Update of udev rules to support IMSM devicesPrzemyslaw Czarnowski2010-11-22
| | | | | | | | ID_FS_TYPE for IMSM members is set to isw_raid_member, so they must also be handled in udev. Signed-off-by: Przemyslaw Czarnowski <przemyslaw.hawrylewicz.czarnowski@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 loaded_containerNeilBrown2010-11-22
| | | | | | | | This field is now only set, never used. So remove it. Signed-off-by: NeilBrown <neilb@suse.de>
* imsm: always calculate container_enough in getinfo_super_imsmNeilBrown2010-11-22
| | | | | | | | We are about to lose the loaded_container field, and we don't really need to use it to protect the calculation of container_enough. So drop the test. Signed-off-by: NeilBrown <neilb@suse.de>
* Replace various load_super calls with load_containerNeilBrown2010-11-22
| | | | | | | When we call load_super expecting to find a container, we now just call load_container directly. Signed-off-by: NeilBrown <neilb@suse.de>
* Assemble: use load_containerNeilBrown2010-11-22
| | | | | | | | | | Separate the load_container call from the load_super call, and use different validity tests as appropriate. Add some general code tidying and a bit of indent change to make structure a little clearer. Signed-off-by: NeilBrown <neilb@suse.de>
* Add must_be_container helper.NeilBrown2010-11-22
| | | | | | | This checks a block device to see if it could be a container, and in particular cannot be a member device. Signed-off-by: NeilBrown <neilb@suse.de>
* Assemble: turn next_member goto loop into a for loop.NeilBrown2010-11-22
| | | | | | It becomes much clearer what is happening now. Signed-off-by: NeilBrown <neilb@suse.de>
* Assemble: simplify the handling of is_member_busy.NeilBrown2010-11-22
| | | | | | | | | This is somewhat inconsistent with the last member of a container getting special handling. Just simplify it so the code seems to make sense and important is easy to follow. Signed-of-by: NeilBrown <neilb@suse.de>
* Assemble: remove the skip variable.NeilBrown2010-11-22
| | | | | | it seems we don't need it any more Signed-off-by: NeilBrown <neilb@suse.de>
* Assemble: merge 'member' test into ident_matches.NeilBrown2010-11-22
| | | | | | | This is a more sensible place for it, gathering all the tests together. Signed-off-by: NeilBrown <neilb@suse.de>
* Assemble: change 'skip' label to a variable.NeilBrown2010-11-22
| | | | | | | This gets rid of some gotos which makes the code flow a bit more clear. 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>
* Assemble: contract next_member loop.NeilBrown2010-11-22
| | | | | | | | | We have a 'goto next_member' loop which is rather spread-out and confusing. Recent refactoring make it possible to contract that loop significantly. Signed-off-by: NeilBrown <neilb@suse.de>
* Assemble: merge to large 'if' statements.NeilBrown2010-11-22
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | In assemble, we see (inside a 'for' loop): if (condition) { lots of stuff } else something small thing if (same condition) { lots more stuff break; } where 'condition' cannot be changed in the middle. So simplify this to if (condition) { lots of stuff small thing lots more stuff break; } something small thing which duplicates the small thing, but provides much conceptual simplicity. Signed-off-by: NeilBrown <neilb@suse.de>