On Mon, Jan 31, 2011 at 02:05:04PM +0100, martin f krafft wrote: > tags 611627 confirmed > thanks > > also sprach Mario 'BitKoenig' Holbe <[email protected]> > [2011.01.31.1341 +0100]: > > checkarray terminates after issuing check to first RAID if no scheduling > > class is given: > > This is due to the break in checkarray:188: > Indeed. Can you please verify that changing s/break/continue in both > lines 188 and 200 fixes the problem?
Changing the break in line 188 to continue fixes the problem.
Changing the break in line 200 is wrong:
break (without a level) exits from the inner loop, which is the loop to
wait for a resync pid here. Hence, changing this in the best case leads
to ionice being called over and over again (up to 5 times) on the same
process:
# /tmp/checkarray --cron --all --idle --quiet
checkarray: I: selecting idle I/O scheduling class for resync of md0.
checkarray: I: selecting idle I/O scheduling class for resync of md0.
checkarray: I: selecting idle I/O scheduling class for resync of md0.
checkarray: I: selecting idle I/O scheduling class for resync of md1.
checkarray: I: selecting idle I/O scheduling class for resync of md1.
...
In the worst case, the resync process terminates within these 5 seconds
and checkarray terminates due to failing ionice (and set -e):
# /tmp/checkarray --cron --all --idle --quiet
checkarray: I: selecting idle I/O scheduling class for resync of md0.
checkarray: I: selecting idle I/O scheduling class for resync of md0.
checkarray: I: selecting idle I/O scheduling class for resync of md0.
ionice: ioprio_set failed: No such process
#
This, btw., indicates a race condition anyways.
It would probably make sense to guard the ionice call:
ionice -p "$resync_pid" $arg || true
And while we are at changing the script anyways...
Could you please consider quieting the "selecting I/O scheduling class"
message? This would prevent the cron job from sending a mail each month.
I'm attaching a diff that does all of the above - and I tested the
resulting script :)
regards
Mario
--
Ho ho ho! I am Santa Claus of Borg. Nice assimilation all together!
--- /usr/share/mdadm/checkarray 2010-09-03 11:11:00.000000000 +0200
+++ /tmp/checkarray 2011-01-31 14:30:41.076379703 +0100
@@ -185,7 +185,7 @@
low) arg='-c2 -n7';;
high) arg='-c2 -n0';;
realtime) arg='-c1 -n4';;
- *) break;;
+ *) continue;;
esac
resync_pid= wait=5
@@ -193,8 +193,8 @@
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 scheduling class for resync of $array." >&2
- ionice -p "$resync_pid" $arg
+ [ $quiet -lt 1 ] && echo "$PROGNAME: I: selecting $ionice I/O scheduling class for resync of $array." >&2
+ ionice -p "$resync_pid" $arg || true
break
fi
sleep 1
signature.asc
Description: Digital signature

