2002-05-31 23:30:51 +04:00
/*
2008-01-30 17:00:02 +03:00
* Copyright ( C ) 2001 - 2004 Sistina Software , Inc . All rights reserved .
2007-08-21 00:55:30 +04:00
* Copyright ( C ) 2004 - 2007 Red Hat , Inc . All rights reserved .
2002-05-31 23:30:51 +04:00
*
2004-03-30 23:35:44 +04:00
* This file is part of LVM2 .
2002-05-31 23:30:51 +04:00
*
2004-03-30 23:35:44 +04:00
* This copyrighted material is made available to anyone wishing to use ,
* modify , copy , or redistribute it subject to the terms and conditions
2007-08-21 00:55:30 +04:00
* of the GNU Lesser General Public License v .2 .1 .
2002-05-31 23:30:51 +04:00
*
2007-08-21 00:55:30 +04:00
* You should have received a copy of the GNU Lesser General Public License
2004-03-30 23:35:44 +04:00
* along with this program ; if not , write to the Free Software Foundation ,
* Inc . , 59 Temple Place , Suite 330 , Boston , MA 02111 - 1307 USA
2002-05-31 23:30:51 +04:00
*/
# include "tools.h"
2008-04-09 17:47:13 +04:00
static int _move_pv ( struct volume_group * vg_from , struct volume_group * vg_to ,
const char * pv_name )
2002-05-31 23:30:51 +04:00
{
struct physical_volume * pv ;
2008-04-09 17:47:13 +04:00
struct pv_list * pvl ;
/* FIXME: handle tags */
if ( ! ( pvl = find_pv_in_vg ( vg_from , pv_name ) ) ) {
log_error ( " Physical volume %s not in volume group %s " ,
pv_name , vg_from - > name ) ;
return 0 ;
}
2002-05-31 23:30:51 +04:00
2008-11-04 01:14:30 +03:00
dm_list_move ( & vg_to - > pvs , & pvl - > list ) ;
2002-05-31 23:30:51 +04:00
vg_from - > pv_count - - ;
vg_to - > pv_count + + ;
2008-04-10 06:15:56 +04:00
pv = pvl - > pv ;
2002-05-31 23:30:51 +04:00
2007-06-16 02:16:55 +04:00
vg_from - > extent_count - = pv_pe_count ( pv ) ;
vg_to - > extent_count + = pv_pe_count ( pv ) ;
2002-05-31 23:30:51 +04:00
2007-06-16 02:16:55 +04:00
vg_from - > free_count - = pv_pe_count ( pv ) - pv_pe_alloc_count ( pv ) ;
vg_to - > free_count + = pv_pe_count ( pv ) - pv_pe_alloc_count ( pv ) ;
2008-04-09 17:47:13 +04:00
return 1 ;
}
static int _move_pvs_used_by_lv ( struct volume_group * vg_from ,
struct volume_group * vg_to ,
const char * lv_name )
{
struct lv_segment * lvseg ;
unsigned s ;
struct lv_list * lvl ;
struct logical_volume * lv ;
/* FIXME: handle tags */
if ( ! ( lvl = find_lv_in_vg ( vg_from , lv_name ) ) ) {
log_error ( " Logical volume %s not in volume group %s " ,
lv_name , vg_from - > name ) ;
return 0 ;
}
2008-11-04 01:14:30 +03:00
dm_list_iterate_items ( lvseg , & lvl - > lv - > segments ) {
2008-04-09 17:47:13 +04:00
if ( lvseg - > log_lv )
if ( ! _move_pvs_used_by_lv ( vg_from , vg_to ,
lvseg - > log_lv - > name ) )
return_0 ;
for ( s = 0 ; s < lvseg - > area_count ; s + + ) {
if ( seg_type ( lvseg , s ) = = AREA_PV ) {
if ( ! _move_pv ( vg_from , vg_to ,
pv_dev_name ( seg_pv ( lvseg , s ) ) ) )
return_0 ;
} else if ( seg_type ( lvseg , s ) = = AREA_LV ) {
lv = seg_lv ( lvseg , s ) ;
if ( ! _move_pvs_used_by_lv ( vg_from , vg_to ,
lv - > name ) )
return_0 ;
}
}
}
return 1 ;
2002-05-31 23:30:51 +04:00
}
2005-04-07 16:39:44 +04:00
/* FIXME Why not (lv->vg == vg) ? */
static int _lv_is_in_vg ( struct volume_group * vg , struct logical_volume * lv )
{
struct lv_list * lvl ;
2008-11-04 01:14:30 +03:00
dm_list_iterate_items ( lvl , & vg - > lvs )
2005-04-07 16:39:44 +04:00
if ( lv = = lvl - > lv )
return 1 ;
return 0 ;
}
2008-04-11 01:34:53 +04:00
static int _move_one_lv ( struct volume_group * vg_from ,
2008-04-10 23:59:43 +04:00
struct volume_group * vg_to ,
2008-11-04 01:14:30 +03:00
struct dm_list * lvh )
2008-04-10 05:30:22 +04:00
{
2008-11-04 01:14:30 +03:00
struct logical_volume * lv = dm_list_item ( lvh , struct lv_list ) - > lv ;
2008-04-10 05:30:22 +04:00
2008-11-04 01:14:30 +03:00
dm_list_move ( & vg_to - > lvs , lvh ) ;
2008-04-10 05:30:22 +04:00
2008-04-11 01:34:53 +04:00
if ( lv_is_active ( lv ) ) {
log_error ( " Logical volume \" %s \" must be inactive " , lv - > name ) ;
return 0 ;
}
2008-04-10 05:30:22 +04:00
if ( lv - > status & SNAPSHOT ) {
vg_from - > snapshot_count - - ;
vg_to - > snapshot_count + + ;
2008-04-23 18:33:06 +04:00
} else if ( ! lv_is_cow ( lv ) ) {
2008-04-10 05:30:22 +04:00
vg_from - > lv_count - - ;
vg_to - > lv_count + + ;
}
2008-04-11 01:34:53 +04:00
return 1 ;
2008-04-10 05:30:22 +04:00
}
2005-04-07 16:39:44 +04:00
2002-05-31 23:30:51 +04:00
static int _move_lvs ( struct volume_group * vg_from , struct volume_group * vg_to )
{
2008-11-04 01:14:30 +03:00
struct dm_list * lvh , * lvht ;
2002-05-31 23:30:51 +04:00
struct logical_volume * lv ;
2002-11-18 17:04:08 +03:00
struct lv_segment * seg ;
2002-05-31 23:30:51 +04:00
struct physical_volume * pv ;
struct volume_group * vg_with ;
2006-05-10 01:23:51 +04:00
unsigned s ;
2002-05-31 23:30:51 +04:00
2008-11-04 01:14:30 +03:00
dm_list_iterate_safe ( lvh , lvht , & vg_from - > lvs ) {
lv = dm_list_item ( lvh , struct lv_list ) - > lv ;
2002-05-31 23:30:51 +04:00
2005-04-07 16:39:44 +04:00
if ( ( lv - > status & SNAPSHOT ) )
continue ;
2007-01-30 02:01:18 +03:00
if ( ( lv - > status & MIRRORED ) )
continue ;
2002-05-31 23:30:51 +04:00
/* Ensure all the PVs used by this LV remain in the same */
/* VG as each other */
vg_with = NULL ;
2008-11-04 01:14:30 +03:00
dm_list_iterate_items ( seg , & lv - > segments ) {
2003-04-25 02:23:24 +04:00
for ( s = 0 ; s < seg - > area_count ; s + + ) {
/* FIXME Check AREA_LV too */
2005-06-01 20:51:55 +04:00
if ( seg_type ( seg , s ) ! = AREA_PV )
2003-04-25 02:23:24 +04:00
continue ;
2005-06-01 20:51:55 +04:00
pv = seg_pv ( seg , s ) ;
2002-05-31 23:30:51 +04:00
if ( vg_with ) {
2003-01-18 00:04:26 +03:00
if ( ! pv_is_in_vg ( vg_with , pv ) ) {
2007-01-10 00:12:41 +03:00
log_error ( " Can't split Logical "
" Volume %s between "
" two Volume Groups " ,
2002-05-31 23:30:51 +04:00
lv - > name ) ;
return 0 ;
}
continue ;
}
2003-01-18 00:04:26 +03:00
if ( pv_is_in_vg ( vg_from , pv ) ) {
2002-05-31 23:30:51 +04:00
vg_with = vg_from ;
continue ;
}
2003-01-18 00:04:26 +03:00
if ( pv_is_in_vg ( vg_to , pv ) ) {
2002-05-31 23:30:51 +04:00
vg_with = vg_to ;
continue ;
}
log_error ( " Physical Volume %s not found " ,
2007-10-12 18:29:32 +04:00
pv_dev_name ( pv ) ) ;
2002-05-31 23:30:51 +04:00
return 0 ;
}
2005-04-07 16:39:44 +04:00
}
2002-05-31 23:30:51 +04:00
if ( vg_with = = vg_from )
continue ;
/* Move this LV */
2008-04-11 01:34:53 +04:00
if ( ! _move_one_lv ( vg_from , vg_to , lvh ) )
2008-04-15 18:57:12 +04:00
return_0 ;
2002-05-31 23:30:51 +04:00
}
2003-04-25 02:23:24 +04:00
/* FIXME Ensure no LVs contain segs pointing at LVs in the other VG */
2002-05-31 23:30:51 +04:00
return 1 ;
}
2008-04-10 00:56:06 +04:00
/*
* Move the hidden / internal " snapshotN " LVs . from ' vg_from ' to ' vg_to ' .
*/
2005-04-07 16:39:44 +04:00
static int _move_snapshots ( struct volume_group * vg_from ,
struct volume_group * vg_to )
2002-05-31 23:30:51 +04:00
{
2008-11-04 01:14:30 +03:00
struct dm_list * lvh , * lvht ;
2005-04-07 16:39:44 +04:00
struct logical_volume * lv ;
struct lv_segment * seg ;
int cow_from = 0 ;
int origin_from = 0 ;
2002-05-31 23:30:51 +04:00
2008-11-04 01:14:30 +03:00
dm_list_iterate_safe ( lvh , lvht , & vg_from - > lvs ) {
lv = dm_list_item ( lvh , struct lv_list ) - > lv ;
2002-05-31 23:30:51 +04:00
2005-04-07 16:39:44 +04:00
if ( ! ( lv - > status & SNAPSHOT ) )
continue ;
2002-05-31 23:30:51 +04:00
2008-11-04 01:14:30 +03:00
dm_list_iterate_items ( seg , & lv - > segments ) {
2005-04-07 16:39:44 +04:00
cow_from = _lv_is_in_vg ( vg_from , seg - > cow ) ;
origin_from = _lv_is_in_vg ( vg_from , seg - > origin ) ;
2007-05-15 17:01:41 +04:00
if ( cow_from & & origin_from )
continue ;
if ( ( ! cow_from & & origin_from ) | |
( cow_from & & ! origin_from ) ) {
log_error ( " Can't split snapshot %s between "
" two Volume Groups " , seg - > cow - > name ) ;
return 0 ;
}
2005-04-07 16:39:44 +04:00
2008-04-10 00:56:06 +04:00
/*
* At this point , the cow and origin should already be
* in vg_to .
*/
if ( _lv_is_in_vg ( vg_to , seg - > cow ) & &
2008-04-11 01:34:53 +04:00
_lv_is_in_vg ( vg_to , seg - > origin ) ) {
if ( ! _move_one_lv ( vg_from , vg_to , lvh ) )
2008-04-15 18:57:12 +04:00
return_0 ;
2008-04-11 01:34:53 +04:00
}
2008-04-10 00:56:06 +04:00
}
2005-04-07 16:39:44 +04:00
2002-05-31 23:30:51 +04:00
}
return 1 ;
}
2007-01-30 02:01:18 +03:00
static int _move_mirrors ( struct volume_group * vg_from ,
struct volume_group * vg_to )
{
2008-11-04 01:14:30 +03:00
struct dm_list * lvh , * lvht ;
2007-01-30 02:01:18 +03:00
struct logical_volume * lv ;
struct lv_segment * seg ;
2007-08-22 18:38:18 +04:00
unsigned s , seg_in , log_in ;
2007-01-30 02:01:18 +03:00
2008-11-04 01:14:30 +03:00
dm_list_iterate_safe ( lvh , lvht , & vg_from - > lvs ) {
lv = dm_list_item ( lvh , struct lv_list ) - > lv ;
2007-01-30 02:01:18 +03:00
if ( ! ( lv - > status & MIRRORED ) )
continue ;
2008-01-30 17:00:02 +03:00
seg = first_seg ( lv ) ;
2007-01-30 02:01:18 +03:00
seg_in = 0 ;
2007-08-22 18:38:18 +04:00
for ( s = 0 ; s < seg - > area_count ; s + + )
if ( _lv_is_in_vg ( vg_to , seg_lv ( seg , s ) ) )
2007-01-30 02:01:18 +03:00
seg_in + + ;
log_in = ( ! seg - > log_lv | | _lv_is_in_vg ( vg_to , seg - > log_lv ) ) ;
2008-01-30 17:00:02 +03:00
if ( ( seg_in & & seg_in < seg - > area_count ) | |
( seg_in & & seg - > log_lv & & ! log_in ) | |
2007-01-30 02:01:18 +03:00
( ! seg_in & & seg - > log_lv & & log_in ) ) {
2007-05-15 17:01:41 +04:00
log_error ( " Can't split mirror %s between "
" two Volume Groups " , lv - > name ) ;
2007-01-30 02:01:18 +03:00
return 0 ;
}
2008-04-11 01:34:53 +04:00
if ( seg_in = = seg - > area_count & & log_in ) {
if ( ! _move_one_lv ( vg_from , vg_to , lvh ) )
2008-04-15 18:57:12 +04:00
return_0 ;
2008-04-11 01:34:53 +04:00
}
2007-01-30 02:01:18 +03:00
}
return 1 ;
}
2008-01-22 05:48:53 +03:00
/*
* Has the user given an option related to a new vg as the split destination ?
*/
static int new_vg_option_specified ( struct cmd_context * cmd )
{
return ( arg_count ( cmd , clustered_ARG ) | |
arg_count ( cmd , alloc_ARG ) | |
arg_count ( cmd , maxphysicalvolumes_ARG ) | |
arg_count ( cmd , maxlogicalvolumes_ARG ) ) ;
}
2002-05-31 23:30:51 +04:00
int vgsplit ( struct cmd_context * cmd , int argc , char * * argv )
{
2008-01-16 01:56:30 +03:00
struct vgcreate_params vp_new ;
struct vgcreate_params vp_def ;
2002-05-31 23:30:51 +04:00
char * vg_name_from , * vg_name_to ;
struct volume_group * vg_to , * vg_from ;
int opt ;
2008-01-22 06:25:45 +03:00
int existing_vg ;
2008-04-02 23:30:12 +04:00
int consistent ;
2008-04-09 17:47:13 +04:00
const char * lv_name ;
2002-05-31 23:30:51 +04:00
2008-04-09 17:47:13 +04:00
if ( ( arg_count ( cmd , name_ARG ) + argc ) < 3 ) {
log_error ( " Existing VG, new VG and either physical volumes "
" or logical volume required. " ) ;
2002-05-31 23:30:51 +04:00
return EINVALID_CMD_LINE ;
}
2008-04-09 17:47:13 +04:00
if ( arg_count ( cmd , name_ARG ) & & ( argc > 2 ) ) {
log_error ( " A logical volume name cannot be given with "
" physical volumes. " ) ;
return ECMD_FAILED ;
}
if ( arg_count ( cmd , name_ARG ) )
lv_name = arg_value ( cmd , name_ARG ) ;
else
lv_name = NULL ;
2007-03-10 00:25:33 +03:00
vg_name_from = skip_dev_dir ( cmd , argv [ 0 ] , NULL ) ;
vg_name_to = skip_dev_dir ( cmd , argv [ 1 ] , NULL ) ;
2002-05-31 23:30:51 +04:00
argc - = 2 ;
argv + = 2 ;
if ( ! strcmp ( vg_name_to , vg_name_from ) ) {
log_error ( " Duplicate volume group name \" %s \" " , vg_name_from ) ;
return ECMD_FAILED ;
}
log_verbose ( " Checking for volume group \" %s \" " , vg_name_from ) ;
2007-11-15 05:20:03 +03:00
if ( ! ( vg_from = vg_lock_and_read ( cmd , vg_name_from , NULL , LCK_VG_WRITE ,
2007-07-23 21:27:55 +04:00
CLUSTERED | EXPORTED_VG |
2007-07-24 01:03:42 +04:00
RESIZEABLE_VG | LVM_WRITE ,
CORRECT_INCONSISTENT | FAIL_INCONSISTENT ) ) )
2007-07-23 21:27:55 +04:00
return ECMD_FAILED ;
2002-05-31 23:30:51 +04:00
2007-11-15 05:53:49 +03:00
log_verbose ( " Checking for new volume group \" %s \" " , vg_name_to ) ;
2008-04-02 23:30:12 +04:00
if ( ! lock_vol ( cmd , vg_name_to , LCK_VG_WRITE | LCK_NONBLOCK ) ) {
log_error ( " Can't get lock for %s " , vg_name_to ) ;
unlock_vg ( cmd , vg_name_from ) ;
return ECMD_FAILED ;
}
consistent = 0 ;
2009-01-26 22:01:32 +03:00
if ( ( vg_to = vg_read_internal ( cmd , vg_name_to , NULL , & consistent ) ) ) {
2008-01-22 06:25:45 +03:00
existing_vg = 1 ;
2008-01-22 05:48:53 +03:00
if ( new_vg_option_specified ( cmd ) ) {
log_error ( " Volume group \" %s \" exists, but new VG "
" option specified " , vg_name_to ) ;
2008-04-10 23:59:43 +04:00
goto_bad ;
2008-01-22 05:48:53 +03:00
}
2008-01-16 22:54:39 +03:00
if ( ! vgs_are_compatible ( cmd , vg_from , vg_to ) )
2008-04-10 23:59:43 +04:00
goto_bad ;
2008-01-12 00:43:16 +03:00
} else {
2008-01-22 06:25:45 +03:00
existing_vg = 0 ;
2008-01-12 00:43:16 +03:00
/* Set metadata format of original VG */
/* FIXME: need some common logic */
cmd - > fmt = vg_from - > fid - > fmt ;
2008-01-16 01:56:30 +03:00
vp_def . vg_name = NULL ;
vp_def . extent_size = vg_from - > extent_size ;
vp_def . max_pv = vg_from - > max_pv ;
vp_def . max_lv = vg_from - > max_lv ;
vp_def . alloc = vg_from - > alloc ;
vp_def . clustered = 0 ;
2008-01-22 06:25:45 +03:00
if ( fill_vg_create_params ( cmd , vg_name_to , & vp_new , & vp_def ) ) {
unlock_vg ( cmd , vg_name_from ) ;
2008-04-09 01:38:09 +04:00
unlock_vg ( cmd , vg_name_to ) ;
2008-01-15 00:07:58 +03:00
return EINVALID_CMD_LINE ;
2008-01-22 06:25:45 +03:00
}
2008-01-15 00:07:58 +03:00
2008-01-22 06:25:45 +03:00
if ( validate_vg_create_params ( cmd , & vp_new ) ) {
unlock_vg ( cmd , vg_name_from ) ;
2008-04-09 01:38:09 +04:00
unlock_vg ( cmd , vg_name_to ) ;
2008-01-15 00:07:58 +03:00
return EINVALID_CMD_LINE ;
2008-01-22 06:25:45 +03:00
}
2008-01-15 00:07:58 +03:00
2008-01-16 01:56:30 +03:00
if ( ! ( vg_to = vg_create ( cmd , vg_name_to , vp_new . extent_size ,
vp_new . max_pv , vp_new . max_lv ,
vp_new . alloc , 0 , NULL ) ) )
2008-04-10 23:59:43 +04:00
goto_bad ;
2002-05-31 23:30:51 +04:00
2008-04-10 21:09:32 +04:00
if ( vg_is_clustered ( vg_from ) )
2008-01-12 00:43:16 +03:00
vg_to - > status | = CLUSTERED ;
}
2006-10-13 17:22:44 +04:00
2002-05-31 23:30:51 +04:00
/* Archive vg_from before changing it */
if ( ! archive ( vg_from ) )
2008-04-10 23:59:43 +04:00
goto_bad ;
2002-05-31 23:30:51 +04:00
/* Move PVs across to new structure */
for ( opt = 0 ; opt < argc ; opt + + ) {
2008-04-09 17:47:13 +04:00
if ( ! _move_pv ( vg_from , vg_to , argv [ opt ] ) )
2008-04-10 23:59:43 +04:00
goto_bad ;
2008-04-09 17:47:13 +04:00
}
2008-02-29 03:13:48 +03:00
2008-04-09 17:47:13 +04:00
/* If an LV given on the cmdline, move used_by PVs */
2008-04-10 23:59:43 +04:00
if ( lv_name & & ! _move_pvs_used_by_lv ( vg_from , vg_to , lv_name ) )
goto_bad ;
2002-05-31 23:30:51 +04:00
/* Move required LVs across, checking consistency */
if ( ! ( _move_lvs ( vg_from , vg_to ) ) )
2008-04-10 23:59:43 +04:00
goto_bad ;
2002-05-31 23:30:51 +04:00
/* Move required snapshots across */
if ( ! ( _move_snapshots ( vg_from , vg_to ) ) )
2008-04-10 23:59:43 +04:00
goto_bad ;
2002-05-31 23:30:51 +04:00
2007-01-30 02:01:18 +03:00
/* Move required mirrors across */
if ( ! ( _move_mirrors ( vg_from , vg_to ) ) )
2008-04-10 23:59:43 +04:00
goto_bad ;
2007-01-30 02:01:18 +03:00
2007-03-23 15:43:17 +03:00
/* Split metadata areas and check if both vgs have at least one area */
2007-06-28 21:59:34 +04:00
if ( ! ( vg_split_mdas ( cmd , vg_from , vg_to ) ) & & vg_from - > pv_count ) {
2007-03-23 15:43:17 +03:00
log_error ( " Cannot split: Nowhere to store metadata for new Volume Group " ) ;
2008-04-10 23:59:43 +04:00
goto_bad ;
2007-03-23 15:43:17 +03:00
}
/* Set proper name for all PVs in new VG */
if ( ! vg_rename ( cmd , vg_to , vg_name_to ) )
2008-04-10 23:59:43 +04:00
goto_bad ;
2002-11-18 17:04:08 +03:00
2002-05-31 23:30:51 +04:00
/* store it on disks */
log_verbose ( " Writing out updated volume groups " ) ;
2008-04-02 23:30:12 +04:00
/*
* First , write out the new VG as EXPORTED . We do this first in case
* there is a crash - we will still have the new VG information , in an
* exported state . Recovery after this point would be removal of the
* new VG and redoing the vgsplit .
* FIXME : recover automatically or instruct the user ?
*/
2002-05-31 23:30:51 +04:00
vg_to - > status | = EXPORTED_VG ;
if ( ! archive ( vg_to ) )
2008-04-10 23:59:43 +04:00
goto_bad ;
2002-05-31 23:30:51 +04:00
2003-07-05 02:34:56 +04:00
if ( ! vg_write ( vg_to ) | | ! vg_commit ( vg_to ) )
2008-04-10 23:59:43 +04:00
goto_bad ;
2002-05-31 23:30:51 +04:00
backup ( vg_to ) ;
2008-04-02 23:30:12 +04:00
/*
* Next , write out the updated old VG . If we crash after this point ,
* recovery is a vgimport on the new VG .
2008-04-10 23:59:43 +04:00
* FIXME : recover automatically or instruct the user ?
2008-04-02 23:30:12 +04:00
*/
2007-06-28 21:59:34 +04:00
if ( vg_from - > pv_count ) {
if ( ! vg_write ( vg_from ) | | ! vg_commit ( vg_from ) )
2008-04-10 23:59:43 +04:00
goto_bad ;
2002-05-31 23:30:51 +04:00
2007-06-28 21:59:34 +04:00
backup ( vg_from ) ;
}
2002-05-31 23:30:51 +04:00
2008-04-02 23:30:12 +04:00
/*
* Finally , remove the EXPORTED flag from the new VG and write it out .
*/
consistent = 1 ;
2008-01-22 06:49:39 +03:00
if ( ! test_mode ( ) & &
2009-01-26 22:01:32 +03:00
( ! ( vg_to = vg_read_internal ( cmd , vg_name_to , NULL , & consistent ) ) | |
2008-04-10 23:59:43 +04:00
! consistent ) ) {
2002-11-18 17:04:08 +03:00
log_error ( " Volume group \" %s \" became inconsistent: please "
" fix manually " , vg_name_to ) ;
2008-04-10 23:59:43 +04:00
goto_bad ;
2002-11-18 17:04:08 +03:00
}
2002-05-31 23:30:51 +04:00
vg_to - > status & = ~ EXPORTED_VG ;
2003-09-15 19:03:54 +04:00
if ( ! vg_write ( vg_to ) | | ! vg_commit ( vg_to ) )
2008-04-10 23:59:43 +04:00
goto_bad ;
2002-05-31 23:30:51 +04:00
backup ( vg_to ) ;
unlock_vg ( cmd , vg_name_from ) ;
unlock_vg ( cmd , vg_name_to ) ;
2008-01-22 06:25:45 +03:00
log_print ( " %s volume group \" %s \" successfully split from \" %s \" " ,
existing_vg ? " Existing " : " New " ,
2002-05-31 23:30:51 +04:00
vg_to - > name , vg_from - > name ) ;
2003-10-22 02:06:07 +04:00
return ECMD_PROCESSED ;
2002-05-31 23:30:51 +04:00
2008-04-09 17:47:13 +04:00
bad :
2002-05-31 23:30:51 +04:00
unlock_vg ( cmd , vg_name_from ) ;
unlock_vg ( cmd , vg_name_to ) ;
return ECMD_FAILED ;
}