diff options
-rw-r--r-- | lib/activate/activate.c | 41 | ||||
-rw-r--r-- | lib/activate/activate.h | 9 | ||||
-rw-r--r-- | lib/locking/file_locking.c | 4 | ||||
-rw-r--r-- | lib/locking/locking.h | 11 | ||||
-rw-r--r-- | tools/lvchange.c | 16 | ||||
-rw-r--r-- | tools/lvcreate.c | 2 | ||||
-rw-r--r-- | tools/lvrename.c | 8 | ||||
-rw-r--r-- | tools/lvresize.c | 10 | ||||
-rw-r--r-- | tools/pvchange.c | 16 | ||||
-rw-r--r-- | tools/toollib.c | 8 | ||||
-rw-r--r-- | tools/vgcreate.c | 14 | ||||
-rw-r--r-- | tools/vgextend.c | 10 | ||||
-rw-r--r-- | tools/vgmerge.c | 16 | ||||
-rw-r--r-- | tools/vgreduce.c | 10 | ||||
-rw-r--r-- | tools/vgremove.c | 2 | ||||
-rw-r--r-- | tools/vgrename.c | 18 |
16 files changed, 83 insertions, 112 deletions
diff --git a/lib/activate/activate.c b/lib/activate/activate.c index 07a2eb68..6936d9a5 100644 --- a/lib/activate/activate.c +++ b/lib/activate/activate.c @@ -112,25 +112,8 @@ int lv_open_count(struct logical_volume *lv) return info.open_count; } -int lv_activate(struct logical_volume *lv) -{ - int r; - struct dev_manager *dm; - - if (!(dm = dev_manager_create(lv->vg->name))) { - stack; - return 0; - } - - if (!(r = dev_manager_activate(dm, lv))) - stack; - - dev_manager_destroy(dm); - return r; -} - /* FIXME Need to detect and handle an lv rename */ -int lv_reactivate(struct logical_volume *lv) +static int _lv_activate(struct logical_volume *lv) { int r; struct dev_manager *dm; @@ -147,7 +130,7 @@ int lv_reactivate(struct logical_volume *lv) return r; } -int lv_deactivate(struct logical_volume *lv) +static int _lv_deactivate(struct logical_volume *lv) { int r; struct dev_manager *dm; @@ -164,7 +147,7 @@ int lv_deactivate(struct logical_volume *lv) return r; } -int lv_suspend(struct logical_volume *lv) +static int _lv_suspend(struct logical_volume *lv) { #if 0 char buffer[128]; @@ -308,8 +291,6 @@ static struct logical_volume *_lv_from_lvid(struct cmd_context *cmd, return lvl->lv; } -/* These functions should become the new interface and the _if_active - * bits then disappear */ int lv_suspend_if_active(struct cmd_context *cmd, const char *lvid_s) { struct logical_volume *lv; @@ -318,7 +299,7 @@ int lv_suspend_if_active(struct cmd_context *cmd, const char *lvid_s) return 0; if (lv_active(lv) > 0) - lv_suspend(lv); + _lv_suspend(lv); return 1; } @@ -332,12 +313,12 @@ int lv_resume_if_active(struct cmd_context *cmd, const char *lvid_s) return 0; if ((lv_active(lv) > 0) && lv_suspended(lv)) - lv_reactivate(lv); + _lv_activate(lv); return 1; } -int lv_deactivate_if_active(struct cmd_context *cmd, const char *lvid_s) +int lv_deactivate(struct cmd_context *cmd, const char *lvid_s) { struct logical_volume *lv; @@ -345,12 +326,12 @@ int lv_deactivate_if_active(struct cmd_context *cmd, const char *lvid_s) return 0; if (lv_active(lv) > 0) - lv_deactivate(lv); + _lv_deactivate(lv); return 1; } -int lv_activate_if_inactive(struct cmd_context *cmd, const char *lvid_s) +int lv_activate(struct cmd_context *cmd, const char *lvid_s) { struct logical_volume *lv; int active; @@ -360,10 +341,8 @@ int lv_activate_if_inactive(struct cmd_context *cmd, const char *lvid_s) active = lv_active(lv); - if ((active > 0) && lv_suspended(lv)) { - lv_reactivate(lv); - } else if (!active) - lv_activate(lv); + if (!active || ((active > 0) && lv_suspended(lv))) + _lv_activate(lv); return 1; } diff --git a/lib/activate/activate.h b/lib/activate/activate.h index 39a1ff4e..f080ff67 100644 --- a/lib/activate/activate.h +++ b/lib/activate/activate.h @@ -28,22 +28,17 @@ int lv_info(struct logical_volume *lv, struct dm_info *info); /* * Activation proper. */ -int lv_activate(struct logical_volume *lv); -int lv_reactivate(struct logical_volume *lv); -int lv_deactivate(struct logical_volume *lv); -int lv_suspend(struct logical_volume *lv); int lv_rename(const char *old_name, struct logical_volume *lv); - /* * These should eventually replace some of the above and maybe * use config file to determine whether or not to activate */ int lv_suspend_if_active(struct cmd_context *cmd, const char *lvid_s); int lv_resume_if_active(struct cmd_context *cmd, const char *lvid_s); -int lv_activate_if_inactive(struct cmd_context *cmd, const char *lvid_s); -int lv_deactivate_if_active(struct cmd_context *cmd, const char *lvid_s); +int lv_activate(struct cmd_context *cmd, const char *lvid_s); +int lv_deactivate(struct cmd_context *cmd, const char *lvid_s); /* diff --git a/lib/locking/file_locking.c b/lib/locking/file_locking.c index 32f05c78..4ec614f6 100644 --- a/lib/locking/file_locking.c +++ b/lib/locking/file_locking.c @@ -167,7 +167,7 @@ int lock_resource(struct cmd_context *cmd, const char *resource, int flags) return 0; break; case LCK_READ: - if (!lv_activate_if_inactive(cmd, resource)) + if (!lv_activate(cmd, resource)) return 0; break; case LCK_WRITE: @@ -175,7 +175,7 @@ int lock_resource(struct cmd_context *cmd, const char *resource, int flags) return 0; break; case LCK_EXCL: - if (!lv_deactivate_if_active(cmd, resource)) + if (!lv_deactivate(cmd, resource)) return 0; break; default: diff --git a/lib/locking/locking.h b/lib/locking/locking.h index 93836905..7939ca85 100644 --- a/lib/locking/locking.h +++ b/lib/locking/locking.h @@ -20,13 +20,7 @@ void fin_locking(void); * * LCK_LV: * Lock/unlock an individual logical volume - * If it's active, LCK_WRITE suspends it; LCK_EXCLUSIVE deactivates it; - * LCK_NONE unsuspends it. - * LCK_READ activates it. - * char *vol holds "VG_name/LV_uuid" - * - * FIXME: Change to something like - * int lock_vol(struct cmd_context *cmd, const struct id *id, int flags); + * char *vol holds lvid */ int lock_vol(struct cmd_context *cmd, const char *vol, int flags); @@ -64,3 +58,6 @@ int lock_vol(struct cmd_context *cmd, const char *vol, int flags); #define LCK_LV_ACTIVATE (LCK_LV | LCK_READ) #define LCK_LV_UNLOCK (LCK_LV | LCK_NONE) +#define unlock_lv(cmd, vol) lock_vol(cmd, vol, LCK_LV_UNLOCK) +#define unlock_vg(cmd, vol) lock_vol(cmd, vol, LCK_VG_UNLOCK) + diff --git a/tools/lvchange.c b/tools/lvchange.c index 4b648932..b4d4103a 100644 --- a/tools/lvchange.c +++ b/tools/lvchange.c @@ -159,14 +159,14 @@ static int lvchange_permission(struct cmd_context *cmd, log_very_verbose("Updating logical volume \"%s\" on disk(s)", lv->name); if (!cmd->fid->ops->vg_write(cmd->fid, lv->vg)) { /* FIXME: Attempt reversion? */ - lock_vol(cmd, lv->lvid.s, LCK_LV_UNLOCK); + unlock_lv(cmd, lv->lvid.s); return 0; } backup(lv->vg); log_very_verbose("Updating permissions for \"%s\" in kernel", lv->name); - if (!lock_vol(cmd, lv->lvid.s, LCK_LV_UNLOCK)) { + if (!unlock_lv(cmd, lv->lvid.s)) { log_error("Problem reactivating %s", lv->name); return 0; } @@ -247,14 +247,14 @@ static int lvchange_contiguous(struct cmd_context *cmd, log_very_verbose("Updating logical volume \"%s\" on disk(s)", lv->name); if (!cmd->fid->ops->vg_write(cmd->fid, lv->vg)) { /* FIXME: Attempt reversion? */ - lock_vol(cmd, lv->lvid.s, LCK_LV_UNLOCK); + unlock_lv(cmd, lv->lvid.s); return 0; } backup(lv->vg); log_very_verbose("Reactivating \"%s\" in kernel", lv->name); - if (!lock_vol(cmd, lv->lvid.s, LCK_LV_UNLOCK)) { + if (!unlock_lv(cmd, lv->lvid.s)) { log_error("Problem reactivating %s", lv->name); return 0; } @@ -296,14 +296,14 @@ static int lvchange_readahead(struct cmd_context *cmd, log_very_verbose("Updating logical volume \"%s\" on disk(s)", lv->name); if (!cmd->fid->ops->vg_write(cmd->fid, lv->vg)) { /* FIXME: Attempt reversion? */ - lock_vol(cmd, lv->lvid.s, LCK_LV_UNLOCK); + unlock_lv(cmd, lv->lvid.s); return 0; } backup(lv->vg); log_very_verbose("Reactivating \"%s\" in kernel", lv->name); - if (!lock_vol(cmd, lv->lvid.s, LCK_LV_UNLOCK)) { + if (!unlock_lv(cmd, lv->lvid.s)) { log_error("Problem reactivating %s", lv->name); return 0; } @@ -347,14 +347,14 @@ static int lvchange_persistent(struct cmd_context *cmd, log_very_verbose("Updating logical volume \"%s\" on disk(s)", lv->name); if (!cmd->fid->ops->vg_write(cmd->fid, lv->vg)) { /* FIXME: Attempt reversion? */ - lock_vol(cmd, lv->lvid.s, LCK_LV_UNLOCK); + unlock_lv(cmd, lv->lvid.s); return 0; } backup(lv->vg); log_very_verbose("Reactivating \"%s\" in kernel", lv->name); - if (!lock_vol(cmd, lv->lvid.s, LCK_LV_UNLOCK)) { + if (!unlock_lv(cmd, lv->lvid.s)) { log_error("Problem reactivating %s", lv->name); return 0; } diff --git a/tools/lvcreate.c b/tools/lvcreate.c index 3a9bd272..ff921125 100644 --- a/tools/lvcreate.c +++ b/tools/lvcreate.c @@ -465,6 +465,6 @@ int lvcreate(struct cmd_context *cmd, int argc, char **argv) r = 0; out: - lock_vol(cmd, lp.vg_name, LCK_VG_UNLOCK); + unlock_vg(cmd, lp.vg_name); return r; } diff --git a/tools/lvrename.c b/tools/lvrename.c index 282e6921..e9bea0f7 100644 --- a/tools/lvrename.c +++ b/tools/lvrename.c @@ -136,11 +136,11 @@ int lvrename(struct cmd_context *cmd, int argc, char **argv) if (!(cmd->fid->ops->vg_write(cmd->fid, vg))) goto lverror; - lock_vol(cmd, lv->lvid.s, LCK_LV_UNLOCK); + unlock_lv(cmd, lv->lvid.s); backup(lv->vg); - lock_vol(cmd, vg_name, LCK_VG_UNLOCK); + unlock_vg(cmd, vg_name); log_print("Renamed \"%s\" to \"%s\" in volume group \"%s\"", lv_name_old, lv_name_new, vg_name); @@ -149,9 +149,9 @@ int lvrename(struct cmd_context *cmd, int argc, char **argv) lverror: - lock_vol(cmd, lv->lvid.s, LCK_LV_UNLOCK); + unlock_lv(cmd, lv->lvid.s); error: - lock_vol(cmd, vg_name, LCK_VG_UNLOCK); + unlock_vg(cmd, vg_name); return ECMD_FAILED; } diff --git a/tools/lvresize.c b/tools/lvresize.c index a8c7256b..99cd6c67 100644 --- a/tools/lvresize.c +++ b/tools/lvresize.c @@ -339,28 +339,28 @@ int lvresize(struct cmd_context *cmd, int argc, char **argv) /* store vg on disk(s) */ if (!cmd->fid->ops->vg_write(cmd->fid, vg)) { /* FIXME: Attempt reversion? */ - lock_vol(cmd, lv->lvid.s, LCK_LV_UNLOCK); + unlock_lv(cmd, lv->lvid.s); goto error; } backup(vg); - if (!lock_vol(cmd, lv->lvid.s, LCK_LV_UNLOCK)) { + if (!unlock_lv(cmd, lv->lvid.s)) { log_error("Problem reactivating %s", lv_name); goto error; } - lock_vol(cmd, vg_name, LCK_VG_UNLOCK); + unlock_vg(cmd, vg_name); log_print("Logical volume %s successfully resized", lv_name); return 0; error: - lock_vol(cmd, vg_name, LCK_VG_UNLOCK); + unlock_vg(cmd, vg_name); return ECMD_FAILED; error_cmdline: - lock_vol(cmd, vg_name, LCK_VG_UNLOCK); + unlock_vg(cmd, vg_name); return EINVALID_CMD_LINE; } diff --git a/tools/pvchange.c b/tools/pvchange.c index 7277c9a0..97f22d0d 100644 --- a/tools/pvchange.c +++ b/tools/pvchange.c @@ -104,26 +104,26 @@ int pvchange_single(struct cmd_context *cmd, struct physical_volume *pv) } if (!(vg = cmd->fid->ops->vg_read(cmd->fid, pv->vg_name))) { - lock_vol(cmd, pv->vg_name, LCK_VG_UNLOCK); + unlock_vg(cmd, pv->vg_name); log_error("Unable to find volume group of \"%s\"", pv_name); return 0; } if (vg->status & EXPORTED_VG) { - lock_vol(cmd, pv->vg_name, LCK_VG_UNLOCK); + unlock_vg(cmd, pv->vg_name); log_error("Volume group \"%s\" is exported", vg->name); return ECMD_FAILED; } if (!(vg->status & LVM_WRITE)) { - lock_vol(cmd, pv->vg_name, LCK_VG_UNLOCK); + unlock_vg(cmd, pv->vg_name); log_error("Volume group \"%s\" is read-only", vg->name); return ECMD_FAILED; } if (!(pvl = find_pv_in_vg(vg, pv_name))) { - lock_vol(cmd, pv->vg_name, LCK_VG_UNLOCK); + unlock_vg(cmd, pv->vg_name); log_error ("Unable to find \"%s\" in volume group \"%s\"", pv_name, vg->name); @@ -139,7 +139,7 @@ int pvchange_single(struct cmd_context *cmd, struct physical_volume *pv) log_error("Physical volume \"%s\" is already allocatable", pv_name); if (*pv->vg_name) - lock_vol(cmd, pv->vg_name, LCK_VG_UNLOCK); + unlock_vg(cmd, pv->vg_name); return 0; } @@ -147,7 +147,7 @@ int pvchange_single(struct cmd_context *cmd, struct physical_volume *pv) log_error("Physical volume \"%s\" is already unallocatable", pv_name); if (*pv->vg_name) - lock_vol(cmd, pv->vg_name, LCK_VG_UNLOCK); + unlock_vg(cmd, pv->vg_name); return 0; } @@ -164,13 +164,13 @@ int pvchange_single(struct cmd_context *cmd, struct physical_volume *pv) log_verbose("Updating physical volume \"%s\"", pv_name); if (*pv->vg_name) { if (!(cmd->fid->ops->vg_write(cmd->fid, vg))) { - lock_vol(cmd, pv->vg_name, LCK_VG_UNLOCK); + unlock_vg(cmd, pv->vg_name); log_error("Failed to store physical volume \"%s\" in " "volume group \"%s\"", pv_name, vg->name); return 0; } backup(vg); - lock_vol(cmd, pv->vg_name, LCK_VG_UNLOCK); + unlock_vg(cmd, pv->vg_name); } else { if (!(cmd->fid->ops->pv_write(cmd->fid, pv))) { log_error("Failed to store physical volume \"%s\"", diff --git a/tools/toollib.c b/tools/toollib.c index 39e7e9a7..ff60184a 100644 --- a/tools/toollib.c +++ b/tools/toollib.c @@ -134,13 +134,13 @@ int process_each_vg(struct cmd_context *cmd, int argc, char **argv, log_verbose("Using volume group(s) on command line"); for (; opt < argc; opt++) { vg_name = argv[opt]; - if (!lock_vol(cmd, (void *) vg_name, LCK_VG | lock_type)) { + if (!lock_vol(cmd, vg_name, LCK_VG | lock_type)) { log_error("Can't lock %s: skipping", vg_name); continue; } if ((ret = process_single(cmd, vg_name)) > ret_max) ret_max = ret; - lock_vol(cmd, (void *) vg_name, LCK_VG_UNLOCK); + unlock_vg(cmd, vg_name); } } else { log_verbose("Finding all volume groups"); @@ -150,7 +150,7 @@ int process_each_vg(struct cmd_context *cmd, int argc, char **argv, } list_iterate(vgh, vgs) { vg_name = list_item(vgh, struct name_list)->name; - if (!lock_vol(cmd, (void *) vg_name, LCK_VG | lock_type)) { + if (!lock_vol(cmd, vg_name, LCK_VG | lock_type)) { log_error("Can't lock %s: skipping", vg_name); continue; } @@ -158,7 +158,7 @@ int process_each_vg(struct cmd_context *cmd, int argc, char **argv, if (ret > ret_max) ret_max = ret; - lock_vol(cmd, (void *) vg_name, LCK_VG_UNLOCK); + unlock_vg(cmd, vg_name); } } diff --git a/tools/vgcreate.c b/tools/vgcreate.c index bc83ef2a..1eb5adef 100644 --- a/tools/vgcreate.c +++ b/tools/vgcreate.c @@ -99,25 +99,25 @@ int vgcreate(struct cmd_context *cmd, int argc, char **argv) if (!lock_vol(cmd, vg_name, LCK_VG_WRITE | LCK_NONBLOCK)) { log_error("Can't get lock for %s", vg_name); - lock_vol(cmd, "", LCK_VG_UNLOCK); + unlock_vg(cmd, ""); return ECMD_FAILED; } if (!archive(vg)) { - lock_vol(cmd, vg_name, LCK_VG_UNLOCK); - lock_vol(cmd, "", LCK_VG_UNLOCK); + unlock_vg(cmd, vg_name); + unlock_vg(cmd, ""); return ECMD_FAILED; } /* Store VG on disk(s) */ if (!cmd->fid->ops->vg_write(cmd->fid, vg)) { - lock_vol(cmd, vg_name, LCK_VG_UNLOCK); - lock_vol(cmd, "", LCK_VG_UNLOCK); + unlock_vg(cmd, vg_name); + unlock_vg(cmd, ""); return ECMD_FAILED; } - lock_vol(cmd, vg_name, LCK_VG_UNLOCK); - lock_vol(cmd, "", LCK_VG_UNLOCK); + unlock_vg(cmd, vg_name); + unlock_vg(cmd, ""); backup(vg); diff --git a/tools/vgextend.c b/tools/vgextend.c index f6082f27..62ee8de3 100644 --- a/tools/vgextend.c +++ b/tools/vgextend.c @@ -47,7 +47,7 @@ int vgextend(struct cmd_context *cmd, int argc, char **argv) log_verbose("Checking for volume group \"%s\"", vg_name); if (!lock_vol(cmd, vg_name, LCK_VG_WRITE | LCK_NONBLOCK)) { - lock_vol(cmd, "", LCK_VG_UNLOCK); + unlock_vg(cmd, ""); log_error("Can't get lock for %s", vg_name); goto error; } @@ -96,15 +96,15 @@ int vgextend(struct cmd_context *cmd, int argc, char **argv) backup(vg); - lock_vol(cmd, vg_name, LCK_VG_UNLOCK); - lock_vol(cmd, "", LCK_VG_UNLOCK); + unlock_vg(cmd, vg_name); + unlock_vg(cmd, ""); log_print("Volume group \"%s\" successfully extended", vg_name); return 0; error: - lock_vol(cmd, vg_name, LCK_VG_UNLOCK); - lock_vol(cmd, "", LCK_VG_UNLOCK); + unlock_vg(cmd, vg_name); + unlock_vg(cmd, ""); return ECMD_FAILED; } diff --git a/tools/vgmerge.c b/tools/vgmerge.c index 26a52312..72c4b7e1 100644 --- a/tools/vgmerge.c +++ b/tools/vgmerge.c @@ -67,26 +67,26 @@ int vgmerge_single(struct cmd_context *cmd, const char *vg_name_to, if (!(vg_to = cmd->fid->ops->vg_read(cmd->fid, vg_name_to))) { log_error("Volume group \"%s\" doesn't exist", vg_name_to); - lock_vol(cmd, vg_name_to, LCK_VG_UNLOCK); + unlock_vg(cmd, vg_name_to); return ECMD_FAILED; } if (vg_to->status & EXPORTED_VG) { log_error("Volume group \"%s\" is exported", vg_to->name); - lock_vol(cmd, vg_name_to, LCK_VG_UNLOCK); + unlock_vg(cmd, vg_name_to); return ECMD_FAILED; } if (!(vg_to->status & LVM_WRITE)) { log_error("Volume group \"%s\" is read-only", vg_to->name); - lock_vol(cmd, vg_name_to, LCK_VG_UNLOCK); + unlock_vg(cmd, vg_name_to); return ECMD_FAILED; } log_verbose("Checking for volume group \"%s\"", vg_name_from); if (!lock_vol(cmd, vg_name_from, LCK_VG_WRITE | LCK_NONBLOCK)) { log_error("Can't get lock for %s", vg_name_from); - lock_vol(cmd, vg_name_to, LCK_VG_UNLOCK); + unlock_vg(cmd, vg_name_to); return ECMD_FAILED; } @@ -190,15 +190,15 @@ int vgmerge_single(struct cmd_context *cmd, const char *vg_name_to, backup(vg_to); - lock_vol(cmd, vg_name_from, LCK_VG_UNLOCK); - lock_vol(cmd, vg_name_to, LCK_VG_UNLOCK); + unlock_vg(cmd, vg_name_from); + unlock_vg(cmd, vg_name_to); log_print("Volume group \"%s\" successfully merged into \"%s\"", vg_from->name, vg_to->name); return 0; error: - lock_vol(cmd, vg_name_from, LCK_VG_UNLOCK); - lock_vol(cmd, vg_name_to, LCK_VG_UNLOCK); + unlock_vg(cmd, vg_name_from); + unlock_vg(cmd, vg_name_to); return ECMD_FAILED; } diff --git a/tools/vgreduce.c b/tools/vgreduce.c index ff51ca30..0bdfd33c 100644 --- a/tools/vgreduce.c +++ b/tools/vgreduce.c @@ -58,25 +58,25 @@ int vgreduce(struct cmd_context *cmd, int argc, char **argv) if (!(vg = cmd->fid->ops->vg_read(cmd->fid, vg_name))) { log_error("Volume group \"%s\" doesn't exist", vg_name); - lock_vol(cmd, vg_name, LCK_VG_UNLOCK); + unlock_vg(cmd, vg_name); return ECMD_FAILED; } if (vg->status & EXPORTED_VG) { log_error("Volume group \"%s\" is exported", vg->name); - lock_vol(cmd, vg_name, LCK_VG_UNLOCK); + unlock_vg(cmd, vg_name); return ECMD_FAILED; } if (!(vg->status & LVM_WRITE)) { log_error("Volume group \"%s\" is read-only", vg_name); - lock_vol(cmd, vg_name, LCK_VG_UNLOCK); + unlock_vg(cmd, vg_name); return ECMD_FAILED; } if (!(vg->status & RESIZEABLE_VG)) { log_error("Volume group \"%s\" is not reducable", vg_name); - lock_vol(cmd, vg_name, LCK_VG_UNLOCK); + unlock_vg(cmd, vg_name); return ECMD_FAILED; } @@ -84,7 +84,7 @@ int vgreduce(struct cmd_context *cmd, int argc, char **argv) /* and update in batch here? */ ret = process_each_pv(cmd, argc, argv, vg, vgreduce_single); - lock_vol(cmd, vg_name, LCK_VG_UNLOCK); + unlock_vg(cmd, vg_name); return ret; diff --git a/tools/vgremove.c b/tools/vgremove.c index 5f898ff9..8ae46e3e 100644 --- a/tools/vgremove.c +++ b/tools/vgremove.c @@ -34,7 +34,7 @@ int vgremove(struct cmd_context *cmd, int argc, char **argv) ret = process_each_vg(cmd, argc, argv, LCK_WRITE | LCK_NONBLOCK, &vgremove_single); - lock_vol(cmd, "", LCK_VG_UNLOCK); + unlock_vg(cmd, ""); return ret; } diff --git a/tools/vgrename.c b/tools/vgrename.c index de178059..cde54217 100644 --- a/tools/vgrename.c +++ b/tools/vgrename.c @@ -76,18 +76,18 @@ int vgrename(struct cmd_context *cmd, int argc, char **argv) if (!(vg_old = cmd->fid->ops->vg_read(cmd->fid, vg_name_old))) { log_error("Volume group \"%s\" doesn't exist", vg_name_old); - lock_vol(cmd, vg_name_old, LCK_VG_UNLOCK); + unlock_vg(cmd, vg_name_old); return ECMD_FAILED; } if (vg_old->status & EXPORTED_VG) { - lock_vol(cmd, vg_name_old, LCK_VG_UNLOCK); + unlock_vg(cmd, vg_name_old); log_error("Volume group \"%s\" is exported", vg_old->name); return ECMD_FAILED; } if (!(vg_old->status & LVM_WRITE)) { - lock_vol(cmd, vg_name_old, LCK_VG_UNLOCK); + unlock_vg(cmd, vg_name_old); log_error("Volume group \"%s\" is read-only", vg_old->name); return ECMD_FAILED; } @@ -98,7 +98,7 @@ int vgrename(struct cmd_context *cmd, int argc, char **argv) /***** FIXME Handle this with multiple LV renames! if (!force_ARG) { log_error("Use -f to force the rename"); - lock_vol(cmd, vg_name_old, LCK_VG_UNLOCK); + unlock_vg(cmd, vg_name_old); return ECMD_FAILED; } *****/ @@ -107,7 +107,7 @@ int vgrename(struct cmd_context *cmd, int argc, char **argv) log_verbose("Checking for new volume group \"%s\"", vg_name_new); if (!lock_vol(cmd, vg_name_new, LCK_VG_WRITE | LCK_NONBLOCK)) { - lock_vol(cmd, vg_name_old, LCK_VG_UNLOCK); + unlock_vg(cmd, vg_name_old); log_error("Can't get lock for %s", vg_name_new); return ECMD_FAILED; } @@ -158,8 +158,8 @@ int vgrename(struct cmd_context *cmd, int argc, char **argv) backup(vg_old); - lock_vol(cmd, vg_name_new, LCK_VG_UNLOCK); - lock_vol(cmd, vg_name_old, LCK_VG_UNLOCK); + unlock_vg(cmd, vg_name_new); + unlock_vg(cmd, vg_name_old); log_print("Volume group \"%s\" successfully renamed to \"%s\"", vg_name_old, vg_name_new); @@ -167,8 +167,8 @@ int vgrename(struct cmd_context *cmd, int argc, char **argv) return 0; error: - lock_vol(cmd, vg_name_new, LCK_VG_UNLOCK); - lock_vol(cmd, vg_name_old, LCK_VG_UNLOCK); + unlock_vg(cmd, vg_name_new); + unlock_vg(cmd, vg_name_old); return ECMD_FAILED; } |