summaryrefslogtreecommitdiffstats
path: root/lib/metadata/mirror.c
Commit message (Collapse)AuthorAgeFilesLines
* config: add silent modeAlasdair G Kergon2012-08-251-2/+2
| | | | | | | | | | | | | | | | 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/+4
| | | | | | 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-1/+0
| | | | | This headers were not resolving anything used for compiled .c files. Remove unused util.c file.
* mirror: reconfigure_mirror_images not usedPeter Rajnoha2012-08-151-0/+3
|
* discards: don't discard reconfigured extentsAlasdair G Kergon2012-06-271-1/+1
| | | | | | | | Update release_lv_segment_area not to discard any PV extents, as it also gets used when moving extents between LVs. Instead, call a new function release_and_discard_lv_segment_area() in the two places where data should be discarded - lv_reduce() and remove_mirrors_from_segments().
* allocation: allow release_lv_segment_area to failAlasdair G Kergon2012-06-271-4/+6
| | | | Allow release_lv_segment_area to fail as functions it calls can fail.
* Fix pvmove if LV is activated exclusively but cmirror is not running.Milan Broz2012-03-231-1/+4
| | | | | | | | | In this case we should allow to use local mirror, check for cmirror should apply only for lvconvert/lvcreate. Introduced in 2.02.86 by removing !(lv->status & ACTIVATE_EXCL). (Partially workaround, it is minimalistic patch for now.)
* Drop backtrace after log_errorZdenek Kabelac2012-02-231-4/+4
| | | | | Just a minor change to not give backtrace when log_error has been just reported.
* Switch to return voidZdenek Kabelac2012-02-081-6/+2
| | | | List delete cannot fail, so there is no reason to test for error.
* Replace snprintf with dm_snprintfZdenek Kabelac2012-02-081-3/+5
| | | | | | snprintf testing for negative is replaced with dm_snprintf where this test really works. Add missing test for result of dm_snprintf().
* Adjust commentsAlasdair Kergon2012-02-011-2/+4
|
* Add synchornization point in mirror log init.Zdenek Kabelac2012-02-011-1/+4
| | | | | Put extra sync point when mirror log is deactivated and before it's activated for the second time.
* Disallow 'mirrored' log for cluster mirrors.Jonathan Earl Brassow2011-10-251-0/+5
| | | | | | | | | Git commit ID 0864378250956c310cb81608978d091fcdcc97d8 was meant to disallow 'mirrored' logs for cluster mirrors. However, when add_mirror_log is used to create the log (as is now the case when using 'lvcreate' or converting only the log) the check is bypassed. This patch adds the check to add_mirror_log.
* Fix splitmirror in cluster having different DM/LVM views of storage.Jonathan Earl Brassow2011-10-061-103/+102
| | | | | | | | | | | | | | | This patch also does some clean-up of the splitmirrors code. I've attempted to clean-up the splitmirrors code to make it easier to understand with fewer operations. I've tried to reduce the number of metadata operations without compromising the intermediate stages which are necessary for easy clean-up in the even of failure. These changes now correctly handle cluster situations - including exclusive cluster mirrors. Whereas before, a splitmirror operation would result in remote nodes having LVM commands report the newly split LV with a proper name while DM commands would report the old (pre-split) names of the device. IOW, there was a kernel/userspace mismatch.
* Revert initial solution to bug 733114 - I/O error message during splitmirrorJonathan Earl Brassow2011-10-061-40/+0
| | | | | | | | | | | | | | | | | | | | | | | | The original commit comments can be located via this git commit ID: 7d8e615c0b30fc2ef300c90378a51f01c328128c There were three possible solutions to the original problem proposed in the initial check-in. The one chosen was as follows: 2) Do like _remove_mirror_images does and suspend the original, then suspend the sub-lv (the error target), then resume the sub-lv, and finally resume the original LV. This seems like extra pointless operations to me, but it doesn't produce the error message (although, I'm not sure why) and it allows us to leave the visible flag in place. Turns out, the cluster also views the extra suspend/resume operations as pointless too and ignores them. So, this solution doesn't work in a cluster. Further, I've noticed that in addition to the remote cluster nodes still getting I/O errors from scanning the error target, they also have a different LVM and DM views of the same LV. IOW, while the LVM level (gotten from the LVM metadata) sees the correct name for the newly split LV, device-mapper still maintains the old names. Because the original fix failed to completely fix the problem (or work-around it) and because a better solution must be found to address the additional cluster issue of device renaming, I am reverting the above mentioned commit.
* fix compiler warning.Jonathan Earl Brassow2011-09-191-2/+1
| | | | | | Compiler says variable may be used uninitialized. It can't be, but we initialize the variable to NULL anyway. Also, remove the double initialization of another variable.
* After suspend/resume following a splitmirror op, call sync_local_dev_namesJonathan Earl Brassow2011-09-161-0/+1
| | | | | | | | to settle udev before calling deactivate_lv. This is an intra-release regression (no WHATS_NEW entry required). It is part of the fix for the current WHATS_NEW entry: Work around resume_lv causing error LV scanning during splitmirror operation.
* Add missing underscores to local static functionsZdenek Kabelac2011-09-141-11/+11
|
* Additional fixes for lv_mirror_count.Jonathan Earl Brassow2011-09-141-1/+5
| | | | | | | | | Changing lv_mirror_count to only count the AREA_LVs made the function stop working for PVMOVE mirrors. A conditional has been added to fix that problem. Additionally, when counting the images in a mirror stack, we don't need to subtract 1 from the count we get back from the lv_mirror_count call on the temporary mirror layer. (This is because we are no falsely counting the top layer of the temporary mirror.)
* Fix for bug 734252 - problem up converting striped mirror after image failureJonathan Earl Brassow2011-09-141-2/+4
| | | | | | | | | | | | | lv_mirror_count was not able to handle mirrors of stripes properly. When a failed device is removed, the MIRRORED status flag is removed from the LV conditionally based on the results of lv_mirror_count. However, lv_mirror_count trusted the MIRRORED flag - thinking any such LV must be mirrored. It would happily assign first_seg(lv)->area_count as the number of mirrors, but when a mirrored striped LV was reduced to a simple striped LV area_count would be the number of /stripes/ not the number of /mirrors/. A result higher than 1 would be returned from lv_mirror_count, the MIRRORED flag would not be cleared, and the LV would fail to be up-converted properly in lvconvert_mirrors_aux because of it.
* Fix bug 733400 - Mirror down conversion when specifying the secondary leg is ↵Jonathan Earl Brassow2011-09-131-0/+1
| | | | | | | | | broke The operation of deactivating the residual error target LV after removing a mirror layer can cause a "device in-use" conflict with udev. Giving udev a poke before calling deactivate_lv eliminates the conflict. The stick used to poke udev is 'sync_local_dev_names'.
* Better fix for bug 737125 - unable to create mirror on 1K extent size VGJonathan Earl Brassow2011-09-131-3/+4
| | | | | | | | | | | | | | | | | | | WHATS_NEW entry: Fix log size calculation when only a log is being added to a mirror. The original fix pass the mirror LV to allocate_extents (rather than passing NULL) so that _alloc_init could correctly determine the necessary size of the mirror log. In the previous check-in, I noted: In order to get a decent value computed, we need to pass in the 'lv' argument to allocate_extents. This would normally imply a desire for cling/contiguous allocation to the given LV, but since we are not allocating any parallel extents and only log extents, it works fine. However, passing in the LV did have unintended consequences on the placement of the log. The better solution is to pass in the number of extext that are in the mirror LV instead of the LV itself. This will not cause the allocator to reserve that number of extents, because 'stripes' and 'mirrors' are specified as 0. Thus, 'extents' is used to calculate the size of the log, but won't affect how much is allocated.
* Fix for bug 737125 - unable to create mirror on 1K extent size VGJonathan Earl Brassow2011-09-131-1/+1
| | | | | | | | | | | | | | | | _alloc_init calculates the number of necessary log extents via 'mirror_log_extents'. 'mirror_log_extents' takes 3 arguments: region_size, pe_size, and size of the mirror LV. Unfortunately, _alloc_init is guessing at the mirror size by using 'ah->new_extents / ah->area_multiple' - the number of extents that the mirror images have. However, this is /always/ wrong when allocating the log separately. Further, the log is always allocated separately unless we are up-converting the mirror at the same time. It was by luck alone that a default value of '1' reflects what we want in most cases. In order to get a decent value computed, we need to pass in the 'lv' argument to allocate_extents. This would normally imply a desire for cling/contiguous allocation to the given LV, but since we are not allocating any parallel extents and only log extents, it works fine.
* Fix for bug 733114.Jonathan Earl Brassow2011-09-131-0/+40
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When an image is split from a 2-way mirror, the original mirror is converted to a linear device. To do this, the top "layer" must be removed. The segments are transferred from the sub-lv to the top-level LV and the link is severed. The former sub-lv - having its segments transferred - now contains a temporary error target. When the original LV is resumed, the old sub-lv that now contains an error segment is activated and scanned. This is what causes the I/O error messages. There are three ways to fix this problem: 1) Do not set the sub-lv which contains the error target as "visible" before suspending the original LV. This way, when the original is resumed, the sub-lv device node is not created and it is not scanned - avoiding the error messages. The problem with this approach is that if the machine crashes after the resume, it leaves the *hidden* LV in place and the user has a more difficult time noticing that it needs to be cleaned up. Thus, this type of processing is frowned upon. 2) Do like _remove_mirror_images does and suspend the original, then suspend the sub-lv (the error target), then resume the sub-lv, and finally resume the original LV. This seems like extra pointless operations to me, but it does not produce the error message (although, I'm not sure why) and it allows us to leave the visible flag in place. 3) Flag the sub-lv (error target) with a "do not scan" flag. This seems like the cleanest approach, but I have been unable to find the method for doing this. LVs get tagged in such a way by _get_udev_flags, but in this case the resume of the original LV also resumes the error target LV without running it through _get_udev_flags (likely because they are no longer linked). Could there be something wrong in resume_lv? Option #2 was chosen to fix this bug, but it seems like more of a workaround for now.
* add thin_manip.c like the other manip filesAlasdair Kergon2011-09-061-8/+0
| | | | | move basic lv_is_* to macros data_lv -> pool_lv - we decided to call it 'pool' everywhere now
* Start using 64-bit status flags - most of the code already handles them.Alasdair Kergon2011-09-061-2/+2
| | | | | | tdata -> tpool remove commented out definitions from metadata.h formatting clean-ups
* Fix for bug 732142: Unsafe table load during mirror image splitJonathan Earl Brassow2011-09-011-70/+114
| | | | | | | | | | | | | | | | | | | | | | | | | | | There was a bad sequence: *) Make changes to LV layout to split images (e.g. 4-way -> 2-way/2-way) 1) vg_write, suspend_lv(original_mirror), vg_commit 2) activate_lv(newly_split_lv) 3) resume_lv(original_mirror) Step #2 is not allowed. However, without it, the resume of the original mirror will also resume its former sub-LVs - making it impossible to activate the newly split LV due to the changes in layering, pointers, and names that had already been made. Additionally, the resume or the original brings the sub-lv's online with names that differ from the metadata on disk - also a no-no. Thus, the split must be done in stages such that the active LVs always reflect what is in the committed LVM metadata. First, alter the original mirror by releasing the images. The images are made visible and independent as an intermediate stage. (This way, we can have consistency between LVM metadata and active LVs.) The second stage collects the recently split LVs, deactivates them, forms them into a mirror if necessary, and then activates them. It is a bit of a circuitous method, but it is the only way to split a mirror from a mirror and obey these general rules: 1) Never [de]activate sub-lvs when the top-level LV is suspended 2) Avoid having active LVs that differ from the description in the LVM metadata Signed-off-by: Jonathan Brassow <jbrassow@redhat.com>
* Move the core of the lib/config/config.c functionality into libdevmapper,Petr Rockai2011-08-301-3/+3
| | | | | | | leaving behind the LVM-specific parts of the code (convenience wrappers that handle `struct device` and `struct cmd_context`, basically). A number of functions have been renamed (in addition to getting a dm_ prefix) -- namely, all of the config interface now has a dm_config_ prefix.
* Remove and unneeded parameter from build_parallel_areas_from_lv()Jonathan Earl Brassow2011-07-191-3/+3
|
* remove unused var after recent patchAlasdair Kergon2011-06-241-1/+0
|
* Fix to preserve exclusive activation of mirror while up-converting.Jonathan Earl Brassow2011-06-231-2/+7
| | | | | | | | | When an LVM mirror is up-converted (an additional image added), it creates a temporary mirror stack. The lower-level mirror in the stack that is created was not being activated exclusively - violating the exclusive nature of the original mirror. We now check for exclusive activation of a mirror before converting it, and if found, we ensure that the temporary mirror is also exclusively activated.
* Fix issue preventing cluster mirror creation.Jonathan Earl Brassow2011-06-221-9/+3
| | | | | | | | | | | | | | | Mirrors used to be created by first creating a linear device and then adding the other images plus the log. Now mirrors are created by creating all the images in one go and then adding the log separately. The new way ran into the condition that cluster mirrors cannot change the log type (in the case of creation, from core -> disk) while the mirror is not active. (It isn't active because it is in the process of being created.) The reason this condition is in place is because a remote node may have the mirror active, and we don't want to alter the log underneath it. What we really needed was a way of checking if the mirror was active remotely but not locally, and in that case do not allow a change of the log. I've added this check, and cluster mirrors can now be created again.
* Remove test for status flagZdenek Kabelac2011-06-171-2/+1
| | | | | | | | As the ACTIVATE_EXCL could be set only in clvmd code - there is no use for this test in lv_add_mirrors() function only called from tools context. FIXME: Add cluster test case for this.
* Add couple FIXMEs around suspicious codeZdenek Kabelac2011-06-171-0/+1
|
* Major pvmove fix to issue ioctls in the correct order when multiple LVsAlasdair Kergon2011-06-111-2/+18
| | | | | | | | | | | are affected by the move. (Currently it's possible for I/O to become trapped between suspended devices amongst other problems. The current fix was selected so as to minimise the testing surface. I hope eventually to replace it with a cleaner one that extends the deptree code. Some lvconvert scenarios still suffer from related problems.
* clean up critical section patchAlasdair Kergon2011-04-281-4/+4
|
* Replace dm_snprintf with strncpyZdenek Kabelac2011-04-121-7/+4
| | | | | | | | | | | My previous patch fixed incorrect error check for dm_snprintf. However in this particular case - dm_snprintf has been used differently - just like strncpy + setting last char with '\0' - so the code had to return error - because the buffer was to short for whole string. Patch replaces it with real strncpy. Also test for alloca() failure is removed - as the program behaviour is rather undefined in this case - it never returns NULL.
* Fix incorrect tests for dm_snprintf() failureZdenek Kabelac2011-04-091-1/+1
| | | | | As the memory is preallocated based on arg size in these cases, the error would be quite hard to trigger here anyway.
* Fix some unmatching sign comparation gcc warningsZdenek Kabelac2011-04-081-2/+2
| | | | Simple replacement for unsigned type - usually in for() loops.
* This patch adds the ability to extend 0 length layered LVs. ThisJonathan Earl Brassow2011-04-061-2/+3
| | | | | | | | allows us to allocate all images of a mirror (or RAID array) at one time during create. The current mirror implementation still requires a separate allocation for the log, however.
* s/MIRROR_NOTSYNCED/LV_NOTSYNCED/ - Flag will may refer to more than just mirrorsJonathan Earl Brassow2011-03-291-4/+4
|
* In some cases, we could end up with a mirrored LV without a MIRRORED flag. InPetr Rockai2011-03-241-13/+46
| | | | | | | | | | | | | other cases, the code could wind up removing wrong number of mirrors. In yet other cases, we could remove the right number of mirrors, but fail to respect the removal preferences (i.e. keep an image that was requested to be removed while removing an image that was requested to be kept). Under some circumstances, remove_mirror_images could also get stuck in an infinite loop. This patch should fix all of the above undesirable behaviours. Signed-off-by: Petr Rockai <prockai@redhat.com> Reviewed-by: Jonathan Brassow <jbrassow@redhat.com>
* Add new free_pv_fid fn and use it throughout to free all attached fids.Peter Rajnoha2011-03-111-1/+5
| | | | | | | | Since format instances will use own memory pool, it's necessary to properly deallocate it. For now, only fid is deallocated. The PV structure itself still uses cmd mempool mostly, but anytime we'd like to add a mempool in the struct physical_volume, we can just rename this fn to free_pv and add the code (like we have free_vg fn for VGs).
* Const fixingZdenek Kabelac2011-02-181-9/+9
| | | | | | | | | | | | | | | | Fixing some const warnings - with API change in: int vg_extend(struct volume_group *vg, int pv_count, const char *const *pv_names, Change is needed - as lvm2api expects const behaviour here. So vg_extend() is doing local strdup for unescaping. skip_dev_dir return const char* from const char* vg_name. Rest of the patch is cleanup of related warnings. Also using dm_report_filed_string() API change to simplify casting in _string_disp and _lvname_disp.
* Critical sectionZdenek Kabelac2011-02-181-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | New strategy for memory locking to decrease the number of call to to un/lock memory when processing critical lvm functions. Introducing functions for critical section. Inside the critical section - memory is always locked. When leaving the critical section, the memory stays locked until memlock_unlock() is called - this happens with sync_local_dev_names() and sync_dev_names() function call. memlock_reset() is needed to reset locking numbers after fork (polldaemon). The patch itself is mostly rename: memlock_inc -> critical_section_inc memlock_dec -> critical_section_dec memlock -> critical_section Daemons (clmvd, dmevent) are using memlock_daemon_inc&dec (mlockall()) thus they will never release or relock memory they've already locked memory. Macros sync_local_dev_names() and sync_dev_names() are functions. It's better for debugging - and also we do not need to add memlock.h to locking.h header (for memlock_unlock() prototyp).
* Fix lvchange --test to exit cleanly.Alasdair Kergon2011-01-241-0/+5
|
* s/log_verbose/log_error/ - Increase log level on error message.Jonathan Earl Brassow2011-01-111-4/+3
|
* Add disk to mirrored log type conversion.Jonathan Earl Brassow2011-01-111-7/+31
|
* Refactor the percent (mirror sync, snapshot usage) handling code to usePetr Rockai2010-11-301-23/+11
| | | | fixed-point values instead of a combination of a float value and an enum.
* Extend cling allocation policy to recognise PV tags (cling_by_tags).Alasdair Kergon2010-11-091-1/+1
| | | | Add allocation/cling_tag_list to lvm.conf.