mirror of
git://sourceware.org/git/lvm2.git
synced 2025-03-28 02:50:41 +03:00
vg_read: skip repair and wipe for foreign and shared VGs
When reading a foreign VG we cannot write it, since it belongs to another host. When reading a shared VG we cannot write it because we may not have an ex lock. (Or we may be reading the shared VG while not using lvmlockd in which case it's like reading a foreign VG.) Add the same checks for wiping outdated PVs. We may read a foreign or shared VG, or see the PVs, while another host is part way through writing a new version of the VG to the PVs. This might cause us to think some of the PVs are outdated. We do not want to write another host's PVs, especially when we may wrongly conclude they are outdated.
This commit is contained in:
parent
4103896ca0
commit
16780f6faa
@ -3428,6 +3428,18 @@ static int _repair_inconsistent_vg(struct volume_group *vg)
|
||||
{
|
||||
unsigned saved_handles_missing_pvs = vg->cmd->handles_missing_pvs;
|
||||
|
||||
/* Cannot write foreign VGs, the owner will repair it. */
|
||||
if (vg->cmd->system_id && strcmp(vg->system_id, vg->cmd->system_id)) {
|
||||
log_verbose("Skip metadata repair for foreign VG.");
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* FIXME: do this at higher level where lvmlockd lock can be changed. */
|
||||
if (is_lockd_type(vg->lock_type)) {
|
||||
log_verbose("Skip metadata repair for shared VG.");
|
||||
return 0;
|
||||
}
|
||||
|
||||
vg->cmd->handles_missing_pvs = 1;
|
||||
if (!vg_write(vg)) {
|
||||
log_error("Automatic metadata correction failed");
|
||||
@ -3457,6 +3469,30 @@ static int _wipe_outdated_pvs(struct cmd_context *cmd, struct volume_group *vg,
|
||||
{
|
||||
struct pv_list *pvl, *pvl2;
|
||||
char uuid[64] __attribute__((aligned(8)));
|
||||
|
||||
/*
|
||||
* Cannot write foreign VGs, the owner will repair it.
|
||||
* Also, if another host is updating its VG, we may read
|
||||
* the PVs while some are written but not others, making
|
||||
* some PVs look outdated to us just because we're reading
|
||||
* the VG while it's only partially written out.
|
||||
*/
|
||||
if (cmd->system_id && strcmp(vg->system_id, cmd->system_id)) {
|
||||
log_verbose("Skip wiping outdated PVs for foreign VG.");
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* FIXME: do this at higher level where lvmlockd lock can be changed.
|
||||
* Also if we're reading the VG with the --shared option (not using
|
||||
* lvmlockd), we can see a VG while it's being written by another
|
||||
* host, same as the foreign VG case.
|
||||
*/
|
||||
if (is_lockd_type(vg->lock_type)) {
|
||||
log_verbose("Skip wiping outdated PVs for shared VG.");
|
||||
return 0;
|
||||
}
|
||||
|
||||
dm_list_iterate_items(pvl, to_check) {
|
||||
dm_list_iterate_items(pvl2, &vg->pvs) {
|
||||
if (pvl->pv->dev == pvl2->pv->dev)
|
||||
|
Loading…
x
Reference in New Issue
Block a user