summaryrefslogtreecommitdiffstats
path: root/tools/vgsplit.c
Commit message (Collapse)AuthorAgeFilesLines
* Fix vgsplit when there are mirrors that have mirrored logs.Jonathan Earl Brassow2011-10-061-2/+15
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The problem as reported by "ben <benscott@nwlink.com>" on lvm-devel: vgsplit fails with mirrored mirror log #lvs --all -o lv_name,lv_attr,devices LV Attr Devices MyMirror mwi-- [MyMirror_mimage_0] Iwi--- /dev/sdq(0) [MyMirror_mimage_1] Iwi--- /dev/sdo(0) [MyMirror_mimage_2] Iwi--- /dev/sdi(0) [MyMirror_mlog] mwi--- [MyMirror_mlog_mimage_0] Iwi--- /dev/sds(0) [MyMirror_mlog_mimage_1] Iwi--- /dev/sde(0) #vgsplit -v "TestA" "TestB" "/dev/sdq" "/dev/sdo" "/dev/sdi" "/dev/sds" "/dev/sde" Checking for volume group "TestA" Checking for new volume group "TestB" Archiving volume group "TestA" metadata (seqno 213). Can't split mirror MyMirror between two Volume Groups AFTER FIX: [root@bp-01 ~]# lvs -a -o name,vg_name,devices vg new Volume group "new" not found Skipping volume group new LV VG Devices lv vg lv_mimage_0(0),lv_mimage_1(0) [lv_mimage_0] vg /dev/sdb1(0) [lv_mimage_1] vg /dev/sdc1(0) [lv_mlog] vg lv_mlog_mimage_0(0),lv_mlog_mimage_1(0) [lv_mlog_mimage_0] vg /dev/sdh1(0) [lv_mlog_mimage_1] vg /dev/sdi1(0) [root@bp-01 ~]# vgsplit vg new /dev/sd[bchi]1 New volume group "new" successfully split from "vg" [root@bp-01 ~]# lvs -a -o name,vg_name,devices vg new LV VG Devices lv new lv_mimage_0(0),lv_mimage_1(0) [lv_mimage_0] new /dev/sdb1(0) [lv_mimage_1] new /dev/sdc1(0) [lv_mlog] new lv_mlog_mimage_0(0),lv_mlog_mimage_1(0) [lv_mlog_mimage_0] new /dev/sdh1(0) [lv_mlog_mimage_1] new /dev/sdi1(0)
* Move the core of the lib/config/config.c functionality into libdevmapper,Petr Rockai2011-08-301-1/+1
| | | | | | | 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.
* Replace free_vg with release_vgZdenek Kabelac2011-08-101-9/+9
| | | | | | | | Move the free_vg() to vg.c and replace free_vg with release_vg and make the _free_vg internal. Patch is needed for sharing VG in vginfo cache so the release_vg function name is a better fit here.
* pre-release clean-upsAlasdair Kergon2011-04-291-2/+2
|
* Fix free_vg orderZdenek Kabelac2011-03-301-7/+7
| | | | | | | | | | | | | | As now the FID management is more complex, the code inside free_vg needs to access some parts of memory pools which were not needed before. For this - makes the order of unlock_and_free_vg() unconditional. Keek using unlock_and_free_vg() API function. For properly working VG locking mechanism only the alphabeting locking orderer needs to be preserved. TODO: there could be few more code parts simplified when we 'officially' support of referencies between different memory pools.
* Const fixingZdenek Kabelac2011-02-181-1/+1
| | | | | | | | | | | | | | | | 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.
* Add further consistency checking to vg_validate, ensuring that all segmentPetr Rockai2010-12-141-0/+1
| | | | areas point to LVs or PVs that are listed in the respective VG.
* Rename vg_release to free_vg.Alasdair Kergon2010-12-081-11/+11
|
* Add escape sequence for ':' and '@' found in device names used as PVs.Peter Rajnoha2010-09-231-0/+1
|
* improve vgmetadatacopies unmanaged messageAlasdair Kergon2010-06-301-1/+1
|
* Add --vgmetadatacopies to vgsplit man page and command.Dave Wysochanski2010-06-281-2/+4
| | | | Signed-off-by: Dave Wysochanski <dwysocha@redhat.com>
* Rename validate_vg_create_params to vgcreate_params_validate.Dave Wysochanski2009-11-011-1/+1
|
* Rename fill_vg_create_params to vgcreate_params_set_from_args.Dave Wysochanski2009-11-011-1/+2
| | | | | Rename fill_vg_create_params to vgcreate_params_set_from_args and remove vg_name parameter from function (caller must set before calling function).
* Add vgcreate_params_set_defaults().Dave Wysochanski2009-11-011-7/+1
| | | | | Add function to set default vgcreate parameters based on existing VG or internal defaults. Should be no functional change.
* Update vgsplit to call vg_set_clustered().Dave Wysochanski2009-10-311-5/+3
|
* Permit snapshots of mirrors. (brassow)Alasdair Kergon2009-10-261-4/+5
|
* Add lots of missing stack debug messages to tools.Alasdair Kergon2009-09-141-7/+13
| | | | | Make readonly locking available as locking type 4. Fix readonly locking to permit writeable global locks (for vgscan). (2.02.49)
* Change vgsplit behavior to open/lock first vg based on alphabetical ordering.Dave Wysochanski2009-09-021-0/+3
| | | | | | | | | If the destination vgname comes before the source vgname, we must open the destination first because of the locking rules. Thus, do a strcmp and set the flag based on the comparison. Author: Dave Wysochanski <dwysocha@redhat.com>
* Refactor vgsplit - reorder _vgsplit_from and _vgsplit_to based on flag.Dave Wysochanski2009-09-021-17/+31
| | | | | | | | | | | | | | | Slight functional change. If we open the destination first, we cannot know the 'fmt'. In this case we use the default metadata type unless the user has specified -M on the cmdline. If not, in most cases this is fine since we use the LVM2 default metadata type. However, if the user is specifying a non-default metadata type (e.g. lvm1) and the order of the names is such that we have to open the destination (vg_to) first, we have a problem. So in this case, we require the use of -M and vgsplit will fail with an error if not. I've updated the man page to recommend the usage of -M in this case. Author: Dave Wysochanski <dwysocha@redhat.com>
* Refactor vgsplit: _vgsplit_from or _vgsplit_to failure cleanup depends on order.Dave Wysochanski2009-09-021-2/+6
| | | | | | | Should be no functional change. Author: Dave Wysochanski <dwysocha@redhat.com>
* Refactor vgsplit - create _vgsplit_from function to open source vg.Dave Wysochanski2009-09-021-6/+23
| | | | | | | | Should be no functional change and allows future reorder of source and dest vgs. Author: Dave Wysochanski <dwysocha@redhat.com>
* Refactor vgsplit - create _vgsplit_to function which creates or opens dest vg.Dave Wysochanski2009-09-021-31/+48
| | | | | | | | | | | Move the creating/opening of the destination vg into its own function so later we can reorder the source / destination vg opening based on the alphabetical lock order rule. Should be no functional change but code is a bit tricky. Author: Dave Wysochanski <dwysocha@redhat.com>
* Refactor vgsplit - add 'lock_vg_from_first' flag.Dave Wysochanski2009-09-021-2/+8
| | | | | | | | Introduce 'lock_vg_from_first' flag to retain which vg was locked first. Should be no functional change. Author: Dave Wysochanski <dwysocha@redhat.com>
* Refactor vgsplit - remove bad2 label.Dave Wysochanski2009-09-021-2/+2
| | | | | | | No functional change. Author: Dave Wysochanski <dwysocha@redhat.com>
* Refactor vgsplit to move existing_vg logic in a separate 'if' statement.Dave Wysochanski2009-09-021-3/+6
| | | | | | | | | This will aid in future refactorings and allow for us to reorder the source and destination vg based on alphabetical names. Should be no functional change. Author: Dave Wysochanski <dwysocha@redhat.com>
* Remove READ_REQUIRE_RESIZEABLE flag from vgsplit.Dave Wysochanski2009-07-141-4/+2
| | | | | | | | | Remove READ_REQUIRE_RESIZEABLE flag from vgsplit similar to the removal from vgextend. Move the check inside the functions that actually move pvs from one vg structure to another. Should be no functional change. Signed-off-by: Dave Wysochanski <dwysocha@redhat.com> Acked-by: Alasdair G Kergon <agk@redhat.com>
* Refactor vgsplit - move move_pvs_used_by_lv and move_pv inside library.Dave Wysochanski2009-07-141-68/+2
| | | | | | | | | In the future we may export these functions or something like them in liblvm For now this helps in cleaning up the checks for RESIZEABLE since we can use the internal library function vg_bad_status_bits. Signed-off-by: Dave Wysochanski <dwysocha@redhat.com> Acked-by: Alasdair G Kergon <agk@redhat.com>
* Change vg_create() to take only minimal parameters and obtain a lock.Dave Wysochanski2009-07-091-15/+21
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | vg_t *vg_create(struct cmd_context *cmd, const char *vg_name); This is the first step towards the API called to create a VG. Call vg_lock_newname() inside this function. Use _vg_make_handle() where possible. Now we have 2 ways to construct a volume group: 1) vg_read: Used when constructing an existing VG from disks 2) vg_create: Used when constructing a new VG Both of these interfaces obtain a lock, and return a vg_t *. The usage of _vg_make_handle() inside vg_create() doesn't fit perfectly but it's ok for now. Needs some cleanup though and I've noted "FIXME" in the code. Add the new vg_create() plus vg 'set' functions for non-default VG parameters in the following tools: - vgcreate: Fairly straightforward refactoring. We just moved vg_lock_newname inside vg_create so we check the return via vg_read_error. - vgsplit: The refactoring here is a bit more tricky. Originally we called vg_lock_newname and depending on the error code, we either read the existing vg or created the new one. Now vg_create() calls vg_lock_newname, so we first try to create the VG. If this fails with FAILED_EXIST, we can then do the vg_read. If the create succeeds, we check the input parameters and set any new values on the VG. TODO in future patches: 1. The VG_ORPHAN lock needs some thought. We may want to treat this as any other VG, and require the application to obtain a handle and pass it to other API calls (for example, vg_extend). Or, we may find that hiding the VG_ORPHAN lock inside other APIs is the way to go. I thought of placing the VG_ORPHAN lock inside vg_create() and tying it to the vg handle, but was not certain this was the right approach. 2. Cleanup error paths. Integrate vg_read_error() with vg_create and vg_read* error codes and/or the new error APIs. Signed-off-by: Dave Wysochanski <dwysocha@redhat.com>
* Add defines for default vgcreate parameters.Dave Wysochanski2009-07-091-1/+1
|
* Fix memory leak in vgsplit when re-reading the VG.Dave Wysochanski2009-07-091-4/+5
| | | | | | | | Call vg_release() before re-reading the vg. Remove vgsplit whitespace and update copyright. Author: Dave Wysochanski <dwysocha@redhat.com>
* Remove unneeded LOCK_NONBLOCKING from vg_read() API.Dave Wysochanski2009-07-081-2/+1
| | | | | | | | | | | | | | | | | | | | | | | Remove unneeded LOCK_NONBLOCKING from vg_read() API and tools that use it. We no longer need this flag anywhere since we now automatically set LCK_NONBLOCK inside lock_vol() if vgs_locked(). For further details, see: commit d52b3fd3fe2006e2d13e42f8518b6512bff03710 Author: Dave Wysochanski <dwysocha@redhat.com> Date: Wed May 13 13:02:52 2009 +0000 Remove NON_BLOCKING lock flag from tools and set a policy to auto-set. As a simplification to the tools and further liblvm, this patch pushes the setting of NON_BLOCKING lock flag inside the lock_vol() call. The policy we set is if any existing VGs are currently locked, we set the NON_BLOCKING flag. At some point it may make sense to add this flag back if we get an RFE from a liblvm user, but for now let's keep it as simple as possible. Signed-off-by: Dave Wysochanski <dwysocha@redhat.com>
* Remove LOCK_KEEP and READ_CHECK_EXISTENCE from vgsplit.Dave Wysochanski2009-07-081-5/+8
| | | | | | | | | | | Remove LOCK_KEEP and READ_CHECK_EXISTENCE from vgsplit. These flags are no longer necessary. We now check for existence in a differnet function, and it is not necessary to keep the lock. Removing these flags simplifies the new vg_read() interface. After this patch, we can fully remove LOCK_KEEP. READ_CHECK_EXISTENCE needs a bit more work before full removal. Signed-off-by: Dave Wysochanski <dwysocha@redhat.com>
* Fix vg_read() error paths to properly release upon vg_read_error().Dave Wysochanski2009-07-071-1/+3
| | | | | | | | | | | | | | | | | | | | | | | Fix vg_read() error paths to properly release upon vg_read_error(). Note that in the iterator paths (process_each_*()), we release inside the iterator so no individual cleanup is needed. However there are a number of other places we missed the cleanup. Proper cleanup when vg_read_error() is true should be calling vg_release(vg), since there should be no locks held if we get an error (except in certain special cases, which IMO we should work to remove from the code). Unfortunately the testsuite is unable to detect these types of memory leaks. Most of them can be easily seen if you try an operation (e.g. lvcreate) with a volume group that does not exist. Error message looks like this: Volume group "vg2" not found You have a memory leak (not released memory pool): [0x1975eb8] You have a memory leak (not released memory pool): [0x1975eb8] Author: Dave Wysochanski <dwysocha@redhat.com>
* Convert vgsplit to use vg_read_for_update.Dave Wysochanski2009-07-011-18/+18
| | | | | | | | | Sun May 3 13:12:28 CEST 2009 Petr Rockai <me@mornfall.net> * Convert vgsplit to use vg_read_for_update. Author: Petr Rockai <prockai@redhat.com> Committer: Dave Wysochanski <dwysocha@redhat.com>
* Fix compiler warning.Milan Broz2009-06-101-1/+1
|
* Update vgsplit to use new vg_reserve_newname() function.Dave Wysochanski2009-06-091-5/+20
|
* Pre-release cleanups.Alasdair Kergon2009-05-211-3/+3
|
* Remove vg->lv_count and use counter function.Milan Broz2009-05-131-5/+1
| | | | | | | This should not cause problems but simplifies code a lot. (the volumes_count is merged and renamed with lvs_visible function by following patch.)
* Remove NON_BLOCKING lock flag from tools and set a policy to auto-set.Dave Wysochanski2009-05-131-1/+1
| | | | | | | | | As a simplification to the tools and further liblvm, this patch pushes the setting of NON_BLOCKING lock flag inside the lock_vol() call. The policy we set is if any existing VGs are currently locked, we set the NON_BLOCKING flag. Should be no functional change.
* Remove snapshot_count from VG and use function instead.Milan Broz2009-05-121-4/+1
|
* Properly release VG memory pool in all CLI tools.Milan Broz2009-04-101-22/+21
|
* Rename vg_read() to vg_read_internal(). (mornfall)Alasdair Kergon2009-01-261-2/+2
|
* Right, a simple build (without options) is working again.Alasdair Kergon2008-11-031-17/+17
|
* Fix vgsplit internal counting of snapshot LVs.Dave Wysochanski2008-04-231-1/+1
|
* missing stackAlasdair Kergon2008-04-151-3/+3
|
* Update vgsplit to only restrict split with active LVs involved in split.Dave Wysochanski2008-04-101-15/+17
| | | | | Existing code will reject a vgsplit if any LVs in the source VG are active. This patch updates vgsplit to only check LVs involved in the split.
* .Alasdair Kergon2008-04-101-4/+2
|
* more pre-release cleanupAlasdair Kergon2008-04-101-34/+27
|
* make list_move consistent with other list fnsAlasdair Kergon2008-04-101-2/+2
|
* Add vg_is_clustered() helper function.Dave Wysochanski2008-04-101-1/+1
| | | | Should be no functional change.