1
0
mirror of git://sourceware.org/git/lvm2.git synced 2024-12-21 13:34:40 +03:00

Fix vgconvert logical volume id metadata validation.

If volume group is downconverted to lvm1 format,
check if lvid has supported format for conversion to lv_num in lvm1.
This commit is contained in:
Milan Broz 2008-08-28 18:41:51 +00:00
parent 8ed917d287
commit 9c520b114a
4 changed files with 31 additions and 0 deletions

View File

@ -1,5 +1,6 @@
Version 2.02.40 -
================================
Fix vgconvert logical volume id metadata validation.
Fix lvmdump metadata gather option (-m) to work correctly.
Fix allocation bug in text metadata format write error path.
Fix vgcfgbackup to properly check filename if template is used.

View File

@ -67,11 +67,29 @@ int lvnum_from_lvid(union lvid *lvid)
lv_num *= sizeof(_c) - 1;
if ((c = strchr(_c, lvid->id[1].uuid[i])))
lv_num += (int) (c - _c);
if (lv_num < 0)
lv_num = 0;
}
return lv_num;
}
int lvid_in_restricted_range(union lvid *lvid)
{
int i;
for (i = 0; i < ID_LEN - 3; i++)
if (lvid->id[1].uuid[i] != '0')
return 0;
for (i = ID_LEN - 3; i < ID_LEN; i++)
if (!isdigit(lvid->id[1].uuid[i]))
return 0;
return 1;
}
int id_create(struct id *id)
{
int randomfile;

View File

@ -34,6 +34,7 @@ union lvid {
int lvid_from_lvnum(union lvid *lvid, struct id *vgid, uint32_t lv_num);
int lvnum_from_lvid(union lvid *lvid);
int lvid_in_restricted_range(union lvid *lvid);
void uuid_from_num(char *uuid, uint32_t num);

View File

@ -81,6 +81,17 @@ static int vgconvert_single(struct cmd_context *cmd, const char *vg_name,
return ECMD_FAILED;
}
/* If converting to restricted lvid, check if lvid is compatible */
if (!(vg->fid->fmt->features & FMT_RESTRICTED_LVIDS) &&
cmd->fmt->features & FMT_RESTRICTED_LVIDS)
list_iterate_items(lvl, &vg->lvs)
if (!lvid_in_restricted_range(&lvl->lv->lvid)) {
log_error("Logical volume %s lvid format is"
" incompatible with requested"
" metadata format.", lvl->lv->name);
return ECMD_FAILED;
}
/* Attempt to change any LVIDs that are too big */
if (cmd->fmt->features & FMT_RESTRICTED_LVIDS) {
list_iterate_items(lvl, &vg->lvs) {