mirror of
git://sourceware.org/git/lvm2.git
synced 2025-03-10 16:58:47 +03:00
Move orphan lock inside vg_remove_single.
Move the vg orphan lock inside vg_remove_single, now a complete liblvm function. Note that this changes the order of the locks - originally VG_ORPHAN was obtained first, then the vgname lock. With the current policy of non-blocking second locks, this could mean we get a failure obtaining the orphan lock. In the case of a vg with lvs being removed, this could result in the lvs being removed but not the vg. Such a scenario could have happened prior though with a different failure. Other tools were examined for side-effects, and no major problems were noted. Signed-off-by: Dave Wysochanski <dwysocha@redhat.com>
This commit is contained in:
parent
42ae96fa3d
commit
03660b3045
@ -388,8 +388,14 @@ int vg_remove_single(vg_t *vg)
|
||||
if (!archive(vg))
|
||||
return 0;
|
||||
|
||||
if (!lock_vol(vg->cmd, VG_ORPHANS, LCK_VG_WRITE)) {
|
||||
log_error("Can't get lock for orphan PVs");
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (!vg_remove(vg)) {
|
||||
log_error("vg_remove %s failed", vg->name);
|
||||
unlock_vg(vg->cmd, VG_ORPHANS);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -423,6 +429,7 @@ int vg_remove_single(vg_t *vg)
|
||||
else
|
||||
log_error("Volume group \"%s\" not properly removed", vg->name);
|
||||
|
||||
unlock_vg(vg->cmd, VG_ORPHANS);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
@ -56,16 +56,9 @@ int vgremove(struct cmd_context *cmd, int argc, char **argv)
|
||||
return EINVALID_CMD_LINE;
|
||||
}
|
||||
|
||||
if (!lock_vol(cmd, VG_ORPHANS, LCK_VG_WRITE)) {
|
||||
log_error("Can't get lock for orphan PVs");
|
||||
return ECMD_FAILED;
|
||||
}
|
||||
|
||||
ret = process_each_vg(cmd, argc, argv,
|
||||
READ_FOR_UPDATE,
|
||||
NULL, &vgremove_single);
|
||||
|
||||
unlock_vg(cmd, VG_ORPHANS);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user