Skip to contentSkip to conversation

New --forceresync patch for LVM2 mirrors

linux-lvm Jonathan Brassow 1 participant 1 message Oct 23, 2006

lore
Share & tools
lore
#0 lore raw

I've reworked the --forceresync patch according to suggestions made by agk.

brassow

This patch adds the --forcesync option to lvchange, allowing users to force mirrors to resynchronize.

This operation is performed by clearing out the log device. It requires that the mirror be deactivated to do this.
If the mirror is in use, it can not be deactivated; and therefore, can not be forcesynced.

Mirrors can have a persistent (disk) log or a non-persistent (core) log. When a core log is employed, it is enough to simply deactivate and reactivate the mirror to start synchronization. The full detail is:
1) deactivate
2) clear any MIRROR_NOTSYNCED flag and commit meta data
3) activate
Items 1 & 3 are not necessary if the device was not active.

When a disk log is employed, we must detach the log device while we are clearing it and then reattach it. The full detail would be:
1) deactivate
2) clear the MIRROR_NOTSYNCED flag
3) detach the log device and commit meta data (including #2)
4) activate log
5) clear log
6) deactivate log
7) reattach log
8) commit meta data
9) activate
Items 1 & 9 are not needed if device was not active.

man/lvchange.8 +9 -0
Index: LVM2/man/lvchange.8
===================================================================
@@ -7,6 +7,7 @@ lvchange \- change attributes of a logic
 [\-A/\-\-autobackup y/n] [\-a/\-\-available y/n/ey/en/ly/ln]
 [\-\-alloc AllocationPolicy]
 [\-C/\-\-contiguous y/n] [\-d/\-\-debug] [\-\-deltag Tag]
+[\-\-forcesync]
 [\-h/\-?/\-\-help]
 [\-\-ignorelockingfailure]
 [\-\-monitor {y|n}]
@@ -40,6 +41,14 @@ logical volumes. It's only possible to c
 logical volume's allocation policy to contiguous, if all of the
 allocated physical extents are already contiguous.
 .TP
+.I \-\-forcesync
+This option only make sense if the logical volume being operated
+on is a mirrored logical volume.  This option is used to
+resynchronize the devices in a mirrored logical volume.  Since
+resynchronization can take considerable time and resources, you
+should consider using this option only if you have reason to
+believe that the devices in your mirror are no longer the same.
+.TP
 .I \-\-minor minor
 Set the minor number.
 .TP
tools/args.h +1 -0
Index: LVM2/tools/args.h
===================================================================
@@ -46,6 +46,7 @@ arg(alloc_ARG, '\0', "alloc", alloc_arg)
 arg(separator_ARG, '\0', "separator", string_arg)
 arg(mirrorsonly_ARG, '\0', "mirrorsonly", NULL)
 arg(nosync_ARG, '\0', "nosync", NULL)
+arg(forcesync_ARG, '\0', "forcesync", NULL)
 arg(corelog_ARG, '\0', "corelog", NULL)
 arg(monitor_ARG, '\0', "monitor", yes_no_arg)
 arg(config_ARG, '\0', "config", string_arg)
tools/commands.h +2 -1
Index: LVM2/tools/commands.h
===================================================================
@@ -61,6 +61,7 @@ xx(lvchange,
    "\t[-d|--debug]\n"
    "\t[--deltag Tag]\n"
    "\t[-f|--force]\n"
+   "\t[--forcesync]\n"
    "\t[-h|--help]\n"
    "\t[--ignorelockingfailure]\n"
    "\t[--monitor {y|n}]\n"
@@ -75,7 +76,7 @@ xx(lvchange,
    "\tLogicalVolume[Path] [LogicalVolume[Path]...]\n",
 
    alloc_ARG, autobackup_ARG, available_ARG, contiguous_ARG, force_ARG,
-   ignorelockingfailure_ARG, major_ARG, minor_ARG, monitor_ARG,
+   forcesync_ARG, ignorelockingfailure_ARG, major_ARG, minor_ARG, monitor_ARG,
    partial_ARG, permission_ARG, persistent_ARG, readahead_ARG,
    refresh_ARG, addtag_ARG, deltag_ARG, test_ARG)
 
tools/lvchange.c +121 -2

142 lines not on this page · raw message