]> sourceware.org Git - lvm2.git/commitdiff
more cleanup
authorAlasdair Kergon <agk@redhat.com>
Fri, 9 May 2008 19:26:58 +0000 (19:26 +0000)
committerAlasdair Kergon <agk@redhat.com>
Fri, 9 May 2008 19:26:58 +0000 (19:26 +0000)
daemons/clvmd/clvmd-command.c
daemons/clvmd/lvm-functions.c
lib/locking/file_locking.c
lib/locking/locking.h

index 3b1379fee8e7b7fc5383f7178eacd47fb1d59e96..0d3da6a60f26e62ffe77880546075dab2c36ad7e 100644 (file)
@@ -119,7 +119,7 @@ int do_command(struct local_client *client, struct clvm_header *msg, int msglen,
                /* Check to see if the VG is in use by LVM1 */
                status = do_check_lvm1(lockname);
                /* P_#global causes a full cache refresh */
-               if (!strcmp(lockname, "P_#global"))
+               if (!strcmp(lockname, "P_" VG_GLOBAL))
                        do_refresh_cache();
                else
                        drop_metadata(lockname + 2);
index 84e0aa5dff39df681d599e47946a1a2e7cf1104c..f226e6e048e600a9884083964dc5b2444dab8478 100644 (file)
@@ -472,8 +472,8 @@ static void drop_vg_locks()
            popen
            ("lvm pvs  --config 'log{command_names=0 prefix=\"\"}' --nolocking --noheadings -o vg_name", "r");
 
-       sync_unlock("P_#orphans", LCK_EXCL);
-       sync_unlock("P_#global", LCK_EXCL);
+       sync_unlock("P_" VG_ORPHANS, LCK_EXCL);
+       sync_unlock("P_" VG_GLOBAL, LCK_EXCL);
 
        if (!vgs)
                return;
index ec7417ac7b8c012d89ee65bde3b16e8558111cbb..7ebfdaa55fdb01a6dd6ededd0416bd1ff7bc03b1 100644 (file)
@@ -210,10 +210,14 @@ static int _file_lock_resource(struct cmd_context *cmd, const char *resource,
 
        switch (flags & LCK_SCOPE_MASK) {
        case LCK_VG:
-               if (flags & LCK_CACHE) {
+               /* Skip cache refresh for VG_GLOBAL - the caller handles it */
+               if (strcmp(resource, VG_GLOBAL))
                        lvmcache_drop_metadata(resource);
+
+               /* LCK_CACHE does not require a real lock */
+               if (flags & LCK_CACHE)
                        break;
-               }
+
                if (*resource == '#')
                        dm_snprintf(lockfile, sizeof(lockfile),
                                     "%s/P_%s", _lock_dir, resource + 1);
index 4c33d943a08e5ddcf213d0f62316425e54155e50..6a34a6d3a58fe74284b5c2511b89a16cdb344521 100644 (file)
@@ -27,9 +27,11 @@ int locking_is_clustered(void);
 
 /*
  * LCK_VG:
- *   Lock/unlock on-disk volume group data
- *   Use VG_ORPHANS to lock orphan PVs
- *   char *vol holds volume group name
+ *   Lock/unlock on-disk volume group data.
+ *   Use VG_ORPHANS to lock all orphan PVs.
+ *   Use VG_GLOBAL as a global lock and to wipe the internal cache.
+ *   char *vol holds volume group name.
+ *   Set the LCK_CACHE flag to invalidate 'vol' in the internal cache.
  *
  * LCK_LV:
  *   Lock/unlock an individual logical volume
@@ -37,6 +39,13 @@ int locking_is_clustered(void);
  */
 int lock_vol(struct cmd_context *cmd, const char *vol, uint32_t flags);
 
+/*
+ * Internal locking representation.
+ *   LCK_VG: Uses prefix V_ unless the vol begins with # (i.e. #global or #orphans)
+ *           or the LCK_CACHE flag is set when it uses the prefix P_.
+ * If LCK_CACHE is set, we do not take out a real lock.
+ */
+
 /*
  * Does the LVM1 driver have this VG active?
  */
@@ -69,7 +78,7 @@ int check_lvm1_vg_inactive(struct cmd_context *cmd, const char *vgname);
 #define LCK_HOLD       0x00000020U     /* Hold lock when lock_vol returns? */
 #define LCK_LOCAL      0x00000040U     /* Don't propagate to other nodes */
 #define LCK_CLUSTER_VG 0x00000080U     /* VG is clustered */
-#define LCK_CACHE      0x00000100U     /* Operation on cache using P_ lock */
+#define LCK_CACHE      0x00000100U     /* Operation on cache only using P_ lock */
 
 /*
  * Additional lock bits for cluster communication
This page took 0.048049 seconds and 5 git commands to generate.