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

Update lvconvert and lvrename to use vg_lock_and_read

This commit is contained in:
Dave Wysochanski 2007-07-23 22:20:42 +00:00
parent d2f218cc46
commit 0c8b215a60
2 changed files with 6 additions and 24 deletions

View File

@ -534,7 +534,6 @@ static int lvconvert_single(struct cmd_context *cmd, struct logical_volume *lv,
int lvconvert(struct cmd_context * cmd, int argc, char **argv) int lvconvert(struct cmd_context * cmd, int argc, char **argv)
{ {
int consistent = 1;
struct volume_group *vg; struct volume_group *vg;
struct lv_list *lvl; struct lv_list *lvl;
struct lvconvert_params lp; struct lvconvert_params lp;
@ -547,18 +546,10 @@ int lvconvert(struct cmd_context * cmd, int argc, char **argv)
log_verbose("Checking for existing volume group \"%s\"", lp.vg_name); log_verbose("Checking for existing volume group \"%s\"", lp.vg_name);
if (!lock_vol(cmd, lp.vg_name, LCK_VG_WRITE)) { if (!(vg = vg_lock_and_read(cmd, lp.vg_name, LCK_VG_WRITE,
log_error("Can't get lock for %s", lp.vg_name); CLUSTERED | EXPORTED_VG | LVM_WRITE,
CORRECT_INCONSISTENT)))
return ECMD_FAILED; return ECMD_FAILED;
}
if (!(vg = vg_read(cmd, lp.vg_name, NULL, &consistent))) {
log_error("Volume group \"%s\" doesn't exist", lp.vg_name);
goto error;
}
if (!vg_check_status(vg, CLUSTERED | EXPORTED_VG | LVM_WRITE))
goto error;
if (!(lvl = find_lv_in_vg(vg, lp.lv_name))) { if (!(lvl = find_lv_in_vg(vg, lp.lv_name))) {
log_error("Logical volume \"%s\" not found in " log_error("Logical volume \"%s\" not found in "

View File

@ -22,7 +22,6 @@ int lvrename(struct cmd_context *cmd, int argc, char **argv)
char *lv_name_old, *lv_name_new; char *lv_name_old, *lv_name_new;
const char *vg_name, *vg_name_new, *vg_name_old; const char *vg_name, *vg_name_new, *vg_name_old;
char *st; char *st;
int consistent = 1;
struct volume_group *vg; struct volume_group *vg;
struct logical_volume *lv; struct logical_volume *lv;
@ -99,18 +98,10 @@ int lvrename(struct cmd_context *cmd, int argc, char **argv)
log_verbose("Checking for existing volume group \"%s\"", vg_name); log_verbose("Checking for existing volume group \"%s\"", vg_name);
if (!lock_vol(cmd, vg_name, LCK_VG_WRITE)) { if (!(vg = vg_lock_and_read(cmd, vg_name, LCK_VG_WRITE,
log_error("Can't get lock for %s", vg_name); CLUSTERED | EXPORTED_VG | LVM_WRITE,
CORRECT_INCONSISTENT)))
return ECMD_FAILED; return ECMD_FAILED;
}
if (!(vg = vg_read(cmd, vg_name, NULL, &consistent))) {
log_error("Volume group \"%s\" doesn't exist", vg_name);
goto error;
}
if (!vg_check_status(vg, CLUSTERED | EXPORTED_VG | LVM_WRITE))
goto error;
if (find_lv_in_vg(vg, lv_name_new)) { if (find_lv_in_vg(vg, lv_name_new)) {
log_error("Logical volume \"%s\" already exists in " log_error("Logical volume \"%s\" already exists in "