diff --git a/lib/locking/locking.c b/lib/locking/locking.c index 70ea58e36..6ca1a10d4 100644 --- a/lib/locking/locking.c +++ b/lib/locking/locking.c @@ -335,6 +335,11 @@ int lock_vol(struct cmd_context *cmd, const char *vol, uint32_t flags) { char resource[258] __attribute((aligned(8))); + if (flags == LCK_NONE) { + log_debug("Internal error: %s: LCK_NONE lock requested", vol); + return 1; + } + switch (flags & LCK_SCOPE_MASK) { case LCK_VG: /* Lock VG to change on-disk metadata. */ diff --git a/lib/locking/locking.h b/lib/locking/locking.h index 854ff1004..475a2d0a6 100644 --- a/lib/locking/locking.h +++ b/lib/locking/locking.h @@ -86,7 +86,7 @@ int check_lvm1_vg_inactive(struct cmd_context *cmd, const char *vgname); /* * Common combinations */ -#define LCK_NONE 0 +#define LCK_NONE (LCK_VG | LCK_NULL) #define LCK_VG_READ (LCK_VG | LCK_READ | LCK_HOLD) #define LCK_VG_WRITE (LCK_VG | LCK_WRITE | LCK_HOLD) diff --git a/tools/pvdisplay.c b/tools/pvdisplay.c index 0528fdbf1..7862629c1 100644 --- a/tools/pvdisplay.c +++ b/tools/pvdisplay.c @@ -31,6 +31,7 @@ static int _pvdisplay_single(struct cmd_context *cmd, if (!(vg = vg_lock_and_read(cmd, vg_name, (char *)&pv->vgid, LCK_VG_READ, CLUSTERED, 0))) { log_error("Skipping volume group %s", vg_name); + /* FIXME If CLUSTERED should return ECMD_PROCESSED here */ return ECMD_FAILED; } diff --git a/tools/toollib.c b/tools/toollib.c index 35ea0d61e..12c2f7408 100644 --- a/tools/toollib.c +++ b/tools/toollib.c @@ -443,10 +443,9 @@ int process_each_segment_in_pv(struct cmd_context *cmd, if (ret > ret_max) ret_max = ret; if (sigint_caught()) - return ret_max; + break; } -out: if (vg_name) unlock_vg(cmd, vg_name); @@ -747,8 +746,15 @@ int process_each_pv(struct cmd_context *cmd, int argc, char **argv, if (sigint_caught()) return ret_max; } - if (!list_empty(&tags) && (vgnames = get_vgs(cmd, 0)) && - !list_empty(vgnames)) { + if (vg) { + ret = process_each_pv_in_vg(cmd, vg, &tags, + handle, process_single); + if (ret > ret_max) + ret_max = ret; + if (sigint_caught()) + return ret_max; + } else if (!list_empty(&tags) && (vgnames = get_vgs(cmd, 0)) && + !list_empty(vgnames)) { list_iterate_items(sll, vgnames) { if (!lock_vol(cmd, sll->str, lock_type)) { log_error("Can't lock %s: skipping", sll->str); diff --git a/tools/vgreduce.c b/tools/vgreduce.c index 6352119ff..209e1d36d 100644 --- a/tools/vgreduce.c +++ b/tools/vgreduce.c @@ -539,7 +539,7 @@ int vgreduce(struct cmd_context *cmd, int argc, char **argv) /* FIXME: Pass private struct through to all these functions */ /* and update in batch here? */ - ret = process_each_pv(cmd, argc, argv, vg, LCK_VG_WRITE, NULL, + ret = process_each_pv(cmd, argc, argv, vg, LCK_NONE, NULL, _vgreduce_single); }