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:
parent
69483a8aaf
commit
d6b1de30fe
@ -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 - 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:
|
||||
* 0 - fail
|
||||
* 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() &&
|
||||
!lockingfailed()) {
|
||||
log_error("Skipping clustered volume group %s", vg->name);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if ((status_flags & EXPORTED_VG) &&
|
||||
if ((status & EXPORTED_VG) &&
|
||||
(vg->status & EXPORTED_VG)) {
|
||||
log_error("Volume group %s is exported", vg->name);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if ((status_flags & LVM_WRITE) &&
|
||||
if ((status & LVM_WRITE) &&
|
||||
!(vg->status & LVM_WRITE)) {
|
||||
log_error("Volume group %s is read-only", vg->name);
|
||||
return 0;
|
||||
}
|
||||
if ((status_flags & RESIZEABLE_VG) &&
|
||||
if ((status & RESIZEABLE_VG) &&
|
||||
!(vg->status & RESIZEABLE_VG)) {
|
||||
log_error("Volume group %s is not resizeable.", vg->name);
|
||||
return 0;
|
||||
|
@ -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_check_status(struct volume_group *vg, uint32_t status_flags);
|
||||
int vg_check_status(struct volume_group *vg, uint32_t status);
|
||||
|
||||
/*
|
||||
* Mirroring functions
|
||||
|
@ -24,10 +24,8 @@ static int lvremove_single(struct cmd_context *cmd, struct logical_volume *lv,
|
||||
|
||||
vg = lv->vg;
|
||||
|
||||
if (!(vg->status & LVM_WRITE)) {
|
||||
log_error("Volume group \"%s\" is read-only", vg->name);
|
||||
if (!vg_check_status(vg, LVM_WRITE))
|
||||
return ECMD_FAILED;
|
||||
}
|
||||
|
||||
if (lv_is_origin(lv)) {
|
||||
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
|
||||
we are about to remove */
|
||||
if (vg->status & CLUSTERED) {
|
||||
if (vg_status(vg) & CLUSTERED) {
|
||||
if (!activate_lv_excl(cmd, lv)) {
|
||||
log_error("Can't get exclusive access to volume \"%s\"",
|
||||
lv->name);
|
||||
|
@ -191,10 +191,8 @@ static int _poll_vg(struct cmd_context *cmd, const char *vgname,
|
||||
return ECMD_FAILED;
|
||||
}
|
||||
|
||||
if (vg->status & EXPORTED_VG) {
|
||||
log_error("Volume group \"%s\" is exported", vg->name);
|
||||
if (!vg_check_status(vg, EXPORTED_VG))
|
||||
return ECMD_FAILED;
|
||||
}
|
||||
|
||||
list_iterate_items(lvl, &vg->lvs) {
|
||||
lv_mirr = lvl->lv;
|
||||
|
@ -159,10 +159,8 @@ int process_each_lv_in_vg(struct cmd_context *cmd, struct volume_group *vg,
|
||||
|
||||
struct lv_list *lvl;
|
||||
|
||||
if (vg->status & EXPORTED_VG) {
|
||||
log_error("Volume group \"%s\" is exported", vg->name);
|
||||
if (!vg_check_status(vg, EXPORTED_VG))
|
||||
return ECMD_FAILED;
|
||||
}
|
||||
|
||||
if (tags && !list_empty(tags))
|
||||
tags_supplied = 1;
|
||||
|
@ -30,10 +30,8 @@ static int vgck_single(struct cmd_context *cmd __attribute((unused)),
|
||||
return ECMD_FAILED;
|
||||
}
|
||||
|
||||
if (vg->status & EXPORTED_VG) {
|
||||
log_error("Volume group \"%s\" is exported", vg_name);
|
||||
if (!vg_check_status(vg, EXPORTED_VG))
|
||||
return ECMD_FAILED;
|
||||
}
|
||||
|
||||
return ECMD_PROCESSED;
|
||||
}
|
||||
|
@ -45,15 +45,8 @@ static int vgconvert_single(struct cmd_context *cmd, const char *vg_name,
|
||||
return ECMD_FAILED;
|
||||
}
|
||||
|
||||
if (!(vg->status & LVM_WRITE)) {
|
||||
log_error("Volume group \"%s\" is read-only", vg->name);
|
||||
if (!vg_check_status(vg, LVM_WRITE | EXPORTED_VG))
|
||||
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) {
|
||||
log_error("Volume group \"%s\" already uses format %s",
|
||||
|
@ -28,8 +28,7 @@ static int vgdisplay_single(struct cmd_context *cmd, const char *vg_name,
|
||||
if (!consistent)
|
||||
log_error("WARNING: Volume group \"%s\" inconsistent", vg_name);
|
||||
|
||||
if (vg->status & EXPORTED_VG)
|
||||
log_print("WARNING: volume group \"%s\" is exported", vg_name);
|
||||
vg_check_status(vg, EXPORTED_VG);
|
||||
|
||||
if (arg_count(cmd, colon_ARG)) {
|
||||
vgdisplay_colons(vg);
|
||||
|
@ -33,13 +33,7 @@ static int vgexport_single(struct cmd_context *cmd __attribute((unused)),
|
||||
goto error;
|
||||
}
|
||||
|
||||
if (vg->status & EXPORTED_VG) {
|
||||
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);
|
||||
if (!vg_check_status(vg, EXPORTED_VG | LVM_WRITE)) {
|
||||
goto error;
|
||||
}
|
||||
|
||||
|
@ -532,21 +532,7 @@ int vgreduce(struct cmd_context *cmd, int argc, char **argv)
|
||||
log_print("Wrote out consistent volume group %s", vg_name);
|
||||
|
||||
} else {
|
||||
if (vg->status & EXPORTED_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);
|
||||
if (!vg_check_status(vg, EXPORTED_VG | LVM_WRITE | RESIZEABLE_VG)) {
|
||||
unlock_vg(cmd, vg_name);
|
||||
return ECMD_FAILED;
|
||||
}
|
||||
|
@ -23,7 +23,7 @@ static int vgremove_single(struct cmd_context *cmd, const char *vg_name,
|
||||
struct pv_list *pvl;
|
||||
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.",
|
||||
vg_name);
|
||||
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;
|
||||
}
|
||||
|
||||
if (vg->status & EXPORTED_VG) {
|
||||
log_error("Volume group \"%s\" is exported", vg->name);
|
||||
if (!vg_check_status(vg, EXPORTED_VG))
|
||||
return ECMD_FAILED;
|
||||
}
|
||||
|
||||
if (vg->lv_count) {
|
||||
log_error("Volume group \"%s\" still contains %d "
|
||||
|
Loading…
Reference in New Issue
Block a user