1
0
mirror of git://sourceware.org/git/lvm2.git synced 2025-01-03 05:18:29 +03:00

Convert vg->status checks to use vg_check_status function.\nRename status_flags to status in vg_check_status.

This commit is contained in:
Dave Wysochanski 2007-06-19 04:36:12 +00:00
parent 69483a8aaf
commit d6b1de30fe
11 changed files with 18 additions and 56 deletions

View File

@ -1744,33 +1744,33 @@ int pv_analyze(struct cmd_context *cmd, const char *pv_name,
/** /**
* vg_check_status - check volume group status flags and log error * vg_check_status - check volume group status flags and log error
* @vg - volume group to check status flags * @vg - volume group to check status flags
* @status_flags - specific status flags to check (e.g. EXPORTED_VG) * @status - specific status flags to check (e.g. EXPORTED_VG)
* *
* Returns: * Returns:
* 0 - fail * 0 - fail
* 1 - success * 1 - success
*/ */
int vg_check_status(struct volume_group *vg, uint32_t status_flags) int vg_check_status(struct volume_group *vg, uint32_t status)
{ {
if ((status_flags & CLUSTERED) && if ((status & CLUSTERED) &&
(vg->status & CLUSTERED) && !locking_is_clustered() && (vg->status & CLUSTERED) && !locking_is_clustered() &&
!lockingfailed()) { !lockingfailed()) {
log_error("Skipping clustered volume group %s", vg->name); log_error("Skipping clustered volume group %s", vg->name);
return 0; return 0;
} }
if ((status_flags & EXPORTED_VG) && if ((status & EXPORTED_VG) &&
(vg->status & EXPORTED_VG)) { (vg->status & EXPORTED_VG)) {
log_error("Volume group %s is exported", vg->name); log_error("Volume group %s is exported", vg->name);
return 0; return 0;
} }
if ((status_flags & LVM_WRITE) && if ((status & LVM_WRITE) &&
!(vg->status & LVM_WRITE)) { !(vg->status & LVM_WRITE)) {
log_error("Volume group %s is read-only", vg->name); log_error("Volume group %s is read-only", vg->name);
return 0; return 0;
} }
if ((status_flags & RESIZEABLE_VG) && if ((status & RESIZEABLE_VG) &&
!(vg->status & RESIZEABLE_VG)) { !(vg->status & RESIZEABLE_VG)) {
log_error("Volume group %s is not resizeable.", vg->name); log_error("Volume group %s is not resizeable.", vg->name);
return 0; return 0;

View File

@ -580,7 +580,7 @@ int vg_add_snapshot(struct format_instance *fid, const char *name,
int vg_remove_snapshot(struct logical_volume *cow); int vg_remove_snapshot(struct logical_volume *cow);
int vg_check_status(struct volume_group *vg, uint32_t status_flags); int vg_check_status(struct volume_group *vg, uint32_t status);
/* /*
* Mirroring functions * Mirroring functions

View File

@ -24,10 +24,8 @@ static int lvremove_single(struct cmd_context *cmd, struct logical_volume *lv,
vg = lv->vg; vg = lv->vg;
if (!(vg->status & LVM_WRITE)) { if (!vg_check_status(vg, LVM_WRITE))
log_error("Volume group \"%s\" is read-only", vg->name);
return ECMD_FAILED; return ECMD_FAILED;
}
if (lv_is_origin(lv)) { if (lv_is_origin(lv)) {
log_error("Can't remove logical volume \"%s\" under snapshot", log_error("Can't remove logical volume \"%s\" under snapshot",
@ -77,7 +75,7 @@ static int lvremove_single(struct cmd_context *cmd, struct logical_volume *lv,
/* If the VG is clustered then make sure no-one else is using the LV /* If the VG is clustered then make sure no-one else is using the LV
we are about to remove */ we are about to remove */
if (vg->status & CLUSTERED) { if (vg_status(vg) & CLUSTERED) {
if (!activate_lv_excl(cmd, lv)) { if (!activate_lv_excl(cmd, lv)) {
log_error("Can't get exclusive access to volume \"%s\"", log_error("Can't get exclusive access to volume \"%s\"",
lv->name); lv->name);

View File

@ -191,10 +191,8 @@ static int _poll_vg(struct cmd_context *cmd, const char *vgname,
return ECMD_FAILED; return ECMD_FAILED;
} }
if (vg->status & EXPORTED_VG) { if (!vg_check_status(vg, EXPORTED_VG))
log_error("Volume group \"%s\" is exported", vg->name);
return ECMD_FAILED; return ECMD_FAILED;
}
list_iterate_items(lvl, &vg->lvs) { list_iterate_items(lvl, &vg->lvs) {
lv_mirr = lvl->lv; lv_mirr = lvl->lv;

View File

@ -159,10 +159,8 @@ int process_each_lv_in_vg(struct cmd_context *cmd, struct volume_group *vg,
struct lv_list *lvl; struct lv_list *lvl;
if (vg->status & EXPORTED_VG) { if (!vg_check_status(vg, EXPORTED_VG))
log_error("Volume group \"%s\" is exported", vg->name);
return ECMD_FAILED; return ECMD_FAILED;
}
if (tags && !list_empty(tags)) if (tags && !list_empty(tags))
tags_supplied = 1; tags_supplied = 1;

View File

@ -30,10 +30,8 @@ static int vgck_single(struct cmd_context *cmd __attribute((unused)),
return ECMD_FAILED; return ECMD_FAILED;
} }
if (vg->status & EXPORTED_VG) { if (!vg_check_status(vg, EXPORTED_VG))
log_error("Volume group \"%s\" is exported", vg_name);
return ECMD_FAILED; return ECMD_FAILED;
}
return ECMD_PROCESSED; return ECMD_PROCESSED;
} }

View File

@ -45,15 +45,8 @@ static int vgconvert_single(struct cmd_context *cmd, const char *vg_name,
return ECMD_FAILED; return ECMD_FAILED;
} }
if (!(vg->status & LVM_WRITE)) { if (!vg_check_status(vg, LVM_WRITE | EXPORTED_VG))
log_error("Volume group \"%s\" is read-only", vg->name);
return ECMD_FAILED; return ECMD_FAILED;
}
if (vg->status & EXPORTED_VG) {
log_error("Volume group \"%s\" is exported", vg_name);
return ECMD_FAILED;
}
if (vg->fid->fmt == cmd->fmt) { if (vg->fid->fmt == cmd->fmt) {
log_error("Volume group \"%s\" already uses format %s", log_error("Volume group \"%s\" already uses format %s",

View File

@ -28,8 +28,7 @@ static int vgdisplay_single(struct cmd_context *cmd, const char *vg_name,
if (!consistent) if (!consistent)
log_error("WARNING: Volume group \"%s\" inconsistent", vg_name); log_error("WARNING: Volume group \"%s\" inconsistent", vg_name);
if (vg->status & EXPORTED_VG) vg_check_status(vg, EXPORTED_VG);
log_print("WARNING: volume group \"%s\" is exported", vg_name);
if (arg_count(cmd, colon_ARG)) { if (arg_count(cmd, colon_ARG)) {
vgdisplay_colons(vg); vgdisplay_colons(vg);

View File

@ -33,13 +33,7 @@ static int vgexport_single(struct cmd_context *cmd __attribute((unused)),
goto error; goto error;
} }
if (vg->status & EXPORTED_VG) { if (!vg_check_status(vg, EXPORTED_VG | LVM_WRITE)) {
log_error("Volume group \"%s\" is already exported", vg_name);
goto error;
}
if (!(vg->status & LVM_WRITE)) {
log_error("Volume group \"%s\" is read-only", vg_name);
goto error; goto error;
} }

View File

@ -532,21 +532,7 @@ int vgreduce(struct cmd_context *cmd, int argc, char **argv)
log_print("Wrote out consistent volume group %s", vg_name); log_print("Wrote out consistent volume group %s", vg_name);
} else { } else {
if (vg->status & EXPORTED_VG) { if (!vg_check_status(vg, EXPORTED_VG | LVM_WRITE | RESIZEABLE_VG)) {
log_error("Volume group \"%s\" is exported", vg->name);
unlock_vg(cmd, vg_name);
return ECMD_FAILED;
}
if (!(vg->status & LVM_WRITE)) {
log_error("Volume group \"%s\" is read-only", vg_name);
unlock_vg(cmd, vg_name);
return ECMD_FAILED;
}
if (!(vg->status & RESIZEABLE_VG)) {
log_error("Volume group \"%s\" is not reducible",
vg_name);
unlock_vg(cmd, vg_name); unlock_vg(cmd, vg_name);
return ECMD_FAILED; return ECMD_FAILED;
} }

View File

@ -23,7 +23,7 @@ static int vgremove_single(struct cmd_context *cmd, const char *vg_name,
struct pv_list *pvl; struct pv_list *pvl;
int ret = ECMD_PROCESSED; int ret = ECMD_PROCESSED;
if (!vg || !consistent || (vg->status & PARTIAL_VG)) { if (!vg || !consistent || (vg_status(vg) & PARTIAL_VG)) {
log_error("Volume group \"%s\" not found or inconsistent.", log_error("Volume group \"%s\" not found or inconsistent.",
vg_name); vg_name);
log_error("Consider vgreduce --removemissing if metadata " log_error("Consider vgreduce --removemissing if metadata "
@ -31,10 +31,8 @@ static int vgremove_single(struct cmd_context *cmd, const char *vg_name,
return ECMD_FAILED; return ECMD_FAILED;
} }
if (vg->status & EXPORTED_VG) { if (!vg_check_status(vg, EXPORTED_VG))
log_error("Volume group \"%s\" is exported", vg->name);
return ECMD_FAILED; return ECMD_FAILED;
}
if (vg->lv_count) { if (vg->lv_count) {
log_error("Volume group \"%s\" still contains %d " log_error("Volume group \"%s\" still contains %d "