mirror of
git://sourceware.org/git/lvm2.git
synced 2025-01-03 05:18:29 +03:00
Convert vgreduce to use vg_read_for_update.
Sun May 3 12:50:58 CEST 2009 Petr Rockai <me@mornfall.net> * Convert vgreduce to use vg_read_for_update. Rebased 6/26/2009 - Dave W.
This commit is contained in:
parent
13e8c7e434
commit
542ef24d9f
@ -382,7 +382,6 @@ static int _vgreduce_single(struct cmd_context *cmd, struct volume_group *vg,
|
|||||||
{
|
{
|
||||||
struct pv_list *pvl;
|
struct pv_list *pvl;
|
||||||
struct volume_group *orphan_vg = NULL;
|
struct volume_group *orphan_vg = NULL;
|
||||||
int consistent = 1;
|
|
||||||
int r = ECMD_FAILED;
|
int r = ECMD_FAILED;
|
||||||
const char *name = pv_dev_name(pv);
|
const char *name = pv_dev_name(pv);
|
||||||
|
|
||||||
@ -424,11 +423,11 @@ static int _vgreduce_single(struct cmd_context *cmd, struct volume_group *vg,
|
|||||||
vg->free_count -= pv_pe_count(pv) - pv_pe_alloc_count(pv);
|
vg->free_count -= pv_pe_count(pv) - pv_pe_alloc_count(pv);
|
||||||
vg->extent_count -= pv_pe_count(pv);
|
vg->extent_count -= pv_pe_count(pv);
|
||||||
|
|
||||||
if(!(orphan_vg = vg_read_internal(cmd, vg->fid->fmt->orphan_vg_name, NULL, &consistent)) ||
|
orphan_vg = vg_read_for_update(cmd, vg->fid->fmt->orphan_vg_name,
|
||||||
!consistent) {
|
NULL, LOCK_NONBLOCKING);
|
||||||
log_error("Unable to read existing orphan PVs");
|
|
||||||
|
if (vg_read_error(orphan_vg))
|
||||||
goto bad;
|
goto bad;
|
||||||
}
|
|
||||||
|
|
||||||
if (!vg_split_mdas(cmd, vg, orphan_vg) || !vg->pv_count) {
|
if (!vg_split_mdas(cmd, vg, orphan_vg) || !vg->pv_count) {
|
||||||
log_error("Cannot remove final metadata area on \"%s\" from \"%s\"",
|
log_error("Cannot remove final metadata area on \"%s\" from \"%s\"",
|
||||||
@ -463,7 +462,6 @@ int vgreduce(struct cmd_context *cmd, int argc, char **argv)
|
|||||||
struct volume_group *vg;
|
struct volume_group *vg;
|
||||||
char *vg_name;
|
char *vg_name;
|
||||||
int ret = ECMD_FAILED;
|
int ret = ECMD_FAILED;
|
||||||
int consistent = 1;
|
|
||||||
int fixed = 1;
|
int fixed = 1;
|
||||||
int repairing = arg_count(cmd, removemissing_ARG);
|
int repairing = arg_count(cmd, removemissing_ARG);
|
||||||
int saved_ignore_suspended_devices = ignore_suspended_devices();
|
int saved_ignore_suspended_devices = ignore_suspended_devices();
|
||||||
@ -511,25 +509,22 @@ int vgreduce(struct cmd_context *cmd, int argc, char **argv)
|
|||||||
}
|
}
|
||||||
|
|
||||||
log_verbose("Finding volume group \"%s\"", vg_name);
|
log_verbose("Finding volume group \"%s\"", vg_name);
|
||||||
if (!lock_vol(cmd, vg_name, LCK_VG_WRITE)) {
|
|
||||||
log_error("Can't get lock for %s", vg_name);
|
|
||||||
return ECMD_FAILED;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (repairing)
|
if (repairing)
|
||||||
init_ignore_suspended_devices(1);
|
init_ignore_suspended_devices(1);
|
||||||
|
|
||||||
if ((!(vg = vg_read_internal(cmd, vg_name, NULL, &consistent)) || !consistent)
|
vg = vg_read_for_update(cmd, vg_name, NULL, READ_ALLOW_EXPORTED);
|
||||||
&& !repairing) {
|
if (vg_read_error(vg) == FAILED_ALLOCATION ||
|
||||||
log_error("Volume group \"%s\" doesn't exist", vg_name);
|
vg_read_error(vg) == FAILED_NOTFOUND)
|
||||||
goto out;
|
goto out;
|
||||||
}
|
|
||||||
|
|
||||||
if (vg && !vg_check_status(vg, CLUSTERED))
|
/* FIXME We want to allow read-only VGs to be changed here? */
|
||||||
|
if (vg_read_error(vg) && vg_read_error(vg) != FAILED_READ_ONLY
|
||||||
|
&& !arg_count(cmd, removemissing_ARG))
|
||||||
goto out;
|
goto out;
|
||||||
|
|
||||||
if (repairing) {
|
if (repairing) {
|
||||||
if (vg && consistent && !vg_missing_pv_count(vg)) {
|
if (!vg_read_error(vg) && !vg_missing_pv_count(vg)) {
|
||||||
log_error("Volume group \"%s\" is already consistent",
|
log_error("Volume group \"%s\" is already consistent",
|
||||||
vg_name);
|
vg_name);
|
||||||
ret = ECMD_PROCESSED;
|
ret = ECMD_PROCESSED;
|
||||||
@ -537,13 +532,16 @@ int vgreduce(struct cmd_context *cmd, int argc, char **argv)
|
|||||||
}
|
}
|
||||||
|
|
||||||
vg_release(vg);
|
vg_release(vg);
|
||||||
consistent = !arg_count(cmd, force_ARG);
|
log_verbose("Trying to open VG %s for recovery...", vg_name);
|
||||||
if (!(vg = vg_read_internal(cmd, vg_name, NULL, &consistent))) {
|
|
||||||
log_error("Volume group \"%s\" not found", vg_name);
|
vg = vg_read_for_update(cmd, vg_name, NULL,
|
||||||
goto out;
|
READ_ALLOW_INCONSISTENT
|
||||||
}
|
| READ_ALLOW_EXPORTED);
|
||||||
if (!vg_check_status(vg, CLUSTERED))
|
|
||||||
|
if (vg_read_error(vg) && vg_read_error(vg) != FAILED_READ_ONLY
|
||||||
|
&& vg_read_error(vg) != FAILED_INCONSISTENT)
|
||||||
goto out;
|
goto out;
|
||||||
|
|
||||||
if (!archive(vg))
|
if (!archive(vg))
|
||||||
goto out;
|
goto out;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user