1
0
mirror of git://sourceware.org/git/lvm2.git synced 2025-01-18 10:04:20 +03:00

pvcreate: Wipe cached bootloaderarea when wiping label.

Previously the cache remembered an existing bootloaderarea and
reinstated it (without even checking for overlap) when asked to
write out the PV.  pvcreate could write out an incorrect layout.
This commit is contained in:
Alasdair G Kergon 2017-08-11 20:32:04 +01:00
parent 7d09d7288b
commit 4fa5add6b1
3 changed files with 8 additions and 6 deletions

View File

@ -1,5 +1,6 @@
Version 2.02.174 - Version 2.02.174 -
================================= =================================
Always clear cached bootloaderarea when wiping label e.g. in pvcreate.
Disallow --bootloaderareasize with pvcreate --restorefile. Disallow --bootloaderareasize with pvcreate --restorefile.
Fix lvmlockd check for running lock managers during lock adoption. Fix lvmlockd check for running lock managers during lock adoption.
Add --withgeneralpreamble and --withlocalpreamble to lvmconfig. Add --withgeneralpreamble and --withlocalpreamble to lvmconfig.

View File

@ -202,6 +202,7 @@ int label_remove(struct device *dev)
int wipe; int wipe;
struct labeller_i *li; struct labeller_i *li;
struct label_header *lh; struct label_header *lh;
struct lvmcache_info *info;
memset(buf, 0, LABEL_SIZE); memset(buf, 0, LABEL_SIZE);
@ -245,8 +246,13 @@ int label_remove(struct device *dev)
if (wipe) { if (wipe) {
log_very_verbose("%s: Wiping label at sector %" PRIu64, log_very_verbose("%s: Wiping label at sector %" PRIu64,
dev_name(dev), sector); dev_name(dev), sector);
if (!dev_write(dev, sector << SECTOR_SHIFT, LABEL_SIZE, if (dev_write(dev, sector << SECTOR_SHIFT, LABEL_SIZE,
buf)) { buf)) {
/* Also remove the PV record from cache. */
info = lvmcache_info_from_pvid(dev->pvid, dev, 0);
if (info)
lvmcache_del(info);
} else {
log_error("Failed to remove label from %s at " log_error("Failed to remove label from %s at "
"sector %" PRIu64, dev_name(dev), "sector %" PRIu64, dev_name(dev),
sector); sector);

View File

@ -5398,7 +5398,6 @@ int pvcreate_each_device(struct cmd_context *cmd,
struct pvcreate_prompt *prompt, *prompt2; struct pvcreate_prompt *prompt, *prompt2;
struct physical_volume *pv; struct physical_volume *pv;
struct volume_group *orphan_vg; struct volume_group *orphan_vg;
struct lvmcache_info *info;
struct dm_list remove_duplicates; struct dm_list remove_duplicates;
struct dm_list arg_sort; struct dm_list arg_sort;
struct pv_list *pvl; struct pv_list *pvl;
@ -5811,10 +5810,6 @@ do_command:
continue; continue;
} }
info = lvmcache_info_from_pvid(pd->pvid, pd->dev, 0);
if (info)
lvmcache_del(info);
if (!lvmetad_pv_gone_by_dev(pd->dev)) { if (!lvmetad_pv_gone_by_dev(pd->dev)) {
log_error("Failed to remove PV %s from lvmetad.", pd->name); log_error("Failed to remove PV %s from lvmetad.", pd->name);
dm_list_move(&pp->arg_fail, &pd->list); dm_list_move(&pp->arg_fail, &pd->list);