summaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorJonathan Brassow <jbrassow@redhat.com>2012-09-11 12:55:17 -0500
committerJonathan Brassow <jbrassow@redhat.com>2012-09-11 12:55:17 -0500
commit05131f5853e86419d9c726faa961b8d012298d9c (patch)
tree21e9c8d363b9c65ae0fa1a143042ec5aeede0bf8 /tools
parentcdb0339319c89b8d1e5611537e9775a8c3ce5844 (diff)
downloadlvm2-05131f5853e86419d9c726faa961b8d012298d9c.tar.gz
lvm2-05131f5853e86419d9c726faa961b8d012298d9c.tar.xz
lvm2-05131f5853e86419d9c726faa961b8d012298d9c.zip
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.
Diffstat (limited to 'tools')
-rw-r--r--tools/lvchange.c98
1 files changed, 55 insertions, 43 deletions
diff --git a/tools/lvchange.c b/tools/lvchange.c
index 1f32d5c1..cbdb3535 100644
--- a/tools/lvchange.c
+++ b/tools/lvchange.c
@@ -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));
-
- 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;
- }
+ /* Separate mirror log so we can clear it */
+ detach_mirror_log(first_seg(lv));
- 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;
- }
+ 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;
+ }
- backup(lv->vg);
+ 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;
+ }
- if (!activate_lv(cmd, log_lv)) {
- log_error("Unable to activate %s for mirror log resync",
- log_lv->name);
- return 0;
- }
+ backup(lv->vg);
- 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 (!activate_lv(cmd, log_lv)) {
+ log_error("Unable to activate %s for mirror log resync",
+ log_lv->name);
+ 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;
- }
+ 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;
+ }
- /* Put mirror log back in place */
- if (!attach_mirror_log(first_seg(lv), log_lv))
- stack;
+ 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.");