From: Alasdair Kergon Date: Wed, 19 May 2010 00:52:55 +0000 (+0000) Subject: Use is_orphan_vg in place of hard-coded prefix tests. X-Git-Tag: old-v2_02_66~22 X-Git-Url: https://sourceware.org/git/?a=commitdiff_plain;h=bea9cf67250cd9f03bee84df31f71738b6a46195;p=lvm2.git Use is_orphan_vg in place of hard-coded prefix tests. --- diff --git a/WHATS_NEW b/WHATS_NEW index 3feb1eb4c..25324b94b 100644 --- a/WHATS_NEW +++ b/WHATS_NEW @@ -1,5 +1,6 @@ Version 2.02.66 - =============================== + Use is_orphan_vg in place of hard-coded prefix tests. Version 2.02.65 - 17th May 2010 =============================== diff --git a/lib/cache/lvmcache.c b/lib/cache/lvmcache.c index 940c61f39..22e4517b2 100644 --- a/lib/cache/lvmcache.c +++ b/lib/cache/lvmcache.c @@ -224,11 +224,11 @@ void lvmcache_drop_metadata(const char *vgname, int drop_precommitted) /* * Ensure vgname2 comes after vgname1 alphabetically. - * Special VG names beginning with '#' don't count. + * Orphans don't count. */ static int _vgname_order_correct(const char *vgname1, const char *vgname2) { - if ((*vgname1 == '#') || (*vgname2 == '#')) + if (is_orphan_vg(vgname1) || is_orphan_vg(vgname2)) return 1; if (strcmp(vgname1, vgname2) < 0) diff --git a/lib/locking/cluster_locking.c b/lib/locking/cluster_locking.c index aff213a93..58f59fc73 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 (*resource == '#' || (flags & LCK_CACHE)) + if (is_orphan_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 f47961dfd..a6ef086a0 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 (*resource == '#') + if (is_orphan_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 c663c2853..3abf8f288 100644 --- a/lib/locking/locking.c +++ b/lib/locking/locking.c @@ -369,7 +369,7 @@ static int _lock_vol(struct cmd_context *cmd, const char *resource, return 0; } - if (*resource == '#' && (flags & LCK_CACHE)) { + if (is_orphan_vg(resource) && (flags & LCK_CACHE)) { log_error(INTERNAL_ERROR "P_%s referenced", resource); return 0; } @@ -423,7 +423,7 @@ int lock_vol(struct cmd_context *cmd, const char *vol, uint32_t flags) if (!_blocking_supported) flags |= LCK_NONBLOCK; - if (vol[0] != '#' && + if (!is_orphan_vg(vol) && ((flags & LCK_TYPE_MASK) != LCK_UNLOCK) && (!(flags & LCK_CACHE)) && !lvmcache_verify_lock_order(vol))