From e935d217520c85eae165cbff0e31065f97a98160 Mon Sep 17 00:00:00 2001 From: Alasdair Kergon Date: Thu, 23 Aug 2007 15:02:26 +0000 Subject: Introduce VG_GLOBAL lock type for vgscan/pvscan to trigger clvmd -R. --- tools/pvscan.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'tools/pvscan.c') 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; } -- cgit