/* 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);
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;
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);
/*
* 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
*/
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?
*/
#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