1
0
mirror of git://sourceware.org/git/lvm2.git synced 2024-12-21 13:34:40 +03:00

Remove NON_BLOCKING lock flag from tools and set a policy to auto-set.

As a simplification to the tools and further liblvm, this patch pushes
the setting of NON_BLOCKING lock flag inside the lock_vol() call.
The policy we set is if any existing VGs are currently locked, we
set the NON_BLOCKING flag.

Should be no functional change.
This commit is contained in:
Dave Wysochanski 2009-05-13 13:02:52 +00:00
parent 5a945afdc6
commit d52b3fd3fe
10 changed files with 22 additions and 13 deletions

View File

@ -1,5 +1,6 @@
Version 2.02.46 - Version 2.02.46 -
================================ ================================
Remove NON_BLOCKING lock flag from tools and set a policy to auto-set.
Remove snapshot_count from VG and use function instead. Remove snapshot_count from VG and use function instead.
Fix first_seg() call for empty segment list. Fix first_seg() call for empty segment list.
Add make install_lvm2 as complement to device-mapper install. Add make install_lvm2 as complement to device-mapper install.

View File

@ -376,6 +376,14 @@ int lock_vol(struct cmd_context *cmd, const char *vol, uint32_t flags)
switch (flags & LCK_SCOPE_MASK) { switch (flags & LCK_SCOPE_MASK) {
case LCK_VG: case LCK_VG:
/*
* Automatically set LCK_NONBLOCK if one or more VGs locked.
* This will enforce correctness and prevent deadlocks rather
* than relying on the caller to set the flag properly.
*/
if (vgs_locked())
flags |= LCK_NONBLOCK;
/* Lock VG to change on-disk metadata. */ /* Lock VG to change on-disk metadata. */
/* If LVM1 driver knows about the VG, it can't be accessed. */ /* If LVM1 driver knows about the VG, it can't be accessed. */
if (!check_lvm1_vg_inactive(cmd, vol)) if (!check_lvm1_vg_inactive(cmd, vol))

View File

@ -1,6 +1,6 @@
/* /*
* Copyright (C) 2001-2004 Sistina Software, Inc. All rights reserved. * Copyright (C) 2001-2004 Sistina Software, Inc. All rights reserved.
* Copyright (C) 2004-2007 Red Hat, Inc. All rights reserved. * Copyright (C) 2004-2009 Red Hat, Inc. All rights reserved.
* *
* This file is part of LVM2. * This file is part of LVM2.
* *
@ -48,7 +48,7 @@ int vgcfgrestore(struct cmd_context *cmd, int argc, char **argv)
return ECMD_FAILED; return ECMD_FAILED;
} }
if (!lock_vol(cmd, vg_name, LCK_VG_WRITE | LCK_NONBLOCK)) { if (!lock_vol(cmd, vg_name, LCK_VG_WRITE)) {
log_error("Unable to lock volume group %s", vg_name); log_error("Unable to lock volume group %s", vg_name);
unlock_vg(cmd, VG_ORPHANS); unlock_vg(cmd, VG_ORPHANS);
return ECMD_FAILED; return ECMD_FAILED;

View File

@ -1,6 +1,6 @@
/* /*
* Copyright (C) 2001-2004 Sistina Software, Inc. All rights reserved. * Copyright (C) 2001-2004 Sistina Software, Inc. All rights reserved.
* Copyright (C) 2004-2007 Red Hat, Inc. All rights reserved. * Copyright (C) 2004-2009 Red Hat, Inc. All rights reserved.
* *
* This file is part of LVM2. * This file is part of LVM2.
* *
@ -51,7 +51,7 @@ int vgcreate(struct cmd_context *cmd, int argc, char **argv)
return ECMD_FAILED; return ECMD_FAILED;
} }
if (!lock_vol(cmd, vp_new.vg_name, LCK_VG_WRITE | LCK_NONBLOCK)) { if (!lock_vol(cmd, vp_new.vg_name, LCK_VG_WRITE)) {
log_error("Can't get lock for %s", vp_new.vg_name); log_error("Can't get lock for %s", vp_new.vg_name);
unlock_vg(cmd, VG_ORPHANS); unlock_vg(cmd, VG_ORPHANS);
return ECMD_FAILED; return ECMD_FAILED;

View File

@ -1,6 +1,6 @@
/* /*
* Copyright (C) 2001-2004 Sistina Software, Inc. All rights reserved. * Copyright (C) 2001-2004 Sistina Software, Inc. All rights reserved.
* Copyright (C) 2004-2007 Red Hat, Inc. All rights reserved. * Copyright (C) 2004-2009 Red Hat, Inc. All rights reserved.
* *
* This file is part of LVM2. * This file is part of LVM2.
* *
@ -42,7 +42,7 @@ int vgextend(struct cmd_context *cmd, int argc, char **argv)
} }
log_verbose("Checking for volume group \"%s\"", vg_name); log_verbose("Checking for volume group \"%s\"", vg_name);
if (!(vg = vg_lock_and_read(cmd, vg_name, NULL, LCK_VG_WRITE | LCK_NONBLOCK, if (!(vg = vg_lock_and_read(cmd, vg_name, NULL, LCK_VG_WRITE,
CLUSTERED | EXPORTED_VG | CLUSTERED | EXPORTED_VG |
LVM_WRITE | RESIZEABLE_VG, LVM_WRITE | RESIZEABLE_VG,
CORRECT_INCONSISTENT | FAIL_INCONSISTENT))) { CORRECT_INCONSISTENT | FAIL_INCONSISTENT))) {

View File

@ -1,6 +1,6 @@
/* /*
* Copyright (C) 2001-2004 Sistina Software, Inc. All rights reserved. * Copyright (C) 2001-2004 Sistina Software, Inc. All rights reserved.
* Copyright (C) 2004-2007 Red Hat, Inc. All rights reserved. * Copyright (C) 2004-2009 Red Hat, Inc. All rights reserved.
* *
* This file is part of LVM2. * This file is part of LVM2.
* *
@ -35,7 +35,7 @@ static int _vgmerge_single(struct cmd_context *cmd, const char *vg_name_to,
log_verbose("Checking for volume group \"%s\"", vg_name_from); log_verbose("Checking for volume group \"%s\"", vg_name_from);
if (!(vg_from = vg_lock_and_read(cmd, vg_name_from, NULL, if (!(vg_from = vg_lock_and_read(cmd, vg_name_from, NULL,
LCK_VG_WRITE | LCK_NONBLOCK, LCK_VG_WRITE,
CLUSTERED | EXPORTED_VG | LVM_WRITE, CLUSTERED | EXPORTED_VG | LVM_WRITE,
CORRECT_INCONSISTENT | FAIL_INCONSISTENT))) { CORRECT_INCONSISTENT | FAIL_INCONSISTENT))) {
unlock_release_vg(cmd, vg_to, vg_name_to); unlock_release_vg(cmd, vg_to, vg_name_to);

View File

@ -397,7 +397,7 @@ static int _vgreduce_single(struct cmd_context *cmd, struct volume_group *vg,
return ECMD_FAILED; return ECMD_FAILED;
} }
if (!lock_vol(cmd, VG_ORPHANS, LCK_VG_WRITE | LCK_NONBLOCK)) { if (!lock_vol(cmd, VG_ORPHANS, LCK_VG_WRITE)) {
log_error("Can't get lock for orphan PVs"); log_error("Can't get lock for orphan PVs");
return ECMD_FAILED; return ECMD_FAILED;
} }

View File

@ -1,6 +1,6 @@
/* /*
* Copyright (C) 2001-2004 Sistina Software, Inc. All rights reserved. * Copyright (C) 2001-2004 Sistina Software, Inc. All rights reserved.
* Copyright (C) 2004-2007 Red Hat, Inc. All rights reserved. * Copyright (C) 2004-2009 Red Hat, Inc. All rights reserved.
* *
* This file is part of LVM2. * This file is part of LVM2.
* *
@ -41,7 +41,7 @@ int vgremove(struct cmd_context *cmd, int argc, char **argv)
} }
ret = process_each_vg(cmd, argc, argv, ret = process_each_vg(cmd, argc, argv,
LCK_VG_WRITE | LCK_NONBLOCK, 1, LCK_VG_WRITE, 1,
NULL, &vgremove_single); NULL, &vgremove_single);
unlock_vg(cmd, VG_ORPHANS); unlock_vg(cmd, VG_ORPHANS);

View File

@ -100,7 +100,7 @@ static int vg_rename_path(struct cmd_context *cmd, const char *old_vg_path,
log_verbose("Checking for new volume group \"%s\"", vg_name_new); log_verbose("Checking for new volume group \"%s\"", vg_name_new);
if (!lock_vol(cmd, vg_name_new, LCK_VG_WRITE | LCK_NONBLOCK)) { if (!lock_vol(cmd, vg_name_new, LCK_VG_WRITE)) {
unlock_release_vg(cmd, vg, vg_name_old); unlock_release_vg(cmd, vg, vg_name_old);
log_error("Can't get lock for %s", vg_name_new); log_error("Can't get lock for %s", vg_name_new);
return 0; return 0;

View File

@ -325,7 +325,7 @@ int vgsplit(struct cmd_context *cmd, int argc, char **argv)
return ECMD_FAILED; return ECMD_FAILED;
log_verbose("Checking for new volume group \"%s\"", vg_name_to); log_verbose("Checking for new volume group \"%s\"", vg_name_to);
if (!lock_vol(cmd, vg_name_to, LCK_VG_WRITE | LCK_NONBLOCK)) { if (!lock_vol(cmd, vg_name_to, LCK_VG_WRITE)) {
log_error("Can't get lock for %s", vg_name_to); log_error("Can't get lock for %s", vg_name_to);
unlock_release_vg(cmd, vg_from, vg_name_from); unlock_release_vg(cmd, vg_from, vg_name_from);
return ECMD_FAILED; return ECMD_FAILED;