summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--WHATS_NEW1
-rw-r--r--lib/locking/cluster_locking.c4
-rw-r--r--lib/locking/file_locking.c5
-rw-r--r--lib/locking/locking.h7
-rw-r--r--tools/pvscan.c12
-rw-r--r--tools/vgscan.c6
6 files changed, 31 insertions, 4 deletions
diff --git a/WHATS_NEW b/WHATS_NEW
index 89be8384..ca088f2c 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
Version 2.02.28 -
================================
+ Introduce VG_GLOBAL lock type for vgscan/pvscan to trigger clvmd -R.
Fix clvmd -R, so it fully refreshes the caches.
Change lvconvert_mirrors to use mirror segtype not striped.
Fix lvconvert_mirrors detection of number of existing mirrors.
diff --git a/lib/locking/cluster_locking.c b/lib/locking/cluster_locking.c
index 58054add..533f1c87 100644
--- a/lib/locking/cluster_locking.c
+++ b/lib/locking/cluster_locking.c
@@ -382,8 +382,10 @@ int lock_resource(struct cmd_context *cmd, const char *resource, uint32_t flags)
switch (flags & LCK_SCOPE_MASK) {
case LCK_VG:
/* If the VG name is empty then lock the unused PVs */
- if (!*resource)
+ if (!*resource) /* FIXME Deprecated */
dm_snprintf(lockname, sizeof(lockname), "P_orphans");
+ else if (*resource == '#')
+ dm_snprintf(lockname, sizeof(lockname), "P_%s", resource + 1);
else
dm_snprintf(lockname, sizeof(lockname), "V_%s",
resource);
diff --git a/lib/locking/file_locking.c b/lib/locking/file_locking.c
index 2ad86fd1..4d83f629 100644
--- a/lib/locking/file_locking.c
+++ b/lib/locking/file_locking.c
@@ -212,9 +212,12 @@ static int _file_lock_resource(struct cmd_context *cmd, const char *resource,
switch (flags & LCK_SCOPE_MASK) {
case LCK_VG:
- if (!*resource)
+ if (!*resource) /* FIXME Deprecated */
dm_snprintf(lockfile, sizeof(lockfile),
"%s/P_orphans", _lock_dir);
+ else if (*resource == '#')
+ dm_snprintf(lockfile, sizeof(lockfile),
+ "%s/P_%s", _lock_dir, resource + 1);
else
dm_snprintf(lockfile, sizeof(lockfile),
"%s/V_%s", _lock_dir, resource);
diff --git a/lib/locking/locking.h b/lib/locking/locking.h
index 9b32524f..051f6775 100644
--- a/lib/locking/locking.h
+++ b/lib/locking/locking.h
@@ -28,7 +28,7 @@ int locking_is_clustered(void);
/*
* LCK_VG:
* Lock/unlock on-disk volume group data
- * Use "" to lock orphan PVs
+ * Use VG_ORPHANS to lock orphan PVs
* char *vol holds volume group name
*
* LCK_LV:
@@ -77,6 +77,11 @@ int check_lvm1_vg_inactive(struct cmd_context *cmd, const char *vgname);
#define LCK_MIRROR_NOSYNC_MODE 0x00000002U /* Mirrors don't require sync */
#define LCK_DMEVENTD_MONITOR_MODE 0x00000004U /* Register with dmeventd */
+/*
+ * Special cases of VG locks.
+ */
+#define VG_ORPHANS "#orphans"
+#define VG_GLOBAL "#global"
/*
* Common combinations
diff --git a/tools/pvscan.c b/tools/pvscan.c
index 1e358a24..8299cc98 100644
--- a/tools/pvscan.c
+++ b/tools/pvscan.c
@@ -124,12 +124,19 @@ int pvscan(struct cmd_context *cmd, int argc __attribute((unused)),
arg_count(cmd, exported_ARG) ?
"of exported volume group(s)" : "in no volume group");
+ if (!lock_vol(cmd, VG_GLOBAL, LCK_VG_WRITE)) {
+ log_error("Unable to obtain global lock.");
+ return ECMD_FAILED;
+ }
+
persistent_filter_wipe(cmd->filter);
lvmcache_destroy();
log_verbose("Walking through all physical volumes");
- if (!(pvslist = get_pvs(cmd)))
+ if (!(pvslist = get_pvs(cmd))) {
+ unlock_vg(cmd, VG_GLOBAL);
return ECMD_FAILED;
+ }
/* eliminate exported/new if required */
list_iterate_items(pvl, pvslist) {
@@ -181,6 +188,7 @@ int pvscan(struct cmd_context *cmd, int argc __attribute((unused)),
if (!pvs_found) {
log_print("No matching physical volumes found");
+ unlock_vg(cmd, VG_GLOBAL);
return ECMD_PROCESSED;
}
@@ -191,5 +199,7 @@ int pvscan(struct cmd_context *cmd, int argc __attribute((unused)),
display_size(cmd, (size_total - size_new)),
new_pvs_found, display_size(cmd, size_new));
+ unlock_vg(cmd, VG_GLOBAL);
+
return ECMD_PROCESSED;
}
diff --git a/tools/vgscan.c b/tools/vgscan.c
index 15b33a3b..65e678f9 100644
--- a/tools/vgscan.c
+++ b/tools/vgscan.c
@@ -51,6 +51,11 @@ int vgscan(struct cmd_context *cmd, int argc, char **argv)
return EINVALID_CMD_LINE;
}
+ if (!lock_vol(cmd, VG_GLOBAL, LCK_VG_WRITE)) {
+ log_error("Unable to obtain global lock.");
+ return ECMD_FAILED;
+ }
+
persistent_filter_wipe(cmd->filter);
lvmcache_destroy();
@@ -65,5 +70,6 @@ int vgscan(struct cmd_context *cmd, int argc, char **argv)
maxret = ret;
}
+ unlock_vg(cmd, VG_GLOBAL);
return maxret;
}