#!/bin/bash ramdev=$1 nvmedev=$2 MOUNT_OPT="" test_size=40G function run_fio() { local rw=write 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 dev=$1 rm -rf /mnt/* umount /mnt mount -o $MOUNT_OPT $dev /mnt } function reset_env() { local overwrite=$1 local dev=$2 if [[ "$overwrite" == "0" ]]; then rm -rf /mnt/* fi umount /mnt mount -o $MOUNT_OPT $dev /mnt } function do_one_test() { local sync=$1 local overwrite=$2 local size=$3 local dev=$4 echo "-------------------" | tee -a /tmp/fio_result echo "=== 4K:" | tee -a /tmp/fio_result reset_env $overwrite $dev run_fio $sync 4k 1 1 $overwrite $size echo "=== 64K:" | tee -a /tmp/fio_result reset_env $overwrite $dev run_fio $sync 64k 1 1 $overwrite $size echo "=== 1M:" | tee -a /tmp/fio_result reset_env $overwrite $dev run_fio $sync 1M 1 1 $overwrite $size echo "-------------------" | tee -a /tmp/fio_result } function run_one_round() { local sync=$1 local overwrite=$2 local size=$3 local dev=$4 echo "Sync:$sync, Overwrite:$overwrite" | tee -a /tmp/fio_result init_env $dev do_one_test $sync $overwrite $size $dev } function run_test() { echo "---- TEST RAMDEV ----" | tee -a /tmp/fio_result mount -o $MOUNT_OPT $ramdev /mnt echo "----- 1. WRITE CACHE" | tee -a /tmp/fio_result # Stop writeback echo 0 > /proc/sys/vm/dirty_writeback_centisecs echo 30000 > /proc/sys/vm/dirty_expire_centisecs echo 100 > /proc/sys/vm/dirty_background_ratio echo 100 > /proc/sys/vm/dirty_ratio run_one_round 0 0 $test_size $ramdev run_one_round 0 1 $test_size $ramdev echo "----- 2. WRITE RAM DISK" | tee -a /tmp/fio_result # Restore writeback echo 500 > /proc/sys/vm/dirty_writeback_centisecs echo 3000 > /proc/sys/vm/dirty_expire_centisecs echo 10 > /proc/sys/vm/dirty_background_ratio echo 20 > /proc/sys/vm/dirty_ratio run_one_round 0 0 $test_size $ramdev run_one_round 0 1 $test_size $ramdev run_one_round 1 0 $test_size $ramdev run_one_round 1 1 $test_size $ramdev umount /mnt echo "---- TEST NVMEDEV ----" | tee -a /tmp/fio_result echo "----- 3. WRITE NVME DISK" | tee -a /tmp/fio_result mount -o $MOUNT_OPT $nvmedev /mnt run_one_round 0 0 $test_size $nvmedev run_one_round 0 1 $test_size $nvmedev run_one_round 1 0 $test_size $nvmedev run_one_round 1 1 $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 echo "==== TEST BASE ====" | tee -a /tmp/fio_result MOUNT_OPT="nobuffered_iomap" run_test ## TEST iomap echo "==== TEST IOMAP ====" | tee -a /tmp/fio_result MOUNT_OPT="buffered_iomap" run_test