#!/bin/bash ramdev=$1 nvmedev=$2 MOUNT_OPT="" test_size=40G function run_fio() { local rw=read local sync=$1 local bs=$2 local iodepth=$3 local numjobs=$4 local overwrite=$5 local name=1 local size=$6 fio -directory=/mnt -direct=0 -iodepth=$iodepth -fsync=$sync -rw=$rw \ -numjobs=${numjobs} -bs=${bs} -ioengine=psync -size=$size \ -runtime=60 -norandommap=0 -fallocate=none -overwrite=$overwrite \ -group_reportin -name=$name --output=/tmp/log cat /tmp/log >> /tmp/fio_result } function init_env() { local hole=$1 local size=$2 local dev=$3 rm -rf /mnt/* if [[ "$hole" == "1" ]]; then truncate -s $size /mnt/1.0.0 else xfs_io -f -c "pwrite 0 $size" /mnt/1.0.0 fi umount /mnt mount -o $MOUNT_OPT $dev /mnt } function reset_env() { local dev=$1 umount /mnt mount -o $MOUNT_OPT $dev /mnt } function do_one_test() { local sync=0 local hole=$1 local size=$2 local dev=$3 echo "-------------------" | tee -a /tmp/fio_result echo "=== 4K:" | tee -a /tmp/fio_result reset_env $dev run_fio $sync 4k 1 1 0 $size echo "=== 64K:" | tee -a /tmp/fio_result reset_env $dev run_fio $sync 64k 1 1 0 $size echo "=== 1M:" | tee -a /tmp/fio_result reset_env $dev run_fio $sync 1M 1 1 0 $size echo "-------------------" | tee -a /tmp/fio_result } function run_one_round() { local hole=$1 local size=$2 local dev=$3 init_env $hole $size $dev do_one_test $hole $size $dev } function run_test() { echo "---- TEST RAMDEV ----" | tee -a /tmp/fio_result mount -o $MOUNT_OPT $ramdev /mnt echo "----- 1. READ HOLE" | tee -a /tmp/fio_result run_one_round 1 $test_size $ramdev echo "----- 2. READ RAM DATA" | tee -a /tmp/fio_result run_one_round 0 $test_size $ramdev umount /mnt echo "---- TEST NVMEDEV ----" | tee -a /tmp/fio_result echo "----- 3. READ NVME DATA" | tee -a /tmp/fio_result mount -o $MOUNT_OPT $nvmedev /mnt run_one_round 0 $test_size $nvmedev umount /mnt } if [ -z "$ramdev" ] || [ -z "$nvmedev" ]; then echo "$0 " exit fi umount /mnt mkfs.ext4 -E lazy_itable_init=0,lazy_journal_init=0 -F $ramdev mkfs.ext4 -E lazy_itable_init=0,lazy_journal_init=0 -F $nvmedev cp /tmp/fio_result /tmp/fio_result.old rm -f /tmp/fio_result ## TEST base ramdev echo "==== TEST BASE ====" | tee -a /tmp/fio_result MOUNT_OPT="nobuffered_iomap" run_test ## TEST iomap ramdev echo "==== TEST IOMAP ====" | tee -a /tmp/fio_result MOUNT_OPT="buffered_iomap" run_test