Add mirror force resync option to lvchange
PATCH 1/1 Add mirror force resync option to lvchange
Hi,
Attached is a patch implementing "--forcesync" option of lvchange to start resync regardless of current log status.
If the LV is created with "--nosync" option, the volume type flag of lvs changes from "M" to "m".
This is useful to ensure mirrors are resynced after failure in corner case.
Comments are welcome.
Thanks,
Signature · 1 line
Jun'ichi Nomura, NEC Corporation of America
Add --forcesync option to lvchange to force resync mirror LV. It also turns 'M' (without initial sync) flag into 'm' (normal mirror) if the LV is created with --nosync.
Applicable to LVM2 2.02.09.
include/log.h +2 -0
@@ -75,6 +75,7 @@ void init_ignorelockingfailure(int levelvoid init_lockingfailed (int level);void init_security_level (int level);void init_mirror_in_sync (int in_sync); +void init_mirror_force_sync (int force_sync);void init_dmeventd_register (int reg);void set_cmd_name (const char *cmd_name);
@@ -90,6 +91,7 @@ int ignorelockingfailure(void);int lockingfailed (void );int security_level (void );int mirror_in_sync (void ); +int mirror_force_sync (void );int dmeventd_register_mode (void );/* Suppress messages to stdout/stderr (1) or everywhere (2) */
lib/log/log.c +11 -0
@@ -48,6 +48,7 @@ static char _cmd_name[30] = "";static char _msg_prefix[30 ] =" " ;static int _already_logging =0 ;static int _mirror_in_sync =0 ; +static int _mirror_force_sync =0 ;static int _dmeventd_register =DEFAULT_DMEVENTD_MONITOR ;static lvm2_log_fn_t _lvm2_log_fn =NULL ;
@@ -189,6 +190,11 @@ void init_mirror_in_sync(int in_sync) _mirror_in_sync = in_sync; } +void init_mirror_force_sync (int force_sync) +{ + _mirror_force_sync = force_sync; +} +void init_dmeventd_register (int reg) { _dmeventd_register = reg;
@@ -268,6 +274,11 @@ int mirror_in_sync(void)return _mirror_in_sync; } +int mirror_force_sync (void ) +{ +return _mirror_force_sync; +} +int dmeventd_register_mode (void ) {return _dmeventd_register;
lib/log/log.h +2 -0
@@ -75,6 +75,7 @@ void init_ignorelockingfailure(int levelvoid init_lockingfailed (int level);void init_security_level (int level);void init_mirror_in_sync (int in_sync); +void init_mirror_force_sync (int force_sync);void init_dmeventd_register (int reg);void set_cmd_name (const char *cmd_name);
@@ -90,6 +91,7 @@ int ignorelockingfailure(void);int lockingfailed (void );int security_level (void );int mirror_in_sync (void ); +int mirror_force_sync (void );int dmeventd_register_mode (void );/* Suppress messages to stdout/stderr (1) or everywhere (2) */
lib/mirror/mirrored.c +3 -1
@@ -255,7 +255,9 @@ static int _add_log(struct dev_manager * log_flags |=DM_CORELOG ; } -if (mirror_in_sync () && !(seg->status &PVMOVE )) +if (mirror_force_sync ()) + log_flags |=DM_FORCESYNC ; +else if (mirror_in_sync () && !(seg->status &PVMOVE )) log_flags |=DM_NOSYNC ;if (_block_on_error_available && !(seg->status &PVMOVE ))
tools/args.h +1 -0
@@ -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
@@ -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 +64 -2
85 lines not on this page · raw message