diff --git a/scripts/blockdev-perftest b/scripts/blockdev-perftest index 1625ae4aa..40e9402e7 100755 --- a/scripts/blockdev-perftest +++ b/scripts/blockdev-perftest @@ -27,17 +27,20 @@ ######################### function usage { - echo "Usage: $0 [-a] [-d] [-n] [-s ] " + echo "Usage: $0 [-a] [-d] [-n] [-r] [-s ] " echo " -a - use asynchronous (buffered) I/O." echo " -d - use direct (non-buffered) I/O." echo " -n - do not verify the data on before overwriting it." + echo " -r - only perform the read test." echo " -s - logarithm base two of the I/O size." echo " - block device to run the I/O performance test on." } function drop_caches { sync - echo 3 > /proc/sys/vm/drop_caches + if [ -w /proc/sys/vm/drop_caches ]; then + echo 3 > /proc/sys/vm/drop_caches + fi } @@ -46,9 +49,10 @@ function drop_caches { ######################### log2_io_size=30 # 1 GB -log2_min_blocksize=12 # 4096 bytes +log2_min_blocksize=9 # 512 bytes log2_max_blocksize=26 # 64 MB iotype=direct +read_test_only=false verify_device_data=true @@ -56,13 +60,14 @@ verify_device_data=true # Argument processing # ######################### -set -- $(/usr/bin/getopt "adns:" "$@") +set -- $(/usr/bin/getopt "adnrs:" "$@") while [ "$1" != "${1#-}" ] do case "$1" in '-a') iotype="buffered"; shift;; '-d') iotype="direct"; shift;; '-n') verify_device_data="false"; shift;; + '-r') read_test_only="true"; shift;; '-s') log2_io_size="$2"; shift; shift;; '--') shift;; *) usage; exit 1;; @@ -86,12 +91,12 @@ if [ ! -e "${device}" ]; then exit 1 fi -if [ ! -w "${device}" ]; then +if [ "${read_test_only}" = "false" -a ! -w "${device}" ]; then echo "Error: device ${device} is not writeable." exit 1 fi -if [ "${verify_device_data}" = "true" ] \ +if [ "${read_test_only}" = "false" -a "${verify_device_data}" = "true" ] \ && ! cmp -s -n $((2**log2_io_size)) "${device}" /dev/zero then echo "Error: device ${device} still contains data." @@ -120,10 +125,14 @@ do printf "%9d " ${bs} for ((i=0;i<3;i++)) do - drop_caches - elapsed="$(dd if=/dev/zero of="${device}" bs=${bs} count=${count} \ - ${dd_oflags} 2>&1 \ - | sed -n 's/.* \([0-9.]*\) s,.*/\1/p')" + if [ "${read_test_only}" = "false" ]; then + drop_caches + elapsed="$(dd if=/dev/zero of="${device}" bs=${bs} count=${count} \ + ${dd_oflags} 2>&1 \ + | sed -n 's/.* \([0-9.]*\) s,.*/\1/p')" + else + elapsed=-1 + fi printf "%8s " "${elapsed}" done for ((i=0;i<3;i++))