summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlasdair Kergon <agk@redhat.com>2007-11-15 21:30:52 +0000
committerAlasdair Kergon <agk@redhat.com>2007-11-15 21:30:52 +0000
commit57d921e953bc4aa0f052e5e53b46dfa3e4651c3b (patch)
tree70dc5923a4767c6888f475e205a8511e6beb6e15
parent37034fb826f20a08c05972ea9e4d50be079e5c1f (diff)
downloadlvm2-57d921e953bc4aa0f052e5e53b46dfa3e4651c3b.tar.gz
lvm2-57d921e953bc4aa0f052e5e53b46dfa3e4651c3b.tar.xz
lvm2-57d921e953bc4aa0f052e5e53b46dfa3e4651c3b.zip
more vg_read lock fixes
-rw-r--r--lib/locking/locking.c5
-rw-r--r--lib/locking/locking.h2
-rw-r--r--tools/pvdisplay.c1
-rw-r--r--tools/toollib.c14
-rw-r--r--tools/vgreduce.c2
5 files changed, 18 insertions, 6 deletions
diff --git a/lib/locking/locking.c b/lib/locking/locking.c
index 70ea58e3..6ca1a10d 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 854ff100..475a2d0a 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 0528fdbf..7862629c 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 35ea0d61..12c2f740 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 6352119f..209e1d36 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);
}