mirror of
git://sourceware.org/git/lvm2.git
synced 2025-01-04 09:18:36 +03:00
Convert find_pv_in_vg_by_uuid and pv_create to use PV handles
This commit is contained in:
parent
fc2063b660
commit
b496210d9a
@ -1,5 +1,6 @@
|
|||||||
Version 2.02.26 -
|
Version 2.02.26 -
|
||||||
=================================
|
=================================
|
||||||
|
Convert find_pv_in_vg_by_uuid and pv_create to use PV handles.
|
||||||
Add get_pv_* functions to return PV members (external LVM library).
|
Add get_pv_* functions to return PV members (external LVM library).
|
||||||
Add wrappers to some functions in preparation for external LVM library.
|
Add wrappers to some functions in preparation for external LVM library.
|
||||||
Allow vgcfgrestore to list metadata backup files using -f
|
Allow vgcfgrestore to list metadata backup files using -f
|
||||||
|
@ -566,8 +566,27 @@ int vg_split_mdas(struct cmd_context *cmd, struct volume_group *vg_from,
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* FIXME: liblvm todo - make into function that returns handle */
|
/**
|
||||||
struct physical_volume *pv_create(const struct format_type *fmt,
|
* pv_create - initialize a physical volume for use with a volume group
|
||||||
|
* @fmt: format type
|
||||||
|
* @dev: PV device to initialize
|
||||||
|
* @id: PV UUID to use for initialization
|
||||||
|
* @size: size of the PV in sectors
|
||||||
|
* @pe_start: physical extent start
|
||||||
|
* @existing_extent_count
|
||||||
|
* @existing_extent_size
|
||||||
|
* @pvmetadatacopies
|
||||||
|
* @pvmetadatasize
|
||||||
|
* @mdas
|
||||||
|
*
|
||||||
|
* Returns:
|
||||||
|
* PV handle - physical volume initialized successfully
|
||||||
|
* NULL - invalid parameter or problem initializing the physical volume
|
||||||
|
*
|
||||||
|
* Note:
|
||||||
|
* FIXME - liblvm todo - tidy up arguments for external use (fmt, mdas, etc)
|
||||||
|
*/
|
||||||
|
void *pv_create(const struct format_type *fmt,
|
||||||
struct device *dev,
|
struct device *dev,
|
||||||
struct id *id, uint64_t size,
|
struct id *id, uint64_t size,
|
||||||
uint64_t pe_start,
|
uint64_t pe_start,
|
||||||
@ -688,9 +707,19 @@ int pv_is_in_vg(struct volume_group *vg, struct physical_volume *pv)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* FIXME: liblvm todo - make into function that returns handle */
|
/**
|
||||||
struct physical_volume *find_pv_in_vg_by_uuid(struct volume_group *vg,
|
* find_pv_in_vg_by_uuid - Find PV in VG by PV UUID
|
||||||
struct id *id)
|
* @vg: volume group to search
|
||||||
|
* @id: UUID of the PV to match
|
||||||
|
*
|
||||||
|
* Returns:
|
||||||
|
* PV handle - if UUID of PV found in VG
|
||||||
|
* NULL - invalid parameter or UUID of PV not found in VG
|
||||||
|
*
|
||||||
|
* Note
|
||||||
|
* FIXME - liblvm todo - make into function that takes VG handle
|
||||||
|
*/
|
||||||
|
void *find_pv_in_vg_by_uuid(struct volume_group *vg, struct id *id)
|
||||||
{
|
{
|
||||||
return _find_pv_in_vg_by_uuid(vg, id);
|
return _find_pv_in_vg_by_uuid(vg, id);
|
||||||
}
|
}
|
||||||
|
@ -438,7 +438,7 @@ int pv_write_orphan(struct cmd_context *cmd, struct physical_volume *pv);
|
|||||||
|
|
||||||
/* pe_start and pe_end relate to any existing data so that new metadata
|
/* pe_start and pe_end relate to any existing data so that new metadata
|
||||||
* areas can avoid overlap */
|
* areas can avoid overlap */
|
||||||
struct physical_volume *pv_create(const struct format_type *fmt,
|
void *pv_create(const struct format_type *fmt,
|
||||||
struct device *dev,
|
struct device *dev,
|
||||||
struct id *id,
|
struct id *id,
|
||||||
uint64_t size,
|
uint64_t size,
|
||||||
@ -500,8 +500,7 @@ struct physical_volume *pv_find(struct volume_group *vg, const char *pv_name);
|
|||||||
|
|
||||||
/* Find a PV within a given VG */
|
/* Find a PV within a given VG */
|
||||||
struct pv_list *find_pv_in_vg(struct volume_group *vg, const char *pv_name);
|
struct pv_list *find_pv_in_vg(struct volume_group *vg, const char *pv_name);
|
||||||
struct physical_volume *find_pv_in_vg_by_uuid(struct volume_group *vg,
|
void *find_pv_in_vg_by_uuid(struct volume_group *vg, struct id *id);
|
||||||
struct id *id);
|
|
||||||
int get_pv_from_vg_by_id(const struct format_type *fmt, const char *vg_name,
|
int get_pv_from_vg_by_id(const struct format_type *fmt, const char *vg_name,
|
||||||
const char *vgid, const char *pvid,
|
const char *vgid, const char *pvid,
|
||||||
struct physical_volume *pv);
|
struct physical_volume *pv);
|
||||||
|
@ -118,7 +118,8 @@ static int pvcreate_single(struct cmd_context *cmd, const char *pv_name,
|
|||||||
void *handle)
|
void *handle)
|
||||||
{
|
{
|
||||||
struct pvcreate_params *pp = (struct pvcreate_params *) handle;
|
struct pvcreate_params *pp = (struct pvcreate_params *) handle;
|
||||||
struct physical_volume *pv, *existing_pv;
|
void *pv;
|
||||||
|
void *existing_pv;
|
||||||
struct id id, *idp = NULL;
|
struct id id, *idp = NULL;
|
||||||
const char *uuid = NULL;
|
const char *uuid = NULL;
|
||||||
uint64_t size = 0;
|
uint64_t size = 0;
|
||||||
@ -159,9 +160,9 @@ static int pvcreate_single(struct cmd_context *cmd, const char *pv_name,
|
|||||||
uuid, restorefile);
|
uuid, restorefile);
|
||||||
return ECMD_FAILED;
|
return ECMD_FAILED;
|
||||||
}
|
}
|
||||||
pe_start = existing_pv->pe_start;
|
pe_start = get_pv_pe_start(existing_pv);
|
||||||
extent_size = existing_pv->pe_size;
|
extent_size = get_pv_pe_size(existing_pv);
|
||||||
extent_count = existing_pv->pe_count;
|
extent_count = get_pv_pe_count(existing_pv);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!lock_vol(cmd, ORPHAN, LCK_VG_WRITE)) {
|
if (!lock_vol(cmd, ORPHAN, LCK_VG_WRITE)) {
|
||||||
@ -210,10 +211,10 @@ static int pvcreate_single(struct cmd_context *cmd, const char *pv_name,
|
|||||||
}
|
}
|
||||||
|
|
||||||
log_verbose("Set up physical volume for \"%s\" with %" PRIu64
|
log_verbose("Set up physical volume for \"%s\" with %" PRIu64
|
||||||
" available sectors", pv_name, pv->size);
|
" available sectors", pv_name, get_pv_size(pv));
|
||||||
|
|
||||||
/* Wipe existing label first */
|
/* Wipe existing label first */
|
||||||
if (!label_remove(pv->dev)) {
|
if (!label_remove(get_pv_dev(pv))) {
|
||||||
log_error("Failed to wipe existing label on %s", pv_name);
|
log_error("Failed to wipe existing label on %s", pv_name);
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
@ -235,7 +236,8 @@ static int pvcreate_single(struct cmd_context *cmd, const char *pv_name,
|
|||||||
|
|
||||||
log_very_verbose("Writing physical volume data to disk \"%s\"",
|
log_very_verbose("Writing physical volume data to disk \"%s\"",
|
||||||
pv_name);
|
pv_name);
|
||||||
if (!(pv_write(cmd, pv, &mdas, arg_int64_value(cmd, labelsector_ARG,
|
if (!(pv_write(cmd, (struct physical_volume *)pv, &mdas,
|
||||||
|
arg_int64_value(cmd, labelsector_ARG,
|
||||||
DEFAULT_LABELSECTOR)))) {
|
DEFAULT_LABELSECTOR)))) {
|
||||||
log_error("Failed to write physical volume \"%s\"", pv_name);
|
log_error("Failed to write physical volume \"%s\"", pv_name);
|
||||||
goto error;
|
goto error;
|
||||||
|
Loading…
Reference in New Issue
Block a user