1#!/bin/bash
2
3# Each CPU reads every block off a block device...twice.
4
5# Copyright (C) 2003-2006 IBM
6#
7# This program is free software; you can redistribute it and/or
8# modify it under the terms of the GNU General Public License as
9# published by the Free Software Foundation; either version 2 of the
10# License, or (at your option) any later version.
11#
12# This program is distributed in the hope that it will be useful, but
13# WITHOUT ANY WARRANTY; without even the implied warranty of
14# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15# General Public License for more details.
16#
17# You should have received a copy of the GNU General Public License
18# along with this program; if not, write to the Free Software
19# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
20# 02111-1307, USA.
21
22
23BLKDEVS=$(cat /proc/partitions | grep [sh]d.[0-9] | awk '{if ($3 > 10000)  print $4}')
24WORK=$((NR_CPUS * 2))
25
26echo "Running dd's on these devices:"
27echo "$BLKDEVS"
28echo "using $WORK dd's per device."
29
30# Did we see any failures?
31LOGFILE=/proc/$$/fd/1
32OLD_ERRORS=`egrep -ic "(error|fail|invalid|denied|cannot)" $LOGFILE`
33
34for ((k=1; k < $WORK; k++))
35do
36for i in $BLKDEVS
37	do
38		dd if=/dev/$i of=/dev/null bs=2k > /dev/null &
39	done
40done
41
42# Wait for children
43wait
44
45# Did we see any failures?
46NEW_ERRORS=`egrep -ic "(error|fail|invalid|denied|cannot)" $LOGFILE`
47ERRORS=$(( NEW_ERRORS - OLD_ERRORS ))
48if [ $ERRORS -eq 255 ]; then
49	ERRORS=254
50fi
51exit $ERRORS
52