martin f. krafft: Add I/O rescheduling functionality to the checkarray

Martin F. Krafft madduck at alioth.debian.org
Sun Aug 29 11:55:19 UTC 2010


Module: mdadm
Branch: master
Commit: 7218996601f029954470ef84a3aad7c836a08887
URL:    http://git.debian.org/?p=pkg-mdadm/mdadm.git;a=commit;h=7218996601f029954470ef84a3aad7c836a08887

Author: martin f. krafft <madduck at debian.org>
Date:   Sun Aug 29 13:53:20 2010 +0200

Add I/O rescheduling functionality to the checkarray

Also makes the cronjob use --idle by default so to minimise the impact
of the monthly checks on the running system.

---

 debian/changelog    |    5 ++++-
 debian/checkarray   |   41 +++++++++++++++++++++++++++++++++++------
 debian/mdadm.cron.d |    2 +-
 3 files changed, 40 insertions(+), 8 deletions(-)

diff --git a/debian/changelog b/debian/changelog
index 7a82038..20528ff 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -6,8 +6,11 @@ mdadm (3.1.3-1) unstable; urgency=low
     arrays not listed in mdadm.conf; thanks to Mario 'BitKoenig' Holbe for the
     patch (closes: #583545).
   * Fix URL in the bug reporting preamble (presubj) (closes: #589833).
+  * Add I/O rescheduling functionality to the checkarray script and make the
+    cronjob use the idle priority; this should now minimise the impact of the
+    monthly re-check on the running system (closes: #592149, #508123).
 
- -- martin f. krafft <madduck at debian.org>  Fri, 28 May 2010 13:17:27 +0200
+ -- martin f. krafft <madduck at debian.org>  Sun, 29 Aug 2010 13:44:59 +0200
 
 mdadm (3.1.2-2) unstable; urgency=low
 
diff --git a/debian/checkarray b/debian/checkarray
index 0012e10..e0b977d 100644
--- a/debian/checkarray
+++ b/debian/checkarray
@@ -25,9 +25,13 @@ usage()
   echo "Valid options are:"
   cat <<-_eof | column -s\& -t
 	-a|--all & check all assembled arrays (check /proc/mdstat).
-	-c|--cron & honour AUTOCHECK setting in /etc/default/mdadm.
 	-s|--status & print redundancy check status of devices.
 	-x|--cancel & queue a request to cancel a running redundancy check.
+	-i|--idle & perform check in a lowest I/O scheduling class (idle).
+	-l|--slow & perform check in a lower-than-standard I/O scheduling class.
+	-f|--fast & perform check in higher-than-standard I/O scheduling class.
+	--realtime & perform check in real-time I/O scheduling class (DANGEROUS!).
+	-c|--cron & honour AUTOCHECK setting in /etc/default/mdadm.
 	-q|--quiet & suppress informational messages.
 	-Q|--real-quiet & suppress all output messages, including warnings and errors.
 	-h|--help & show this output.
@@ -35,7 +39,7 @@ usage()
 	_eof
   echo
   echo "Examples:"
-  echo "  $PROGNAME --all"
+  echo "  $PROGNAME --all --idle"
   echo "  $PROGNAME --quiet /dev/md[123]"
   echo "  $PROGNAME -sa"
   echo "  $PROGNAME -x --all"
@@ -49,8 +53,8 @@ usage()
   echo "You can also control the status of a check with /proc/mdstat ."
 }
 
-SHORTOPTS=achVqQsx
-LONGOPTS=all,cron,help,version,quiet,real-quiet,status,cancel
+SHORTOPTS=achVqQsxif
+LONGOPTS=all,cron,help,version,quiet,real-quiet,status,cancel,idle,fast,realtime
 
 eval set -- $(getopt -o $SHORTOPTS -l $LONGOPTS -n $PROGNAME -- "$@")
 
@@ -60,16 +64,21 @@ all=0
 quiet=0
 status=0
 action=check
+ionice=
 
 for opt in $@; do
   case "$opt" in
     -a|--all) all=1;;
-    -c|--cron) cron=1;;
     -s|--status) action=status;;
     -x|--cancel) action=idle;;
-    -h|--help) usage; exit 0;;
+    -i|--idle) ionice=idle;;
+    -l|--slow) ionice=low;;
+    -f|--fast) ionice=high;;
+    --realtime) ionice=realtime;;
+    -c|--cron) cron=1;;
     -q|--quiet) quiet=1;;
     -Q|--real-quiet) quiet=2;;
+    -h|--help) usage; exit 0;;
     -V|--version) about; exit 0;;
     /dev/md/*|md/*) arrays="${arrays:+$arrays }md${opt#*md/}";;
     /dev/md*|md*) arrays="${arrays:+$arrays }${opt#/dev/}";;
@@ -170,6 +179,26 @@ for array in $arrays; do
       # are properly queued so as to not kill one of the array.
       echo $action > $SYNC_ACTION_CTL
       [ $quiet -lt 1 ] && echo "$PROGNAME: I: check queued for array $array." >&2
+
+      case "$ionice" in
+        idle) arg='-c3';;
+        low) arg='-c2 -n7';;
+        high) arg='-c2 -n0';;
+        realtime) arg='-c1 -n4';;
+        *) break;;
+      esac
+
+      resync_pid= wait=5
+      while [ $wait -gt 0 ]; do
+        wait=$((wait - 1))
+        resync_pid=$(ps -ef | awk -v dev=$array 'BEGIN { pattern = "^\\[" dev "_resync]$" } $8 ~ pattern { print $2 }')
+        if [ -n "$resync_pid" ]; then
+          echo "$PROGNAME: I: selecting $ionice I/O schedulung class for resync of $array." >&2
+          ionice -t -p "$resync_pid" $arg
+          break
+        fi
+        sleep 1
+      done
       ;;
   esac
 
diff --git a/debian/mdadm.cron.d b/debian/mdadm.cron.d
index 7a167cf..309d180 100644
--- a/debian/mdadm.cron.d
+++ b/debian/mdadm.cron.d
@@ -9,4 +9,4 @@
 # the month is less than or equal to 7. Thus, only run on the first Sunday of
 # each month. crontab(5) sucks, unfortunately, in this regard; therefore this
 # hack (see #380425).
-57 0 * * 0 root if [ -x /usr/share/mdadm/checkarray ] && [ $(date +\%d) -le 7 ]; then /usr/share/mdadm/checkarray --cron --all --quiet; fi
+57 0 * * 0 root if [ -x /usr/share/mdadm/checkarray ] && [ $(date +\%d) -le 7 ]; then /usr/share/mdadm/checkarray --cron --all --idle --quiet; fi




More information about the pkg-mdadm-commits mailing list