summaryrefslogtreecommitdiff
path: root/tests/bcache/reboot_fio_new.ktest
blob: 03164b9afd6d7020e578b82a6b1363d63154c58e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
#!/usr/bin/env bash

. $(dirname $(readlink -e ${BASH_SOURCE[0]}))/bcache-test-libs.sh

config-cache 2G
config-tier 4G
config-bucket-size 32k
config-block-size 4k
config-volume 1600M
config-cpus 1

nr_iterations=$(((ktest_priority + 1) * 8))
config-timeout $((nr_iterations * 30))

# Usage: fio_pass read/write verify
fio_pass()
{
    (
	# Our default working directory (/cdrom) is not writable,
	# fio wants to write files when verify_dump is set, so
	# change to a different directory.
	cd $ktest_out

	for dev in $DEVICES; do
	    fio --eta=always - <<-ZZ &
		[global]
		randrepeat=0
		ioengine=libaio
		iodepth=64
		direct=1

		verify_fatal=1
		verify_dump=1

		filename=$dev

		[foo]
		blocksize_range=4k-128k
		rw=$1
		verify=$2
		ZZ
	done

	wait_all
    )

}

test_main()
{
    setup_tracing 'bcache:*'

    if [ $NR_REBOOTS = 0 ]; then
	setup_bcache
    else
	existing_bcache
    fi

    run_antagonist

    if [ "$NR_REBOOTS" == "$nr_iterations" ]; then
	discard_all_devices
	stop_bcache
    else
	case $((NR_REBOOTS % 2)) in
	    0)
		workload=write
		;;
	    1)
		workload=read
		;;
	esac

	# Change verify type between successive write/read pairs
	# to detect stale data
	case $(((NR_REBOOTS / 2) % 2)) in
	    0)
		verify=crc32c-intel
		;;
	    1)
		verify=meta
		;;
	esac

	fio_pass $workload $verify

	# Unclean vs unclean shutdown
	case $(((NR_REBOOTS / 4) % 2)) in
	    1)
		stop_bcache
		;;
	esac

	do_reboot
    fi
}