]> sourceware.org Git - lvm2.git/commitdiff
Introduce VG_GLOBAL lock type for vgscan/pvscan to trigger clvmd -R.
authorAlasdair Kergon <agk@redhat.com>
Thu, 23 Aug 2007 15:02:26 +0000 (15:02 +0000)
committerAlasdair Kergon <agk@redhat.com>
Thu, 23 Aug 2007 15:02:26 +0000 (15:02 +0000)
WHATS_NEW
lib/locking/cluster_locking.c
lib/locking/file_locking.c
lib/locking/locking.h
tools/pvscan.c
tools/vgscan.c

index 89be83840c3201d21be725e9c311e51b30f32993..ca088f2c2c02d532fd9441a7286665ac0d5b52de 100644 (file)
--- 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.
index 58054addd7b7c64bd4339c491fe7469c2e18c970..533f1c87fadd849e4ca855b33629fd0ac0e9d3e8 100644 (file)
@@ -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);
index 2ad86fd14b8928450de004e81afc672a709e1236..4d83f6294ee501455dab803eb815032c41aa6871 100644 (file)
@@ -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);
index 9b32524fa22310f01d0c3807d2a2c62e141e0e4f..051f6775e543a1ab3a20bffd3d347b9ebb8687f7 100644 (file)
@@ -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
index 1e358a249936dc46f4e73753fac569e9f75fe9d5..8299cc98f61b506e95c1d6f99ea98f953ef0ae9b 100644 (file)
@@ -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;
 }
index 15b33a3b4a4197652411790745cbf16b069db5e9..65e678f933f7f3ee8a9dd686626bd54961cfb975 100644 (file)
@@ -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;
 }
This page took 0.097532 seconds and 5 git commands to generate.