summaryrefslogtreecommitdiff
path: root/tools/vgreduce.c
diff options
context:
space:
mode:
Diffstat (limited to 'tools/vgreduce.c')
-rw-r--r--tools/vgreduce.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/tools/vgreduce.c b/tools/vgreduce.c
index 0adf1bb85..693f538ae 100644
--- a/tools/vgreduce.c
+++ b/tools/vgreduce.c
@@ -141,6 +141,7 @@ int vgreduce(struct cmd_context *cmd, int argc, char **argv)
{
struct volume_group *vg;
const char *vg_name;
+ uint32_t lockd_state;
int ret = ECMD_FAILED;
int fixed = 1;
int repairing = arg_count(cmd, removemissing_ARG);
@@ -195,7 +196,14 @@ int vgreduce(struct cmd_context *cmd, int argc, char **argv)
init_ignore_suspended_devices(1);
cmd->handles_missing_pvs = 1;
- vg = vg_read_for_update(cmd, vg_name, NULL, READ_ALLOW_EXPORTED);
+ /* Needed to change the set of orphan PVs. */
+ if (!lockd_gl(cmd, "ex", 0))
+ return_ECMD_FAILED;
+
+ if (!lockd_vg(cmd, vg_name, "ex", 0, &lockd_state))
+ return_ECMD_FAILED;
+
+ vg = vg_read_for_update(cmd, vg_name, NULL, READ_ALLOW_EXPORTED, lockd_state);
if (vg_read_error(vg) == FAILED_ALLOCATION ||
vg_read_error(vg) == FAILED_NOTFOUND)
goto_out;
@@ -218,7 +226,7 @@ int vgreduce(struct cmd_context *cmd, int argc, char **argv)
log_verbose("Trying to open VG %s for recovery...", vg_name);
vg = vg_read_for_update(cmd, vg_name, NULL,
- READ_ALLOW_INCONSISTENT | READ_ALLOW_EXPORTED);
+ READ_ALLOW_INCONSISTENT | READ_ALLOW_EXPORTED, lockd_state);
locked |= !vg_read_error(vg);