mirror of
git://sourceware.org/git/lvm2.git
synced 2025-01-03 05:18:29 +03:00
Look up missing PVs by uuid not dev_name in _pvs_single to avoid invalid stat.
Make find_pv_in_vg_by_uuid() return same type as related functions.
This commit is contained in:
parent
770dc81b8e
commit
cccae7e633
@ -1,5 +1,7 @@
|
|||||||
Version 2.02.63 -
|
Version 2.02.63 -
|
||||||
================================
|
================================
|
||||||
|
Look up missing PVs by uuid not dev_name in _pvs_single to avoid invalid stat.
|
||||||
|
Make find_pv_in_vg_by_uuid() return same type as related functions.
|
||||||
Introduce is_missing_pv().
|
Introduce is_missing_pv().
|
||||||
Fix clvmd Makefile to not overwrite LIBS from template definition.
|
Fix clvmd Makefile to not overwrite LIBS from template definition.
|
||||||
|
|
||||||
|
@ -597,7 +597,7 @@ struct logical_volume *insert_layer_for_lv(struct cmd_context *cmd,
|
|||||||
/* Find a PV within a given VG */
|
/* Find a PV within a given VG */
|
||||||
struct pv_list *find_pv_in_vg(const struct volume_group *vg,
|
struct pv_list *find_pv_in_vg(const struct volume_group *vg,
|
||||||
const char *pv_name);
|
const char *pv_name);
|
||||||
struct physical_volume *find_pv_in_vg_by_uuid(const struct volume_group *vg,
|
struct pv_list *find_pv_in_vg_by_uuid(const struct volume_group *vg,
|
||||||
const struct id *id);
|
const struct id *id);
|
||||||
|
|
||||||
/* Find an LV within a given VG */
|
/* Find an LV within a given VG */
|
||||||
|
@ -52,9 +52,6 @@ static struct physical_volume *_find_pv_by_name(struct cmd_context *cmd,
|
|||||||
static struct pv_list *_find_pv_in_vg(const struct volume_group *vg,
|
static struct pv_list *_find_pv_in_vg(const struct volume_group *vg,
|
||||||
const char *pv_name);
|
const char *pv_name);
|
||||||
|
|
||||||
static struct physical_volume *_find_pv_in_vg_by_uuid(const struct volume_group *vg,
|
|
||||||
const struct id *id);
|
|
||||||
|
|
||||||
static uint32_t _vg_bad_status_bits(const struct volume_group *vg,
|
static uint32_t _vg_bad_status_bits(const struct volume_group *vg,
|
||||||
uint64_t status);
|
uint64_t status);
|
||||||
|
|
||||||
@ -1656,37 +1653,36 @@ int pv_is_in_vg(struct volume_group *vg, struct physical_volume *pv)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
static struct pv_list *_find_pv_in_vg_by_uuid(const struct volume_group *vg,
|
||||||
* find_pv_in_vg_by_uuid - Find PV in VG by PV UUID
|
|
||||||
* @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
|
|
||||||
*/
|
|
||||||
struct physical_volume *find_pv_in_vg_by_uuid(const struct volume_group *vg,
|
|
||||||
const struct id *id)
|
|
||||||
{
|
|
||||||
return _find_pv_in_vg_by_uuid(vg, id);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
static struct physical_volume *_find_pv_in_vg_by_uuid(const struct volume_group *vg,
|
|
||||||
const struct id *id)
|
const struct id *id)
|
||||||
{
|
{
|
||||||
struct pv_list *pvl;
|
struct pv_list *pvl;
|
||||||
|
|
||||||
dm_list_iterate_items(pvl, &vg->pvs)
|
dm_list_iterate_items(pvl, &vg->pvs)
|
||||||
if (id_equal(&pvl->pv->id, id))
|
if (id_equal(&pvl->pv->id, id))
|
||||||
return pvl->pv;
|
return pvl;
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* find_pv_in_vg_by_uuid - Find PV in VG by PV UUID
|
||||||
|
* @vg: volume group to search
|
||||||
|
* @id: UUID of the PV to match
|
||||||
|
*
|
||||||
|
* Returns:
|
||||||
|
* struct pv_list within owning struct volume_group - 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
|
||||||
|
*/
|
||||||
|
struct pv_list *find_pv_in_vg_by_uuid(const struct volume_group *vg,
|
||||||
|
const struct id *id)
|
||||||
|
{
|
||||||
|
return _find_pv_in_vg_by_uuid(vg, id);
|
||||||
|
}
|
||||||
|
|
||||||
struct lv_list *find_lv_in_vg(const struct volume_group *vg,
|
struct lv_list *find_lv_in_vg(const struct volume_group *vg,
|
||||||
const char *lv_name)
|
const char *lv_name)
|
||||||
{
|
{
|
||||||
|
@ -56,7 +56,7 @@ static int pvcreate_restore_params_validate(struct cmd_context *cmd,
|
|||||||
pp->restorefile);
|
pp->restorefile);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
if (!(existing_pv = find_pv_in_vg_by_uuid(vg, pp->idp))) {
|
if (!(existing_pv = find_pv_in_vg_by_uuid(vg, pp->idp)->pv)) {
|
||||||
log_error("Can't find uuid %s in backup file %s",
|
log_error("Can't find uuid %s in backup file %s",
|
||||||
uuid, pp->restorefile);
|
uuid, pp->restorefile);
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -136,6 +136,7 @@ static int _pvs_single(struct cmd_context *cmd, struct volume_group *vg,
|
|||||||
int ret = ECMD_PROCESSED;
|
int ret = ECMD_PROCESSED;
|
||||||
const char *vg_name = NULL;
|
const char *vg_name = NULL;
|
||||||
struct volume_group *old_vg = vg;
|
struct volume_group *old_vg = vg;
|
||||||
|
char uuid[64] __attribute((aligned(8)));
|
||||||
|
|
||||||
if (is_pv(pv) && !is_orphan(pv) && !vg) {
|
if (is_pv(pv) && !is_orphan(pv) && !vg) {
|
||||||
vg_name = pv_vg_name(pv);
|
vg_name = pv_vg_name(pv);
|
||||||
@ -149,14 +150,26 @@ static int _pvs_single(struct cmd_context *cmd, struct volume_group *vg,
|
|||||||
|
|
||||||
/*
|
/*
|
||||||
* Replace possibly incomplete PV structure with new one
|
* Replace possibly incomplete PV structure with new one
|
||||||
* allocated in vg_read_internal() path.
|
* allocated in vg_read.
|
||||||
*/
|
*/
|
||||||
|
if (!is_missing_pv(pv)) {
|
||||||
if (!(pvl = find_pv_in_vg(vg, pv_dev_name(pv)))) {
|
if (!(pvl = find_pv_in_vg(vg, pv_dev_name(pv)))) {
|
||||||
log_error("Unable to find \"%s\" in volume group \"%s\"",
|
log_error("Unable to find \"%s\" in volume group \"%s\"",
|
||||||
pv_dev_name(pv), vg->name);
|
pv_dev_name(pv), vg->name);
|
||||||
ret = ECMD_FAILED;
|
ret = ECMD_FAILED;
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
} else if (!(pvl = find_pv_in_vg_by_uuid(vg, &pv->id))) {
|
||||||
|
if (!id_write_format(&pv->id, uuid, sizeof(uuid))) {
|
||||||
|
stack;
|
||||||
|
uuid[0] = '\0';
|
||||||
|
}
|
||||||
|
|
||||||
|
log_error("Unable to find missing PV %s in volume group %s",
|
||||||
|
uuid, vg->name);
|
||||||
|
ret = ECMD_FAILED;
|
||||||
|
goto out;
|
||||||
|
}
|
||||||
|
|
||||||
pv = pvl->pv;
|
pv = pvl->pv;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user