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

Fix process_each_vg / _process_one_vg when vg_read() returns FAILED_LOCKING.

Remove the checks for vg_read_error() in most of the tools callback
functions and instead make the check in _process_one_vg() more general.

In all but vgcfgbackup, we do not want to proceed if we get any error
from vg_read().  In vgcfgbackup's case, we may proceed if the backup
is to proceed with inconsistent VGs.  This is a special case though,
and we mark it with the READ_ALLOW_INCONSISTENT flag passed to
process_each_vg (and subsequently to _process_one_vg).

NOTE: More cleanup is needed in the vg_read_error() path cases.
This patch is a start.
This commit is contained in:
Dave Wysochanski 2009-09-15 01:38:59 +00:00
parent 90c8088760
commit 266214db84
13 changed files with 12 additions and 51 deletions

View File

@ -1,8 +1,10 @@
Version 2.02.52 -
=================================
Update _process_one_vg to cleanup properly after vg_read_error.
Add lots of missing stack debug messages to tools.
Make readonly locking available as locking type 4.
Fix readonly locking to permit writeable global locks (for vgscan). (2.02.49)
Add lvm_vg_is_clustered, lvm_vg_is_exported, and lvm_vg_is_partial.
Add manpage entry for dmsetup's udevcomplete_all and udevcookies commands.
Add DM_UDEV_RULES_VSN udev enviroment variable.
Check that udev is running and set internal state appropriately.

View File

@ -185,11 +185,6 @@ static int _poll_vg(struct cmd_context *cmd, const char *vgname,
const char *name;
int finished;
if (vg_read_error(vg)) {
stack;
return ECMD_FAILED;
}
dm_list_iterate_items(lvl, &vg->lvs) {
lv_mirr = lvl->lv;
if (!(lv_mirr->status & parms->lv_type))

View File

@ -20,11 +20,6 @@ static int _vgs_single(struct cmd_context *cmd __attribute((unused)),
const char *vg_name, struct volume_group *vg,
void *handle)
{
if (vg_read_error(vg)) {
stack;
return ECMD_FAILED;
}
if (!report_object(handle, vg, NULL, NULL, NULL, NULL)) {
stack;
return ECMD_FAILED;

View File

@ -433,10 +433,11 @@ static int _process_one_vg(struct cmd_context *cmd, const char *vg_name,
vg = vg_read(cmd, vg_name, vgid, flags);
/* Allow FAILED_INCONSISTENT through only for vgcfgrestore */
if (vg_read_error(vg) && (vg_read_error(vg) != FAILED_INCONSISTENT)) {
vg_release(vg);
if (vg_read_error(vg) &&
!((vg_read_error(vg) == FAILED_INCONSISTENT)&&(flags & READ_ALLOW_INCONSISTENT))) {
ret_max = ECMD_FAILED;
stack;
return ECMD_FAILED;
goto out;
}
if (!dm_list_empty(tags)) {
@ -451,7 +452,11 @@ static int _process_one_vg(struct cmd_context *cmd, const char *vg_name,
ret_max = ret;
out:
unlock_and_release_vg(cmd, vg, vg_name);
if ((vg_read_error(vg) == FAILED_ALLOCATION)||
(vg_read_error(vg) == FAILED_LOCKING))
vg_release(vg);
else
unlock_and_release_vg(cmd, vg, vg_name);
return ret_max;
}

View File

@ -92,7 +92,7 @@ int vgcfgbackup(struct cmd_context *cmd, int argc, char **argv)
init_pvmove(1);
ret = process_each_vg(cmd, argc, argv, 0,
ret = process_each_vg(cmd, argc, argv, READ_ALLOW_INCONSISTENT,
&last_filename, &vg_backup_single);
dm_free(last_filename);

View File

@ -496,11 +496,6 @@ static int vgchange_single(struct cmd_context *cmd, const char *vg_name,
{
int r = ECMD_FAILED;
if (vg_read_error(vg)) {
stack;
return ECMD_FAILED;
}
if (vg_is_exported(vg)) {
log_error("Volume group \"%s\" is exported", vg_name);
return ECMD_FAILED;

View File

@ -21,11 +21,6 @@ static int vgck_single(struct cmd_context *cmd __attribute((unused)),
struct volume_group *vg,
void *handle __attribute((unused)))
{
if (vg_read_error(vg)) {
stack;
return ECMD_FAILED;
}
if (!vg_check_status(vg, EXPORTED_VG)) {
stack;
return ECMD_FAILED;

View File

@ -32,11 +32,6 @@ static int vgconvert_single(struct cmd_context *cmd, const char *vg_name,
struct lvinfo info;
int active = 0;
if (vg_read_error(vg)) {
stack;
return ECMD_FAILED;
}
if (!vg_check_status(vg, LVM_WRITE | EXPORTED_VG)) {
stack;
return ECMD_FAILED;

View File

@ -20,11 +20,6 @@ static int vgdisplay_single(struct cmd_context *cmd, const char *vg_name,
void *handle __attribute((unused)))
{
/* FIXME Do the active check here if activevolumegroups_ARG ? */
if (vg_read_error(vg)) {
stack;
return ECMD_FAILED;
}
vg_check_status(vg, EXPORTED_VG);
if (arg_count(cmd, colon_ARG)) {

View File

@ -23,9 +23,6 @@ static int vgexport_single(struct cmd_context *cmd __attribute((unused)),
struct pv_list *pvl;
struct physical_volume *pv;
if (vg_read_error(vg))
goto_bad;
if (lvs_in_vg_activated(vg)) {
log_error("Volume group \"%s\" has active logical volumes",
vg_name);

View File

@ -23,9 +23,6 @@ static int vgimport_single(struct cmd_context *cmd __attribute((unused)),
struct pv_list *pvl;
struct physical_volume *pv;
if (vg_read_error(vg))
goto_bad;
if (!vg_is_exported(vg)) {
log_error("Volume group \"%s\" is not exported", vg_name);
goto bad;

View File

@ -22,11 +22,6 @@ static int vgremove_single(struct cmd_context *cmd, const char *vg_name,
unsigned lv_count;
force_t force;
if (vg_read_error(vg)) {
stack;
return ECMD_FAILED;
}
if (!vg_check_status(vg, EXPORTED_VG)) {
stack;
return ECMD_FAILED;

View File

@ -19,11 +19,6 @@ static int vgscan_single(struct cmd_context *cmd, const char *vg_name,
struct volume_group *vg,
void *handle __attribute((unused)))
{
if (vg_read_error(vg)) {
stack;
return ECMD_FAILED;
}
log_print("Found %svolume group \"%s\" using metadata type %s",
vg_is_exported(vg) ? "exported " : "", vg_name,
vg->fid->fmt->name);