summaryrefslogtreecommitdiff
path: root/Assemble.c
Commit message (Collapse)AuthorAge
* Monitor reshaped arrayAdam Kwolek2011-10-05
| | | | | | | | | Reshape can be run for monitored arrays only /external metadata case/. Before reshape can be executed, make sure that just starter array/container is monitored. If not, run mdmon for it. Signed-off-by: Adam Kwolek <adam.kwolek@intel.com> Signed-off-by: NeilBrown <neilb@suse.de>
* Add recovery blocked field to mdinfoAdam Kwolek2011-10-05
| | | | | | | | | | | | | | | | | | | When container is assembled while reshape is active on one of its member whole container can be required to be blocked from monitoring. For such purpose field recovery blocked is added to mdinfo structure. When metadata handler finds active reshape in container it should set recovery_blocked field to disable whole container monitoring during reshape. For arrays that doesn't use containers, recovery_blocked field has the same value as reshape_active field e.g. super0/1. In fact,recovery is blocked during reshape for such arrays. For ddf, metadata handler doesn't set reshape_active field, so recovery_blocked is not set also. 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>
* Move restore backup code to functionAdam Kwolek2011-09-21
| | | | | | | | Reshape backup should be able to be restored during reshape continuation also. To reuse already existing code it is moved to function. Signed-off-by: Adam Kwolek <adam.kwolek@intel.com> Signed-off-by: NeilBrown <neilb@suse.de>
* FIX: Memory leak during AssemblyAdam Kwolek2011-09-21
| | | | | | | | For fdlist pointer allocated in assemble_container_content() function, free() is never called. This patch fixes this memory leak. Signed-off-by: Adam Kwolek <adam.kwolek@intel.com> Signed-off-by: NeilBrown <neilb@suse.de>
* Don't index past the end of 'best' array in Assemble.NeilBrown2011-06-17
| | | | | | | | The 'best' array only has 'bestcnt' entries allocated, so 'i' should always be "< bestcnt", not "<= bestcnt". Reported-by: "Lawrence, Joe" <Joe.Lawrence@stratus.com> Signed-off-by: NeilBrown <neilb@suse.de>
* Add reshape restart support for external metadataAdam Kwolek2011-06-08
| | | | | | | | | | | | Patch introduces support for reshape process restart for external metadata using metadata specific data handling methods. It introduces recover_backup() function that restores array to stable state It is equivalent to Grow_restart() functionality for native metadata. Signed-off-by: Maciej Trela <maciej.trela@intel.com> Signed-off-by: Adam Kwolek <adam.kwolek@intel.com> Signed-off-by: Krzysztof Wojcik <krzysztof.wojcik@intel.com> Signed-off-by: NeilBrown <neilb@suse.de>
* getinfo_super now clears the 'info' structure before filling it in.NeilBrown2011-06-08
| | | | | | | | | | | | | | Some code currently clears 'info' before calling getinfo_super, some code doesn't. To be consistent, change it so no caller ever clears 'info', but ever getinfo_super function must clear it. Note that ->raid_disk may be meaningful if that 'map' is passed non-NULL. In that case it is copied out before the structure is zeroed. Signed-off-by: NeilBrown <neilb@suse.de>
* FIX: Count correctly added devicesAdam Kwolek2011-04-18
| | | | | | | | | When array is in reshape state raid_disks field contains final disks number. To know how many disks were added, disk.raid_disk index has to be compared against old disk number computed using delta_disks. Signed-off-by: Adam Kwolek <adam.kwolek@intel.com> Signed-off-by: NeilBrown <neilb@suse.de>
* Assemble: improve efficacy of -Af in assembling degraded dirty arrays.NeilBrown2011-03-23
| | | | | | | | | | | | If a degraded dirty array has some superblocks which are clean and others that are dirty, and the dirty ones are newer by precisely '1' in the event count, then the current code to force the array to be clean will not work. We need to make sure to find a superblock with most recent event count and force that one to be 'clean'. Reported-by: A J Wyborny <ajwyborny@gmail.com> Signed-off-by: NeilBrown <neilb@suse.de>
* FIX: ping_monitor() usage causes memory leaksAdam Kwolek2011-03-18
| | | | | | | | | | When for ping_monitor() input devnum2devname() is used, received string pointer should be passed to free() for memory release. It is not made in several places. This use case should have function to avoid memory leak. Signed-off-by: Adam Kwolek <adam.kwolek@intel.com> Signed-off-by: NeilBrown <neilb@suse.de>
* Remove incorrect use of open_devNeilBrown2011-03-10
| | | | | | | open_dev can only be used for md array. To open an arbitrary device, dev_open must be used. Signed-off-by: NeilBrown <neilb@suse.de>
* FIX: Make expansion counter usableAdam Kwolek2011-03-10
| | | | | | | | | | Currently whole array geometry is set in sysfs_set_array(), so none of disks (even for expansion) should fail during sysfs_add_disk() Due to this expansion counter should be used for reshaped array when disk slot is bigger than number of disks in array. Signed-off-by: Adam Kwolek <adam.kwolek@intel.com> Signed-off-by: NeilBrown <neilb@suse.de>
* FIX: Block reshaped array monitoringAdam Kwolek2011-03-10
| | | | | | | | | | | When array under reshape is assembled it has to be disabled from monitoring as soon as possible. It can occur that this is i.e second array in container and mdmon is loaded already. Lack of blocking monitoring can cause change array state to active, and reshape continuation will be not possible. Signed-off-by: Adam Kwolek <adam.kwolek@intel.com> Signed-off-by: NeilBrown <neilb@suse.de>
* Run Grow_restart/Grow_continue when assembling the content of a container.NeilBrown2011-03-08
| | | | | | | | | | | | | As containers can now grow, we need to use both Grow_restart (to replay any backup-file) and Grow_continue when assembling the content of a container. Note that we don't pass a backup-file when doing incremental assembly. If such is needed in that case, the assembly will fail. To restart such arrays, explicit assembly is required. Signed-off-by: NeilBrown <neilb@suse.de>
* Continue reshape after assembling arrayAdam Kwolek2011-03-02
| | | | | | | | | | | | | | | | | assemble_container_content() cannot close mdfd handle, as it could be required by reshape continuation. mdfd handle is closed outside this function, when it is not longer necessary. Call to Grow_continue is added for reshape continuation after assembly. In the nearest future, simple condition: if (content->reshape_active) before Grow_continue() call will be replaced by check function for support container operation /reshape/. Signed-off-by: Adam Kwolek <adam.kwolek@intel.com> Signed-off-by: NeilBrown <neilb@suse.de>
* FIX: disks added beyond array should be counted during reshapeAdam Kwolek2011-02-27
| | | | | | | | | | | | During expansion there is more working disks that array can have. Disks with set raid_disk (not a spare disk) during reshape should be counted to allow array state transition to read_only state. Array reconfiguration to new geometry should be done before reshape will be started. Signed-off-by: Adam Kwolek <adam.kwolek@intel.com> Signed-off-by: NeilBrown <neilb@suse.de>
* Various compile fixes.NeilBrown2011-02-01
| | | | | | | Make "make everything" succeed. This fixed some real bugs. Signed-off-by: NeilBrown <neilb@suse.de>
* Allow explicitly listed spared to be included by default.NeilBrown2011-02-01
| | | | | | | | | | When the metadata doesn't identify which array a spare belongs to we normally require an explicit domain match to connect a spare with an array. However when the spare is explicitly listed in argv, it should be safe to include as long as there is no domain conflict. Signed-off-by: NeilBrown <neilb@suse.de>
* Allow domain_test to report that no domains were found.NeilBrown2011-02-01
| | | | | | | | | Sometime we will need to know the difference between no domains found and domains didn't match. So allow domain_test to return different values and fix up all callers to maintain current behaviour. Signed-off-by: NeilBrown <neilb@suse.de>
* free_super after assembling a containerNeilBrown2011-02-01
| | | | | | Else the devices are held open. Signed-off-by: NeilBrown <neilb@suse.de>
* Assemble: ignore unknown devices not listed on command line.NeilBrown2011-02-01
| | | | | | | | | If we find a device that has not superblock, we currently fail unless in auto_assem mode. However we really should only fail if the device was explicitly listed in the arg list. So add a test for that. Signed-off-by: NeilBrown <neilb@suse.de>
* Assemble: allow to assemble container with uuid=0:0:0:0Czarnowska, Anna2011-02-01
| | | | | | | | | | | When there are any arrays in config file the spares with domain not matching any array are not assembled because auto assembly is not attempted. Addition of ARRAY line with uuid=0:0:0:0 in config will work with modified condition for gathering spares. Signed-off-by: Anna Czarnowska <anna.czarnowska@intel.com> Signed-off-by: NeilBrown <neilb@suse.de>
* Assemble: allow to assemble spares on their ownAnna Czarnowska2011-01-05
| | | | | | | | | | | | | | | | | | If we find spares but no members of given array we create container with just spares. This allows auto assemble to pick up all lose imsm spares when there is no config file. When there is a valid config file and any array is assembled from it we don't try auto assembly so we will not assemble spares that don't match any array. To remedy this we must add ARRAY metadata=imsm UUID=00000000:00000000:00000000:00000000 to config file. This container will include all remaining spares. Signed-off-by: Anna Czarnowska <anna.czarnowska@intel.com> Signed-off-by: NeilBrown <neilb@suse.de>
* Assemble: we need to read policy to know array domainsAnna Czarnowska2011-01-05
| | | | | | | | | Policy must be read on all disks identified as array members to get array's domains list. Currently it is only read on first array member in auto assembly mode. Signed-off-by: Anna Czarnowska <anna.czarnowska@intel.com> Signed-off-by: NeilBrown <neilb@suse.de>
* Assemble imsm spares in matching domain onlyAnna Czarnowska2010-12-26
| | | | | | | | | | | | | | | | | | | | Imsm spare will only be taken if it matches domain of identified members of currently assembled array. This implies that: - spare with null domain will match first array assembled. - if array has null domain then no spare will match If we allow spares to set st they may block assembly of subarrays. This is because in auto-assembly tmpdev->used=0 for a spare not matching any array. If we find such spare before container and set st, the content will not get assembled. We allow uuid_zero match any uuid in assembly as unsuitable spares will be rejected on domain check. Signed-off-by: Anna Czarnowska <anna.czarnowska@intel.com> Signed-off-by: NeilBrown <neilb@suse.de>
* FIX: Bad block verification during assembling arrayKrzysztof Wojcik2010-12-26
| | | | | | | | | | | | | | | We need to refuse to assemble an arrays with bad blocks. Initially there was condition in container_content function that returns error value in the case when metadata store information about bad blocks. When the container_content function is called from functions NOT connected with assemble (Kill_subarray, Detail) we get faulty error return value. Patch introduces new flag in array.status - MD_SB_BBM_ERRORS. It is set in container_content when bad blocks are detected and can be checked by container_content caller. Signed-off-by: Krzysztof Wojcik <krzysztof.wojcik@intel.com> 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>
* fix: assemble for external metadata generates segfault if invalid device foundHawrylewicz Czarnowski, Przemyslaw2010-12-01
| | | | | | | | | | | An attempt to invoke super_by_fd() on device that has metadata_version="none" always matches super0 (as test_version is ""). In Assemble() it results in segfault when load_container is invoked (=null for super0). As of now load_container is only started if it points to valid pointer. Signed-off-by: Przemyslaw Czarnowski <przemyslaw.hawrylewicz.czarnowski@intel.com> Signed-off-by: NeilBrown <neilb@suse.de>
* Assemble: call remove_partitions later.NeilBrown2010-11-30
| | | | | | | We shouldn't call remove_partitions until we have made a really firm decision to include the device into the array. 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>
* 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>
* 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>
* 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>
* 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>
* Assemble: factor out ident_matchesNeilBrown2010-11-22
| | | | | | | This will help future patch, and we need to make "Assemble()" smaller anyway. Signed-off-by: NeilBrown <neilb@suse.de>
* Assemble: small cleanup of error checking.NeilBrown2010-11-22
| | | | | | | | | | | | | | If we get an early error (e.g. not a block device) we need to not continue through and check e.g. uuid. Also make sure we set used=2 whenever we find an error, and don't bother with ->free_super as 'goto loop' does that. Now that we abort earlier, we can remove lots of tests on tst && tst->sb Signed-off-by: NeilBrown <neilb@suse.de>
* Add subarray arg to container_content.NeilBrown2010-11-22
| | | | | | | | | | This allows the info for a single array to be extracted, so we don't have to write it into st->subarray. For consistency, implement container_content for super0 and super1, to just return the mdinfo for the single array. Signed-off-by: NeilBrown <neilb@suse.de>
* Assemble - avoid including wayward devices.NeilBrown2010-11-22
| | | | | | | | | | | | | | | If a device - typically in a mirrored set - is assembled independently of the other devices, and then attempted to be brought back into the set it could contain inconsistent data. It should not be included. So detect this situation by ensuring that the 'most recent' device is believed to be active by every other device. If a device is wayward, it will only consider fellow wayward devices to be active and will think all others are failed or missing. This patch only fixes --assemble, not --incremental Signed-off-by: NeilBrown <neilb@suse.de>
* Assemble: handle devices array better.NeilBrown2010-11-22
| | | | | | Only allocate when it is about to be used, and free it when finished. Signed-off-by: NeilBrown <neilb@suse.de>
* get_info_super: report which other devices are thought to be working/failed.NeilBrown2010-11-22
| | | | | | | | | | | | | | To accurately detect when an array has been split and is now being recombined, we need to track which other devices each thinks is working. We should never include a device in an array if it thinks that the primary device has failed. This patch just allows get_info_super to return a list of devices and whether they are thought to be working or not. Signed-off-by: NeilBrown <neilb@suse.de>
* Report error in --update string is not recognised.NeilBrown2010-11-22
| | | | | | | | If an --update is requested by the relevant metadata doesn't understand it, print a useful message rather than silently ignoring the issue. Signed-off-by: NeilBrown <neilb@suse.de>