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

cleanup: Reduce indentation by short-circuiting function

By changing the conditional for resyncing mirrors with core-logs a
bit, we can short-circuit the rest of the function for that case
and reduce the amount of indenting in the rest of the function.

This cleanup will simplify future patches aimed at properly handling
the resync of RAID LVs.
This commit is contained in:
Jonathan Brassow 2012-09-11 12:55:17 -05:00
parent cdb0339319
commit 05131f5853
2 changed files with 59 additions and 46 deletions

View File

@ -1,5 +1,6 @@
Version 2.02.98 -
=================================
Disallow addition of RAID images until the array is in-sync.
Fix RAID LV creation with '--test' so valid commands do not fail.
Add lvm_lv_rename() to lvm2api.
Fix setvbuf code by closing and reopening stream before changing buffer.

View File

@ -335,67 +335,79 @@ static int lvchange_resync(struct cmd_context *cmd,
* it to reset the sync status. We only need to
* worry about persistent logs.
*/
if (!log_lv && !(lv->status & LV_NOTSYNCED)) {
if (!log_lv) {
if (!(lv->status & LV_NOTSYNCED)) {
lv->status &= ~LV_NOTSYNCED;
log_very_verbose("Updating logical volume \"%s\""
" on disk(s)", lv->name);
if (!vg_write(lv->vg) || !vg_commit(lv->vg)) {
log_error("Failed to update metadata on disk.");
return 0;
}
}
if (active && !activate_lv(cmd, lv)) {
log_error("Failed to reactivate %s to resynchronize "
"mirror", lv->name);
return 0;
}
return 1;
}
/*
* Now we handle mirrors with log devices
*/
lv->status &= ~LV_NOTSYNCED;
if (log_lv) {
/* Separate mirror log so we can clear it */
detach_mirror_log(first_seg(lv));
/* Separate mirror log so we can clear it */
detach_mirror_log(first_seg(lv));
if (!vg_write(lv->vg)) {
log_error("Failed to write intermediate VG metadata.");
if (!attach_mirror_log(first_seg(lv), log_lv))
stack;
if (active && !activate_lv(cmd, lv))
stack;
return 0;
}
if (!vg_commit(lv->vg)) {
log_error("Failed to commit intermediate VG metadata.");
if (!attach_mirror_log(first_seg(lv), log_lv))
stack;
if (active && !activate_lv(cmd, lv))
stack;
return 0;
}
backup(lv->vg);
if (!activate_lv(cmd, log_lv)) {
log_error("Unable to activate %s for mirror log resync",
log_lv->name);
return 0;
}
log_very_verbose("Clearing log device %s", log_lv->name);
if (!set_lv(cmd, log_lv, log_lv->size, 0)) {
log_error("Unable to reset sync status for %s", lv->name);
if (!deactivate_lv(cmd, log_lv))
log_error("Failed to deactivate log LV after "
"wiping failed");
return 0;
}
if (!deactivate_lv(cmd, log_lv)) {
log_error("Unable to deactivate log LV %s after wiping "
"for resync", log_lv->name);
return 0;
}
/* Put mirror log back in place */
if (!vg_write(lv->vg)) {
log_error("Failed to write intermediate VG metadata.");
if (!attach_mirror_log(first_seg(lv), log_lv))
stack;
if (active && !activate_lv(cmd, lv))
stack;
return 0;
}
if (!vg_commit(lv->vg)) {
log_error("Failed to commit intermediate VG metadata.");
if (!attach_mirror_log(first_seg(lv), log_lv))
stack;
if (active && !activate_lv(cmd, lv))
stack;
return 0;
}
backup(lv->vg);
if (!activate_lv(cmd, log_lv)) {
log_error("Unable to activate %s for mirror log resync",
log_lv->name);
return 0;
}
log_very_verbose("Clearing log device %s", log_lv->name);
if (!set_lv(cmd, log_lv, log_lv->size, 0)) {
log_error("Unable to reset sync status for %s", lv->name);
if (!deactivate_lv(cmd, log_lv))
log_error("Failed to deactivate log LV after "
"wiping failed");
return 0;
}
if (!deactivate_lv(cmd, log_lv)) {
log_error("Unable to deactivate log LV %s after wiping "
"for resync", log_lv->name);
return 0;
}
/* Put mirror log back in place */
if (!attach_mirror_log(first_seg(lv), log_lv))
stack;
log_very_verbose("Updating logical volume \"%s\" on disk(s)", lv->name);
if (!vg_write(lv->vg) || !vg_commit(lv->vg)) {
log_error("Failed to update metadata on disk.");