summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorAlasdair Kergon <agk@redhat.com>2010-05-19 01:16:40 +0000
committerAlasdair Kergon <agk@redhat.com>2010-05-19 01:16:40 +0000
commitfa305e2ec65f9e8f4449b79b76570ee1c525635e (patch)
tree0bb679a2dca1538f56e6f7f3227f2538b05b1805 /lib
parent24d21cfceeac1ad37676521da985d5958e05e143 (diff)
downloadlvm2-fa305e2ec65f9e8f4449b79b76570ee1c525635e.tar.gz
lvm2-fa305e2ec65f9e8f4449b79b76570ee1c525635e.tar.xz
lvm2-fa305e2ec65f9e8f4449b79b76570ee1c525635e.zip
Accept orphan VG names as parameters to lock_vol() and related functions.
Diffstat (limited to 'lib')
-rw-r--r--lib/cache/lvmcache.c2
-rw-r--r--lib/locking/locking.c14
-rw-r--r--lib/metadata/metadata.c16
3 files changed, 15 insertions, 17 deletions
diff --git a/lib/cache/lvmcache.c b/lib/cache/lvmcache.c
index 22e4517b..34c54ad6 100644
--- a/lib/cache/lvmcache.c
+++ b/lib/cache/lvmcache.c
@@ -290,7 +290,7 @@ int vgname_is_locked(const char *vgname)
if (!_lock_hash)
return 0;
- return dm_hash_lookup(_lock_hash, vgname) ? 1 : 0;
+ return dm_hash_lookup(_lock_hash, is_orphan_vg(vgname) ? VG_ORPHANS : vgname) ? 1 : 0;
}
void lvmcache_unlock_vgname(const char *vgname)
diff --git a/lib/locking/locking.c b/lib/locking/locking.c
index 3abf8f28..032d97da 100644
--- a/lib/locking/locking.c
+++ b/lib/locking/locking.c
@@ -417,16 +417,16 @@ int lock_vol(struct cmd_context *cmd, const char *vol, uint32_t flags)
switch (flags & LCK_SCOPE_MASK) {
case LCK_VG:
- /*
- * VG locks alphabetical, ORPHAN lock last
- */
if (!_blocking_supported)
flags |= LCK_NONBLOCK;
- if (!is_orphan_vg(vol) &&
- ((flags & LCK_TYPE_MASK) != LCK_UNLOCK) &&
- (!(flags & LCK_CACHE)) &&
- !lvmcache_verify_lock_order(vol))
+ /* Global VG_ORPHANS lock covers all orphan formats. */
+ if (is_orphan_vg(vol))
+ vol = VG_ORPHANS;
+ /* VG locks alphabetical, ORPHAN lock last */
+ else if (((flags & LCK_TYPE_MASK) != LCK_UNLOCK) &&
+ !(flags & LCK_CACHE) &&
+ !lvmcache_verify_lock_order(vol))
return 0;
/* Lock VG to change on-disk metadata. */
diff --git a/lib/metadata/metadata.c b/lib/metadata/metadata.c
index 12cb5e41..0bd7455f 100644
--- a/lib/metadata/metadata.c
+++ b/lib/metadata/metadata.c
@@ -3459,7 +3459,7 @@ int vg_check_status(const struct volume_group *vg, uint64_t status)
return !_vg_bad_status_bits(vg, status);
}
-static struct volume_group *_recover_vg(struct cmd_context *cmd, const char *lock_name,
+static struct volume_group *_recover_vg(struct cmd_context *cmd,
const char *vg_name, const char *vgid,
uint32_t lock_flags)
{
@@ -3469,11 +3469,11 @@ static struct volume_group *_recover_vg(struct cmd_context *cmd, const char *loc
lock_flags &= ~LCK_TYPE_MASK;
lock_flags |= LCK_WRITE;
- unlock_vg(cmd, lock_name);
+ unlock_vg(cmd, vg_name);
dev_close_all();
- if (!lock_vol(cmd, lock_name, lock_flags))
+ if (!lock_vol(cmd, vg_name, lock_flags))
return_NULL;
if (!(vg = vg_read_internal(cmd, vg_name, vgid, &consistent)))
@@ -3503,7 +3503,6 @@ static struct volume_group *_vg_lock_and_read(struct cmd_context *cmd, const cha
uint64_t status_flags, uint32_t misc_flags)
{
struct volume_group *vg = NULL;
- const char *lock_name;
int consistent = 1;
int consistent_in;
uint32_t failure = 0;
@@ -3518,11 +3517,10 @@ static struct volume_group *_vg_lock_and_read(struct cmd_context *cmd, const cha
return NULL;
}
- lock_name = is_orphan_vg(vg_name) ? VG_ORPHANS : vg_name;
- already_locked = vgname_is_locked(lock_name);
+ already_locked = vgname_is_locked(vg_name);
if (!already_locked && !(misc_flags & READ_WITHOUT_LOCK) &&
- !lock_vol(cmd, lock_name, lock_flags)) {
+ !lock_vol(cmd, vg_name, lock_flags)) {
log_error("Can't get lock for %s", vg_name);
return _vg_make_handle(cmd, vg, FAILED_LOCKING);
}
@@ -3555,7 +3553,7 @@ static struct volume_group *_vg_lock_and_read(struct cmd_context *cmd, const cha
/* consistent == 0 when VG is not found, but failed == FAILED_NOTFOUND */
if (!consistent && !failure) {
vg_release(vg);
- if (!(vg = _recover_vg(cmd, lock_name, vg_name, vgid, lock_flags))) {
+ if (!(vg = _recover_vg(cmd, vg_name, vgid, lock_flags))) {
log_error("Recovery of volume group \"%s\" failed.",
vg_name);
failure |= FAILED_INCONSISTENT;
@@ -3592,7 +3590,7 @@ static struct volume_group *_vg_lock_and_read(struct cmd_context *cmd, const cha
bad:
if (!already_locked && !(misc_flags & READ_WITHOUT_LOCK))
- unlock_vg(cmd, lock_name);
+ unlock_vg(cmd, vg_name);
return _vg_make_handle(cmd, vg, failure);
}