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 23 BLKDEVS=$(cat /proc/partitions | grep [sh]d.[0-9] | awk '{if ($3 > 10000) print $4}') 24 WORK=$((NR_CPUS * 2)) 25 26 echo "Running dd's on these devices:" 27 echo "$BLKDEVS" 28 echo "using $WORK dd's per device." 29 30 # Did we see any failures? 31 LOGFILE=/proc/$$/fd/1 32 OLD_ERRORS=`egrep -ic "(error|fail|invalid|denied|cannot)" $LOGFILE` 33 34 for ((k=1; k < $WORK; k++)) 35 do 36 for i in $BLKDEVS 37 do 38 dd if=/dev/$i of=/dev/null bs=2k > /dev/null & 39 done 40 done 41 42 # Wait for children 43 wait 44 45 # Did we see any failures? 46 NEW_ERRORS=`egrep -ic "(error|fail|invalid|denied|cannot)" $LOGFILE` 47 ERRORS=$(( NEW_ERRORS - OLD_ERRORS )) 48 if [ $ERRORS -eq 255 ]; then 49 ERRORS=254 50 fi 51 exit $ERRORS 52