diff --git a/WHATS_NEW b/WHATS_NEW index 56cc42a10..4bce21b7f 100644 --- a/WHATS_NEW +++ b/WHATS_NEW @@ -2,7 +2,7 @@ Version 2.02.66 - =============================== Validate orphan and VG_GLOBAL lock order too. Accept orphan VG names as parameters to lock_vol() and related functions. - Use is_orphan_vg in place of hard-coded prefix tests. + Use is_orphan_vg in place of hard-coded prefix tests and add is_global_vg. Version 2.02.65 - 17th May 2010 =============================== diff --git a/lib/cache/lvmcache.h b/lib/cache/lvmcache.h index 8eeb49511..5706dcff2 100644 --- a/lib/cache/lvmcache.h +++ b/lib/cache/lvmcache.h @@ -19,9 +19,10 @@ #include "dev-cache.h" #include "uuid.h" #include "label.h" +#include "locking.h" -#define ORPHAN_PREFIX "#" -#define ORPHAN_VG_NAME(fmt) ORPHAN_PREFIX "orphans_" fmt +#define ORPHAN_PREFIX VG_ORPHANS +#define ORPHAN_VG_NAME(fmt) ORPHAN_PREFIX "_" fmt #define CACHE_INVALID 0x00000001 #define CACHE_LOCKED 0x00000002 diff --git a/lib/locking/cluster_locking.c b/lib/locking/cluster_locking.c index 58f59fc73..1a0dbfdc8 100644 --- a/lib/locking/cluster_locking.c +++ b/lib/locking/cluster_locking.c @@ -406,7 +406,7 @@ int lock_resource(struct cmd_context *cmd, const char *resource, uint32_t flags) } /* If the VG name is empty then lock the unused PVs */ - if (is_orphan_vg(resource) || (flags & LCK_CACHE)) + if (is_orphan_vg(resource) || is_global_vg(resource) || (flags & LCK_CACHE)) dm_snprintf(lockname, sizeof(lockname), "P_%s", resource); else diff --git a/lib/locking/file_locking.c b/lib/locking/file_locking.c index a6ef086a0..46232cc19 100644 --- a/lib/locking/file_locking.c +++ b/lib/locking/file_locking.c @@ -265,7 +265,7 @@ static int _file_lock_resource(struct cmd_context *cmd, const char *resource, if (flags & LCK_CACHE) break; - if (is_orphan_vg(resource)) + if (is_orphan_vg(resource) || is_global_vg(resource)) dm_snprintf(lockfile, sizeof(lockfile), "%s/P_%s", _lock_dir, resource + 1); else diff --git a/lib/locking/locking.c b/lib/locking/locking.c index cbafa4540..ab391af65 100644 --- a/lib/locking/locking.c +++ b/lib/locking/locking.c @@ -325,7 +325,7 @@ int check_lvm1_vg_inactive(struct cmd_context *cmd, const char *vgname) char path[PATH_MAX]; /* We'll allow operations on orphans */ - if (is_orphan_vg(vgname)) + if (is_orphan_vg(vgname) || is_global_vg(vgname)) return 1; /* LVM1 is only present in 2.4 kernels. */ @@ -369,7 +369,7 @@ static int _lock_vol(struct cmd_context *cmd, const char *resource, return 0; } - if (is_orphan_vg(resource) && (flags & LCK_CACHE)) { + if ((is_orphan_vg(resource) || is_global_vg(resource)) && (flags & LCK_CACHE)) { log_error(INTERNAL_ERROR "P_%s referenced", resource); return 0; } diff --git a/lib/metadata/metadata.c b/lib/metadata/metadata.c index 63b921e47..017e8ce75 100644 --- a/lib/metadata/metadata.c +++ b/lib/metadata/metadata.c @@ -3337,7 +3337,7 @@ int is_global_vg(const char *vg_name) */ int is_orphan_vg(const char *vg_name) { - return (vg_name && vg_name[0] == ORPHAN_PREFIX[0]) ? 1 : 0; + return (vg_name && !strncmp(vg_name, ORPHAN_PREFIX, sizeof(ORPHAN_PREFIX) - 1)) ? 1 : 0; } /**