Add support for 'repair' action to checkarray. (Closes: #772465)
Enables the use of the repair action in the cron checkarray script.
The 'repair' mode must be enabled manually in order to take effect, so deployed
systems continue to operate under the lower risk of the 'check' mode.
Authorship of this commit was acknowledged in Git. Thank you to Henrique de
Moraes Holschuh!
Henrique de Moraes Holschuh authored 2 years ago
Felix Lechner committed 2 years ago
26 | 26 | -a|--all check all assembled arrays (ignores arrays in command line). |
27 | 27 | -s|--status print redundancy check status of devices. |
28 | 28 | -x|--cancel queue a request to cancel a running redundancy check. |
29 | -r|--repair repair instead of check | |
29 | 30 | -i|--idle perform check in a lowest scheduling class (idle) |
30 | 31 | -l|--slow perform check in a lower-than-standard scheduling class |
31 | 32 | -f|--fast perform check in higher-than-standard scheduling class |
45 | 46 | Devices can be specified in almost any format. The following are equivalent: |
46 | 47 | /dev/md0, md0, /dev/md/0, /sys/block/md0 |
47 | 48 | |
48 | You can also control the status of a check with /proc/mdstat file." | |
49 | You can also control the status of a check/repair with /proc/mdstat file." | |
49 | 50 | } |
50 | 51 | |
51 | SHORTOPTS=achVqQsxilf | |
52 | LONGOPTS=all,cron,help,version,quiet,real-quiet,status,cancel,idle,slow,fast,realtime | |
52 | SHORTOPTS=achVqQsxrilf | |
53 | LONGOPTS=all,cron,help,version,quiet,real-quiet,status,cancel,repair,idle,slow,fast,realtime | |
53 | 54 | |
54 | 55 | eval set -- $(getopt -o $SHORTOPTS -l $LONGOPTS -n $PROGNAME -- "$@") |
55 | 56 | |
66 | 67 | -a|--all) all=1;; |
67 | 68 | -s|--status) action=status;; |
68 | 69 | -x|--cancel) action=idle;; |
70 | -r|--repair) action=repair;; | |
69 | 71 | -i|--idle) ionice=idle;; |
70 | 72 | -l|--slow) ionice=low;; |
71 | 73 | -f|--fast) ionice=high;; |
164 | 166 | [ $quiet -lt 1 ] && echo "$PROGNAME: I: cancel request queued for array $array." >&2 |
165 | 167 | ;; |
166 | 168 | |
167 | check) | |
169 | check|repair) | |
168 | 170 | if [ "$cur_status" != idle ]; then |
169 | 171 | [ $quiet -lt 2 ] && echo "$PROGNAME: W: array $array not idle, skipping..." >&2 |
170 | 172 | continue |
186 | 188 | fi |
187 | 189 | |
188 | 190 | # queue request for the array. The kernel will make sure that these requests |
189 | # are properly queued so as to not kill one of the array. | |
191 | # are properly queued so as to not kill one of the arrays. | |
190 | 192 | echo $action > $MDBASE/sync_action |
191 | [ $quiet -lt 1 ] && echo "$PROGNAME: I: check queued for array $array." >&2 | |
193 | [ $quiet -lt 1 ] && echo "$PROGNAME: I: $action queued for array $array." >&2 | |
192 | 194 | |
193 | 195 | case "$ionice" in |
194 | 196 | idle) ioarg='-c3'; renice=15;; |