master - redefine pvcreate structs
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=4de6caf5b5a1b7eef80fc9ed56ac0cf8b7776ac4 Commit: 4de6caf5b5a1b7eef80fc9ed56ac0cf8b7776ac4 Parent: c201ee09bdfdfccecd5975ee26537cf790b25e25 Author: David Teigland <[email protected]> AuthorDate: Thu Feb 18 15:31:27 2016 -0600 Committer: David Teigland <[email protected]> CommitterDate: Thu Feb 25 09:14:10 2016 -0600
redefine pvcreate structs
New pv_create_args struct contains all the specific parameters for creating a PV, independent of the command.
--- lib/format1/format1.c | 32 ++++++------- lib/format_pool/format_pool.c | 5 +-- lib/format_text/archiver.c | 27 +++-------- lib/format_text/archiver.h | 5 +-- lib/format_text/format-text.c | 43 +++++++++--------- lib/metadata/metadata-exported.h | 55 ++++++++-------------- lib/metadata/metadata.c | 86 ++++++++++++++---------------------- lib/metadata/metadata.h | 5 +-- liblvm/lvm_prop.c | 20 ++++---- liblvm/lvm_pv.c | 8 ++-- tools/pvcreate.c | 16 +++--- tools/toollib.c | 92 ++++++++++++++++---------------------- tools/vgconvert.c | 24 ++++------ 13 files changed, 168 insertions(+), 250 deletions(-)
lib/format1/format1.c +14 -18
@@ -345,10 +345,7 @@ static int _format1_pv_read(const struct format_type *fmt, const char *pv_name, }static int _format1_pv_initialise (const struct format_type * fmt, -int64_t label_sector __attribute__((unused)), -unsigned long data_alignment __attribute__((unused)), -unsigned long data_alignment_offset __attribute__((unused)), -struct pvcreate_restorable_params *rp, +struct pv_create_args *pva,struct physical_volume * pv) {if (pv->size >MAX_PV_SIZE )
@@ -360,18 +357,18 @@ static int _format1_pv_initialise(const struct format_type * fmt, }/* Nothing more to do if extent size isn't provided */ -if (!rp->extent_size) +if (!pva->extent_size)return 1 ;/* * This works out pe_start and pe_count. */ -if (!calculate_extent_count (pv, rp->extent_size, rp->extent_count, rp->pe_start)) +if (!calculate_extent_count (pv, pva->extent_size, pva->extent_count, pva->pe_start)) return_0;/* Retain existing extent locations exactly */ -if (((rp->pe_start || rp->extent_count) && (rp->pe_start != pv->pe_start)) || - (rp->extent_count && (rp->extent_count != pv->pe_count))) { +if (((pva->pe_start || pva->extent_count) && (pva->pe_start != pv->pe_start)) || + (pva->extent_count && (pva->extent_count != pv->pe_count))) {log_error ("Metadata would overwrite physical extents" );return 0 ; }
@@ -383,16 +380,15 @@ static int _format1_pv_setup(const struct format_type *fmt,struct physical_volume *pv, struct volume_group *vg) { - struct pvcreate_restorable_params rp = {.restorefile = NULL, - .id = {{0 }}, - .idp =NULL , - .ba_start =0 , - .ba_size =0 , - .pe_start =0 , - .extent_count =0 , - .extent_size = vg->extent_size}; - -return _format1_pv_initialise (fmt,-1 ,0 ,0 , &rp, pv); + struct pv_create_args pva = { .id = {{0}}, + .idp =NULL , + .ba_start =0 , + .ba_size =0 , + .pe_start =0 , + .extent_count =0 , + .extent_size = vg->extent_size}; + +return _format1_pv_initialise (fmt, &pva, pv); }static int _format1_lv_setup (struct format_instance *fid,struct logical_volume *lv)
lib/format_pool/format_pool.c +1 -4
@@ -166,10 +166,7 @@ bad: }static int _pool_pv_initialise (const struct format_type *fmt __attribute__((unused)), -int64_t label_sector __attribute__((unused)), -unsigned long data_alignment __attribute__((unused)), -unsigned long data_alignment_offset __attribute__((unused)), -struct pvcreate_restorable_params *rp __attribute__((unused)), +struct pv_create_args *pva __attribute__((unused)),struct physical_volume *pv __attribute__((unused))) {return 1 ;
lib/format_text/archiver.c +8 -19
@@ -361,13 +361,8 @@ static int _restore_vg_should_write_pv(struct physical_volume *pv, int do_pvcreaint backup_restore_vg (struct cmd_context *cmd,struct volume_group *vg,int drop_lvmetad,int do_pvcreate, -uint64_t bootloaderareasize, -int pvmetadatacopies, -uint64_t pvmetadatasize, -uint64_t label_sector) - +struct pv_create_args *pva) { -struct pvcreate_restorable_params rp = {0 };struct dm_list new_pvs;struct pv_list *pvl, *new_pvl;struct physical_volume *existing_pv, *pv;
@@ -389,20 +384,14 @@ int backup_restore_vg(struct cmd_context *cmd, struct volume_group *vg, dm_list_iterate_items(pvl, &vg->pvs) { existing_pv = pvl->pv; - rp.id = existing_pv->id; - rp.idp = &rp.id; - rp.pe_start =pv_pe_start (existing_pv); - rp.extent_count =pv_pe_count (existing_pv); - rp.extent_size =pv_pe_size (existing_pv); - rp.ba_size = bootloaderareasize; + pva->id = existing_pv->id; + pva->idp = &pva->id; + pva->pe_start =pv_pe_start (existing_pv); + pva->extent_count =pv_pe_count (existing_pv); + pva->extent_size =pv_pe_size (existing_pv);/* pe_end = pv_pe_count(existing_pv) * pv_pe_size(existing_pv) + pe_start - 1 */ -if (!(pv =pv_create (cmd,pv_dev (existing_pv), -0 ,0 ,0 , - label_sector, - pvmetadatacopies, - pvmetadatasize, -0 , &rp))) { +if (!(pv =pv_create (cmd,pv_dev (existing_pv), pva))) {log_error ("Failed to setup physical volume \"%s\"." ,pv_dev_name (existing_pv));return 0 ;
@@ -561,7 +550,7 @@ int backup_restore_from_file(struct cmd_context *cmd, const char *vg_name, missing_pvs =vg_missing_pv_count (vg);if (missing_pvs ==0 ) - r =backup_restore_vg (cmd, vg,1 ,0 ,0 ,0 ,0 ,0 ); + r =backup_restore_vg (cmd, vg,1 ,0 ,NULL );else log_error ("Cannot restore Volume Group %s with %i PVs " "marked as missing." , vg->name, missing_pvs);
lib/format_text/archiver.h +1 -4
@@ -55,10 +55,7 @@ struct volume_group *backup_read_vg(struct cmd_context *cmd,int backup_restore_vg (struct cmd_context *cmd,struct volume_group *vg,int drop_lvmetad,int do_pvcreate, -uint64_t bootloaderareasize, -int pvmetadatacopies, -uint64_t pvmetadatasize, -uint64_t label_sector); +struct pv_create_args *pva);int backup_restore_from_file (struct cmd_context *cmd,const char *vg_name,const char *file,int force);
lib/format_text/format-text.c +21 -22
90 lines not on this page · raw message
lib/metadata/metadata-exported.h +20 -35
92 lines not on this page · raw message
lib/metadata/metadata.c +33 -53
157 lines not on this page · raw message
lib/metadata/metadata.h +1 -4
@@ -256,10 +256,7 @@ struct format_handler {* Initialise a new PV. */ int (*pv_initialise) (const struct format_type * fmt, -int64_t label_sector, -unsigned long data_alignment, -unsigned long data_alignment_offset, -struct pvcreate_restorable_params *rp, +struct pv_create_args *pva,struct physical_volume * pv);/*
liblvm/lvm_prop.c +10 -10
@@ -21,20 +21,20 @@ GET_LVCREATEPARAMS_NUM_PROPERTY_FN(skip_zero, lvcp->zero)SET_LVCREATEPARAMS_NUM_PROPERTY_FN (skip_zero, lvcp->zero) /* PV create parameters */ -GET_PVCREATEPARAMS_NUM_PROPERTY_FN(size, pvcp->size) -SET_PVCREATEPARAMS_NUM_PROPERTY_FN(size, pvcp->size) +GET_PVCREATEPARAMS_NUM_PROPERTY_FN(size, pvcp->pva.size) +SET_PVCREATEPARAMS_NUM_PROPERTY_FN(size, pvcp->pva.size) -GET_PVCREATEPARAMS_NUM_PROPERTY_FN(pvmetadatacopies, pvcp->pvmetadatacopies) -SET_PVCREATEPARAMS_NUM_PROPERTY_FN(pvmetadatacopies, pvcp->pvmetadatacopies) +GET_PVCREATEPARAMS_NUM_PROPERTY_FN(pvmetadatacopies, pvcp->pva.pvmetadatacopies) +SET_PVCREATEPARAMS_NUM_PROPERTY_FN(pvmetadatacopies, pvcp->pva.pvmetadatacopies) -GET_PVCREATEPARAMS_NUM_PROPERTY_FN(pvmetadatasize, pvcp->pvmetadatasize) -SET_PVCREATEPARAMS_NUM_PROPERTY_FN(pvmetadatasize, pvcp->pvmetadatasize) +GET_PVCREATEPARAMS_NUM_PROPERTY_FN(pvmetadatasize, pvcp->pva.pvmetadatasize) +SET_PVCREATEPARAMS_NUM_PROPERTY_FN(pvmetadatasize, pvcp->pva.pvmetadatasize) -GET_PVCREATEPARAMS_NUM_PROPERTY_FN(data_alignment, pvcp->data_alignment) -SET_PVCREATEPARAMS_NUM_PROPERTY_FN(data_alignment, pvcp->data_alignment) +GET_PVCREATEPARAMS_NUM_PROPERTY_FN(data_alignment, pvcp->pva.data_alignment) +SET_PVCREATEPARAMS_NUM_PROPERTY_FN(data_alignment, pvcp->pva.data_alignment) -GET_PVCREATEPARAMS_NUM_PROPERTY_FN(data_alignment_offset, pvcp->data_alignment_offset) -SET_PVCREATEPARAMS_NUM_PROPERTY_FN(data_alignment_offset, pvcp->data_alignment_offset) +GET_PVCREATEPARAMS_NUM_PROPERTY_FN(data_alignment_offset, pvcp->pva.data_alignment_offset) +SET_PVCREATEPARAMS_NUM_PROPERTY_FN(data_alignment_offset, pvcp->pva.data_alignment_offset) GET_PVCREATEPARAMS_NUM_PROPERTY_FN(zero, pvcp->zero)SET_PVCREATEPARAMS_NUM_PROPERTY_FN (zero, pvcp->zero)
liblvm/lvm_pv.c +4 -4
@@ -421,12 +421,12 @@ static int _pv_create(pv_create_params_t params)struct cmd_context *cmd = (struct cmd_context *)params->libh;int rc =0 ; -if (params->pv_p.size) { -if (params->pv_p.size %SECTOR_SIZE ) { +if (params->pv_p.pva.size) { +if (params->pv_p.pva.size %SECTOR_SIZE ) {log_errno (EINVAL ,"Size not a multiple of 512" );return -1 ; } - params->pv_p.size = params->pv_p.size >>SECTOR_SHIFT ; + params->pv_p.pva.size = params->pv_p.pva.size >>SECTOR_SHIFT ; }if (!lock_vol (cmd,VG_ORPHANS ,LCK_VG_WRITE ,NULL )) {
@@ -448,7 +448,7 @@ int lvm_pv_create(lvm_t libh, const char *pv_name, uint64_t size)struct saved_env e =store_user_env ((struct cmd_context *)libh);if (_lvm_pv_params_create (libh, pv_name, &pp)) { - pp.pv_p.size = size; + pp.pv_p.pva.size = size; rc =_pv_create (&pp); }
tools/pvcreate.c +8 -8
@@ -47,7 +47,7 @@ static int pvcreate_each_restore_params_from_args(struct cmd_context *cmd, int aif (arg_count (cmd, uuidstr_ARG)) { pp->uuid_str =arg_str_value (cmd, uuidstr_ARG,"" ); -if (!id_read_format (&pp->id, pp->uuid_str)) +if (!id_read_format (&pp->pva.id, pp->uuid_str))return 0 ; }
@@ -55,7 +55,7 @@ static int pvcreate_each_restore_params_from_args(struct cmd_context *cmd, int alog_error ("Physical volume size may not be negative" );return 0 ; } - pp->size =arg_uint64_value (cmd, physicalvolumesize_ARG,UINT64_C (0 )); + pp->pva.size =arg_uint64_value (cmd, physicalvolumesize_ARG,UINT64_C (0 ));if (arg_count (cmd, restorefile_ARG) ||arg_count (cmd, uuidstr_ARG)) pp->zero =0 ;
@@ -79,18 +79,18 @@ static int pvcreate_each_restore_params_from_backup(struct cmd_context *cmd,return 0 ; } -if (!(existing_pvl =find_pv_in_vg_by_uuid (vg, &pp->id))) { +if (!(existing_pvl =find_pv_in_vg_by_uuid (vg, &pp->pva.id))) {release_vg (vg);log_error ("Can't find uuid %s in backup file %s" , pp->uuid_str, pp->restorefile);return 0 ; } - pp->ba_start =pv_ba_start (existing_pvl->pv); - pp->ba_size =pv_ba_size (existing_pvl->pv); - pp->pe_start =pv_pe_start (existing_pvl->pv); - pp->extent_size =pv_pe_size (existing_pvl->pv); - pp->extent_count =pv_pe_count (existing_pvl->pv); + pp->pva.ba_start =pv_ba_start (existing_pvl->pv); + pp->pva.ba_size =pv_ba_size (existing_pvl->pv); + pp->pva.pe_start =pv_pe_start (existing_pvl->pv); + pp->pva.extent_size =pv_pe_size (existing_pvl->pv); + pp->pva.extent_count =pv_pe_count (existing_pvl->pv);release_vg (vg);return 1 ;
tools/toollib.c +38 -54
169 lines not on this page · raw message
tools/vgconvert.c +9 -15
@@ -19,13 +19,11 @@ static int vgconvert_single(struct cmd_context *cmd, const char *vg_name,struct volume_group *vg, struct processing_handle *handle __attribute__((unused))) { +struct pv_create_args pva = {0 };struct logical_volume *lv;struct lv_list *lvl;struct lvinfo info;int active =0 ; -int pvmetadatacopies =0 ; -uint64_t pvmetadatasize =0 ; -uint64_t bootloaderareasize =0 ;if (!vg_check_status (vg,LVM_WRITE |EXPORTED_VG )) return_ECMD_FAILED;
@@ -42,13 +40,13 @@ static int vgconvert_single(struct cmd_context *cmd, const char *vg_name,return EINVALID_CMD_LINE ; } - pvmetadatasize =arg_uint64_value (cmd, metadatasize_ARG,UINT64_C (0 )); -if (!pvmetadatasize) - pvmetadatasize =find_config_tree_int (cmd, metadata_pvmetadatasize_CFG,NULL ); + pva.pvmetadatasize =arg_uint64_value (cmd, metadatasize_ARG,UINT64_C (0 )); +if (!pva.pvmetadatasize) + pva.pvmetadatasize =find_config_tree_int (cmd, metadata_pvmetadatasize_CFG,NULL ); - pvmetadatacopies =arg_int_value (cmd, pvmetadatacopies_ARG,-1 ); -if (pvmetadatacopies <0 ) - pvmetadatacopies =find_config_tree_int (cmd, metadata_pvmetadatacopies_CFG,NULL ); + pva.pvmetadatacopies =arg_int_value (cmd, pvmetadatacopies_ARG,-1 ); +if (pva.pvmetadatacopies <0 ) + pva.pvmetadatacopies =find_config_tree_int (cmd, metadata_pvmetadatacopies_CFG,NULL ); }if (cmd->fmt->features &FMT_BAS ) {
@@ -57,7 +55,7 @@ static int vgconvert_single(struct cmd_context *cmd, const char *vg_name,return EINVALID_CMD_LINE ; } - bootloaderareasize =arg_uint64_value (cmd, bootloaderareasize_ARG,UINT64_C (0 )); + pva.ba_size =arg_uint64_value (cmd, bootloaderareasize_ARG,UINT64_C (0 )); }if (!vg_check_new_extent_size (cmd->fmt, vg->extent_size))
@@ -128,11 +126,7 @@ static int vgconvert_single(struct cmd_context *cmd, const char *vg_name,log_verbose ("Writing metadata for VG %s using format %s" , vg_name, cmd->fmt->name); -if (!backup_restore_vg (cmd, vg,0 ,1 , - bootloaderareasize, - pvmetadatacopies, - pvmetadatasize, -arg_int64_value (cmd, labelsector_ARG,DEFAULT_LABELSECTOR ))) { +if (!backup_restore_vg (cmd, vg,0 ,1 , &pva)) {log_error ("Conversion failed for volume group %s." , vg_name);log_error ("Use pvcreate and vgcfgrestore to repair from " "archived metadata." );