1
0
mirror of git://sourceware.org/git/lvm2.git synced 2025-03-08 08:58:50 +03:00

metadata: check PV dev size is not less than PV size

This commit is contained in:
Peter Rajnoha 2016-01-22 11:37:09 +01:00
parent 1f5dfb7369
commit c0912af310
2 changed files with 35 additions and 0 deletions

View File

@ -1,5 +1,6 @@
Version 2.02.141 -
====================================
Warn if device size is less than corresponding PV size in metadata.
Cache device sizes internally.
Restore support for command breaking in process_each_lv_in_vg() (2.02.118).
Use correct mempool when process_each_lv_in_vg() (2.02.118).

View File

@ -666,6 +666,34 @@ int vg_check_pv_dev_block_sizes(const struct volume_group *vg)
return 1;
}
static int _check_pv_dev_sizes(struct volume_group *vg)
{
struct pv_list *pvl;
uint64_t dev_size, size;
int r = 1;
if (is_orphan_vg(vg->name))
return 1;
dm_list_iterate_items(pvl, &vg->pvs) {
if (is_missing_pv(pvl->pv))
continue;
dev_size = pv_dev_size(pvl->pv);
size = pv_size(pvl->pv);
if (dev_size < size) {
log_warn("Device %s has size of %" PRIu64 " sectors which "
"is smaller than corresponding PV size of %" PRIu64
" sectors. Was device resized?",
pv_dev_name(pvl->pv), dev_size, size);
r = 0;
}
}
return r;
}
/*
* Extend a VG by a single PV / device path
*
@ -742,6 +770,8 @@ int vg_extend(struct volume_group *vg, int pv_count, const char *const *pv_names
dm_free(pv_name);
}
(void) _check_pv_dev_sizes(vg);
/* FIXME Decide whether to initialise and add new mdahs to format instance */
return 1;
@ -4031,6 +4061,10 @@ struct volume_group *vg_read_internal(struct cmd_context *cmd, const char *vgnam
if (!(vg = _vg_read(cmd, vgname, vgid, warn_flags, consistent, 0)))
goto_out;
if (!_check_pv_dev_sizes(vg))
log_warn("One or more devices used as PVs in VG %s "
"have changed sizes.", vg->name);
if (!check_pv_segments(vg)) {
log_error(INTERNAL_ERROR "PV segments corrupted in %s.",
vg->name);