summaryrefslogtreecommitdiffstats
path: root/lib/metadata/raid_manip.c
Commit message (Collapse)AuthorAgeFilesLines
* RAID: '--test' should not cause a valid create command to failJonathan Brassow2012-09-051-0/+3
| | | | | | | | | It is necessary when creating a RAID LV to clear the new metadata areas. Failure to do so could result in a prepopulated bitmap that would cause the new array to skip syncing portions of the array. It is a requirement that the metadata LVs be activated and cleared in the process of creating. However in test mode, this requirement should be lifted - no new LVs should be created or written to.
* cleanup: Use segtype->ops->name() instead of segtype->name where applicableJonathan Brassow2012-09-051-5/+6
| | | | | | | | When printing a message for the user and the lv_segment pointer is available, use segtype->ops->name() instead of segtype->name. This gives a better user-readable name for the segment. This is especially true for the 'striped' segment type, which prints "linear" if there is an area_count of one.
* config: add silent modeAlasdair G Kergon2012-08-251-7/+6
| | | | | | | | | | | | | | | | Accept -q as the short form of --quiet. Suppress non-essential standard output if -q is given twice. Treat log/silent in lvm.conf as equivalent to -qq. Review all log_print messages and change some to log_print_unless_silent. When silent, the following commands still produce output: dumpconfig, lvdisplay, lvmdiskscan, lvs, pvck, pvdisplay, pvs, version, vgcfgrestore -l, vgdisplay, vgs. [Needs checking.] Non-essential messages are shifted from log level 4 to log level 5 for syslog and lvm2_log_fn purposes.
* RAID: Add support for RAID10Jonathan Brassow2012-08-241-0/+18
| | | | | | This patch adds support for RAID10. It is not the default at this stage. The user needs to specify '--type raid10' if they would like RAID10 instead of stacked mirror over stripe.
* cleanup: drop unneeded included header filesZdenek Kabelac2012-08-231-3/+0
| | | | | This headers were not resolving anything used for compiled .c files. Remove unused util.c file.
* Allow a subset of failed devices to be replaced in RAID LVs.Jonathan Earl Brassow2012-04-241-0/+18
| | | | | | If two devices in an array failed, it was previously impossible to replace just one of them. This patch allows for the replacement of some, but perhaps not all, failed devices.
* Fix code that performs RAID device replacement while under snapshot.Jonathan Earl Brassow2012-04-121-4/+4
| | | | | | | The code should have been calling [suspend|resume]_lv_origin() rather than [suspend|resume]_lv. This addresses bug 807069.
* Fix inability to split RAID1 image while specifying a particular PV.Jonathan Earl Brassow2012-04-111-19/+40
| | | | | | | | The logic for resuming the original and newly split LVs was not properly done to handle situations where anything but the last device in the array was split. It did not take into account the possible name collisions that might occur when the original LV undergoes the shifting and renaming of its sub-LVs.
* RAID LVs could not handle a down-convert if a device other than the last oneJonathan Earl Brassow2012-04-111-2/+16
| | | | in the array was specified for removal. This change addresses that (bz806111).
* Fix name conflicts that prevent down-converting RAID1 when specifying a deviceJonathan Earl Brassow2012-03-151-1/+13
| | | | | | | | | | | | | When down-converting a RAID1 device, it is the last device that is extracted and removed when the user does not specify a particular device. However, when a device is specified (and it is not the last), the device is removed and the remaining sub-LVs are "shifted down" to fill the hole. This cause problems when resuming the LV because if the shifted devices were resumed (and thus renamed) before the sub-LV being extracted, there would be a name conflict. The solution is to resume the extracted sub-LVs first so that they can be properly renamed preventing a possible conflict. This addresses bug 801967.
* Require number of stripes to be greater than parity devices in higher RAID.Jonathan Earl Brassow2012-02-231-0/+9
| | | | | Also, add some comments to code that I recently added that may be unclear otherwise.
* Fix allocation code to allow replacement of single RAID 4/5/6 device.Jonathan Earl Brassow2012-02-231-1/+5
| | | | | | | | | | | | | The code fail to account for the case where we just need a single device in a RAID 4/5/6 array. There is no good way to tell the allocation functions that we don't need parity devices when we are allocating just a single device. So, I've used a bit of a hack. If we are allocating an area_count that is <= the parity count, then we can assume we are simply allocating a replacement device (i.e. no need to include parity devices in the calculations). This should make sense in most cases. If we need to allocate replacement devices due to failure (or moving), we will never allocate more than the parity count; or we would cause the array to become unusable. If we are creating a new device, we should always create more stripes than parity devices.
* Add check for rimage name allocation failureZdenek Kabelac2012-02-131-1/+4
|
* Use suspend|resume_origin_only when up-converting RAID LVs, as mirrors do.Jonathan Earl Brassow2012-01-241-2/+2
| | | | | | | | | | | Failure to do so results in "Performing unsafe table load while X device(s) are known to be suspended" errors. While fixing the problem in this way works and is consistent with the way the mirror segment type does it, it would be nice to find a solution that uses the generic suspend/resume calls. Also included in this check-in are additions to the test suite that perform conversions on RAID LVs under a snapshot. These tests are disabled for the time being due to a kernel bug that is yet to be tracked down.
* Don't allow two images to be split and tracked from a RAID LV at one timeJonathan Earl Brassow2011-12-011-9/+48
| | | | | | | | | | | | | | | Also, don't allow a splitmirror operation on a RAID LV that is already tracking a split, unless the operation is to stop the tracking and complete the split. Example: ~> lvconvert --splitmirrors 1 --trackchanges vg/lv /dev/sdc1 # Now tracking changes - image can be merged back or split-off for good ~> lvconvert --splitmirrors 1 -n new_name vg/lv /dev/sdc1 # ^ Completes split ^ If a split is performed on a RAID that is tracking an already split image and PVs are provided, we must ensure that 1) the already split LV is represented in the PVs 2) we are careful to split only the tracked image
* Do not allow users to change the name of RAID sub-LVs or the name of theJonathan Earl Brassow2011-12-011-0/+16
| | | | RAID LV if it is tracking changes for a split image.
* Support the ability to replace specific devices in a RAID array.Jonathan Earl Brassow2011-11-301-4/+239
| | | | | | | | | | | | | | | | | RAID is not like traditional LVM mirroring. LVM mirroring required failed devices to be removed or the logical volume would simply hang. RAID arrays can keep on running with failed devices. In fact, for RAID types other than RAID1, removing a device would mean substituting an error target or converting to a lower level RAID (e.g. RAID6 -> RAID5, or RAID4/5 to RAID0). Therefore, rather than removing a failed device unconditionally and potentially allocating a replacement, RAID allows the user to "replace" a device with a new one. This approach is a 1-step solution vs the current 2-step solution. example> lvconvert --replace <dev_to_remove> vg/lv [possible_replacement_PVs] '--replace' can be specified more than once. example> lvconvert --replace /dev/sdb1 --replace /dev/sdc1 vg/lv
* Add the ability to convert LVs of "mirror" segtype to "raid1" segtype.Jonathan Earl Brassow2011-10-071-9/+173
| | | | | | | | | | | | | | | | | Example: ~> lvconvert --type raid1 vg/mirror_lv Steps to convert "mirror" to "raid1" 1) Allocate a RAID metadata LV for each mirror image from the same PVs on which they are located. 2) Clear the metadata LVs. This involves writing LVM metadata, so we don't change any aspects of the mirror LV before this so that the user can easily remove LVs from the failed convert attempt while retaining the original mirror. 3) Remove the mirror log, if it exists. 4) Add metadata LVs to mirror LV 5) Rename mirror sub-lvs (s/mimage/rimage/) 6) Change flags and segtype from mirror to raid1
* Add the ability to convert linear LVs to RAID1Jonathan Earl Brassow2011-10-071-13/+175
| | | | | | | | | | | | | | | | | | | | | | Example: ~> lvconvert --type raid1 -m 1 vg/lv The following steps are performed to convert linear to RAID1: 1) Allocate a metadata device from the same PV as the linear device to provide the metadata/data LV pair required for all RAID components. 2) Allocate the required number of metadata/data LV pairs for the remaining additional images. 3) Clear the metadata LVs. This performs a LVM metadata update. 4) Create the top-level RAID LV and add the component devices. We want to make any failure easy to unwind. This is why we don't create the top-level LV and add the components until the last step. Should anything happen before that, the user could simply remove the unnecessary images. Also, we want to ensure that the metadata LVs are cleared before forming the array to prevent stale information from polluting the new array. A new macro 'seg_is_linear' was added to allow us to distinguish linear LVs from striped LVs.
* When up-converting a RAID1 array, we need to allocate new larger arrays forJonathan Earl Brassow2011-09-221-1/+1
| | | | | | | | | seg->areas and seg->meta_areas. We also need to copy the memory from the old arrays to the newly allocated arrays. The amount of memory to copy was determined by seg->area_count. However, seg->area_count was being set to the higher value after copying the 'seg->areas' information, but before copying the 'seg->meta_areas' information. This means we were copying more memory than necessary for 'seg->meta_areas' - something that could lead to a segfault.
* LVM_WRITE and LVM_READ are 64bit constantsZdenek Kabelac2011-09-141-5/+1
| | | | | | Revert John patch, which fixed only 1 place where ~LVM_WRITE was in use and convert ommited LVM_READ/WRITE flags to 64bit constants as well. (Since both 'status' flags for LV and VG are 64bit.)
* Changing RAID status flags to 64-bit broke some binary flag operations.Jonathan Earl Brassow2011-09-131-1/+5
| | | | | | | | LVM_WRITE is a 32-bit flag. Now that RAID[_IMAGE|_META] are 64-bit, and'ing a RAID LV's status against LVM_WRITE can reset the higher order flags. A similar thing will affect thinp flags if not careful.
* Start using 64-bit status flags - most of the code already handles them.Alasdair Kergon2011-09-061-1/+1
| | | | | | tdata -> tpool remove commented out definitions from metadata.h formatting clean-ups
* clarify commentAlasdair Kergon2011-08-191-2/+2
|
* _ for static fnsAlasdair Kergon2011-08-191-37/+37
|
* Add ability to merge back a RAID1 image that has been split w/ --trackchangesJonathan Earl Brassow2011-08-181-0/+86
| | | | Argument layout is very similar to the merge command for snapshots.
* Add support for m-way to n-way up-convert in RAID1 (no linear to n-way yet)Jonathan Earl Brassow2011-08-181-46/+343
| | | | | | | | | | | This patch adds the ability to upconvert a raid1 array - say from 2-way to 3-way. It does not yet support upconverting linear to n-way. The 'raid' device-mapper target allows for individual components (images) of an array to be specified for rebuild. This mechanism is used when adding new images to the array so that the new images can be resync'ed while the rest of the images in the array can remain 'in-sync'. (There is no mirror-on-mirror layering required.)
* Add the ability to split an image from the mirror and track changes.Jonathan Earl Brassow2011-08-181-0/+96
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | ~> lvconvert --splitmirrors 1 --trackchanges vg/lv The '--trackchanges' option allows a user the ability to use an image of a RAID1 array for the purposes of temporary read-only access. The image can be merged back into the array at a later time and only the blocks that have changed in the array since the split will be resync'ed. This operation can be thought of as a partial split. The image is never completely extracted from the array, in that the array reserves the position the device occupied and tracks the differences between the array and the split image via a bitmap. The image itself is rendered read-only and the name (<LV>_rimage_*) cannot be changed. The user can complete the split (permanently splitting the image from the array) by re-issuing the 'lvconvert' command without the '--trackchanges' argument and specifying the '--name' argument. ~> lvconvert --splitmirrors 1 --name my_split vg/lv Merging the tracked image back into the array is done with the '--merge' option (included in a follow-on patch). ~> lvconvert --merge vg/lv_rimage_<n> The internal mechanics of this are relatively simple. The 'raid' device- mapper target allows for the specification of an empty slot in an array via '- -'. This is what will be used if a partial activation of an array is ever required. (It would also be possible to use 'error' targets in place of the '- -'.) If a RAID image is found to be both read-only and visible, then it is considered separate from the array and '- -' is used to hold it's position in the array. So, all that needs to be done to temporarily split an image from the array /and/ cause the kernel target's bitmap to track (aka "mark") changes made is to make the specified image visible and read-only. To merge the device back into the array, the image needs to be returned to the read/write state of the top-level LV and made invisible.
* Add --splitmirrors support for RAID1 (1 image only)Jonathan Earl Brassow2011-08-181-0/+108
| | | | | | | | | Users already have the ability to split an image from an LV of "mirror" segtype. This patch extends that ability to LVs of "raid1" segtype. This patch only allows a single image to be split off, however. (The "mirror" segtype allows an arbitrary number of images to be split off. e.g. 4-way => 3-way/linear, 2-way/2-way, linear,3-way)
* When down-converting RAID1, don't activate sub-lvs between suspend/resumeJonathan Earl Brassow2011-08-181-15/+3
| | | | | | | | | of top-level LV. We can't activate sub-lv's that are being removed from a RAID1 LV while it is suspended. However, this is what was being used to have them show-up so we could remove them. 'sync_local_dev_names' is a sufficient and proper replacement and can be done after the top-level LV is resumed.
* Compiler warning fixes, better error messaging, and cosmetic changes.Jonathan Earl Brassow2011-08-131-28/+75
| | | | | | | | 1) add new function 'raid_remove_top_layer' which will be useful to other conversion functions later (also cleans up code) 2) Add error messages if raid_[extract|add]_images fails 3) Add function prototypes to prevent compiler warnings when compiling with '--with-raid=shared'
* Various code clean-ups (s/malloc/zalloc/, new msgs, etc)Jonathan Earl Brassow2011-08-111-3/+3
| | | | | | | Fix a couple more issues that kabi found. - Add some error messages in failure cases - s/malloc/zalloc/ - use vg->vgmem for lv names instead of vg->cmd->mem
* Add some log_error msg's and fix potential segfaultJonathan Earl Brassow2011-08-111-4/+8
| | | | | Thanks to kabi for spotting these - especially the possibility for segfault if a loop runs all the way through without finding a match.
* Add ability to down-convert RAID1 arrays.Jonathan Earl Brassow2011-08-111-0/+478
Also, add some simple RAID tests to testsuite.