Package: mdadm
Version: 3.3.2-2
Severity: wishlist
Tags: patch

Please consider the attached patch, it enables the use of the repair action
in the cron checkarray script.  Manual configuration is required to switch
from the standard check to the new repair mode, so it shouldn't have any
added risk to deployed systems.

-- 
  "One disk to rule them all, One disk to find them. One disk to bring
  them all and in the darkness grind them. In the Land of Redmond
  where the shadows lie." -- The Silicon Valley Tarot
  Henrique Holschuh
--- checkarray	2014-12-07 12:22:21.611713564 -0200
+++ checkarray.repair	2014-12-07 12:22:06.018196634 -0200
@@ -27,6 +27,7 @@
  -a|--all	check all assembled arrays (ignores arrays in command line).
  -s|--status	print redundancy check status of devices.
  -x|--cancel	queue a request to cancel a running redundancy check.
+ -r|--repair	repair instead of check
  -i|--idle	perform check in a lowest scheduling class (idle)
  -l|--slow	perform check in a lower-than-standard scheduling class
  -f|--fast	perform check in higher-than-standard scheduling class
@@ -46,11 +47,11 @@
 Devices can be specified in almost any format. The following are equivalent:
  /dev/md0, md0, /dev/md/0, /sys/block/md0
 
-You can also control the status of a check with /proc/mdstat file."
+You can also control the status of a check/repair with /proc/mdstat file."
 }
 
-SHORTOPTS=achVqQsxilf
-LONGOPTS=all,cron,help,version,quiet,real-quiet,status,cancel,idle,slow,fast,realtime
+SHORTOPTS=achVqQsxrilf
+LONGOPTS=all,cron,help,version,quiet,real-quiet,status,cancel,repair,idle,slow,fast,realtime
 
 eval set -- $(getopt -o $SHORTOPTS -l $LONGOPTS -n $PROGNAME -- "$@")
 
@@ -67,6 +68,7 @@
     -a|--all) all=1;;
     -s|--status) action=status;;
     -x|--cancel) action=idle;;
+    -r|--repair) action=repair;;
     -i|--idle) ionice=idle;;
     -l|--slow) ionice=low;;
     -f|--fast) ionice=high;;
@@ -165,7 +167,7 @@
       [ $quiet -lt 1 ] && echo "$PROGNAME: I: cancel request queued for array $array." >&2
       ;;
 
-    check)
+    check|repair)
       if [ "$cur_status" != idle ]; then
         [ $quiet -lt 2 ] && echo "$PROGNAME: W: array $array not idle, skipping..." >&2
         continue
@@ -187,9 +189,9 @@
       fi
 
       # queue request for the array. The kernel will make sure that these requests
-      # are properly queued so as to not kill one of the array.
+      # are properly queued so as to not kill one of the arrays.
       echo $action > $MDBASE/sync_action
-      [ $quiet -lt 1 ] && echo "$PROGNAME: I: check queued for array $array." >&2
+      [ $quiet -lt 1 ] && echo "$PROGNAME: I: $action queued for array $array." >&2
 
       case "$ionice" in
         idle) ioarg='-c3'; renice=15;;

Reply via email to