blob: d511ee86f46fe739a410b822555613a880d35361 (
plain) (
blame)
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
97
98
99
100
101
102
103
104
105
|
#image="$(realpath "$1")"
image="/home/h4ct1c/git/masterteamprojekt/dnbd3_images/archLinux/archLinux.vdi.r10"
test_directory=/tmp/performance_test
[ ! -z $2 ] && test_directory="$2"
image_directory="$(dirname "$image")"
dnbd3_rootfs_directory="../builder/dnbd3-rootfs"
log_directory="./io_test_logs"
mountpoint_xmount="${test_directory}/mnt_xmount"
mountpoint="${test_directory}/mnt"
source ${dnbd3_rootfs_directory}/scripts/build.sh
if [[ ! -d "$test_directory" ]]; then
mkdir "$test_directory"
mkdir "$mountpoint_xmount"
mkdir "$mountpoint"
mkdir "$log_directory"
build_clean_xmount ${dnbd3_rootfs_directory}/binaries/xmount
build_clean_qemu_xmount ${dnbd3_rootfs_directory}/binaries/qemu-xmount
build_compile_xmount ${dnbd3_rootfs_directory}/binaries/xmount \
"/" "${test_directory}/xmount"
build_compile_qemu_xmount ${dnbd3_rootfs_directory}/binaries/qemu-xmount \
"${test_directory}/xmount"
cp ${dnbd3_rootfs_directory}/binaries/qemu-xmount/libxmount_input_qemu.so \
"${test_directory}/xmount/lib/xmount/"
fi
pushd "$log_directory"
dd_test() {
local device="$1"
size_in_megabyte="$2"
dd if="$device" of=/dev/null \
bs="$size_in_megabyte"M count=1\
iflag=direct \
2>&1 | grep bytes
}
fio_test() {
local device="$1"
shift
local name="$1"
shift
fio --readonly --name=hans --direct=1 --write_bw_log="$name" \
--size=2G --filename="$device" $@
}
test_device() {
local device="$1"
local name="$2"
echo
#echo "-------------- $2 read test (dd)"
#dd_test "$device" 1000
#echo "-------------- $2 read test (fio)"
#fio_test "$device" "$name" --rw=read
echo "-------------- $2 read test (fio random read)"
fio_test "$device" "${name}.rand" --rw=randread
#echo "-------------- $2 read test (fio random read libaio)"
#fio_test "$device" "${name}.rand,libaio" --rw=randread --ioengine=libaio
#echo "-------------- $2 read test (find)"
#mount -o ro "$device"p2 "$mountpoint"
#(time find "$mountpoint" 1>/dev/null) 2>&1 | grep -E 'user|sys'
#umount "$mountpoint"
}
test_qemu() {
# qemu-nbd test (no cache)
modprobe nbd max_part=16
qemu-nbd --connect=/dev/nbd0 --read-only --persistent --nocache "$image"
#ln -s /dev/nbd0 "$image" # device as file (for dnbd3)
test_device "/dev/nbd0" "qemu-nbd (nocache)"
# qemu-nbd teardown
qemu-nbd -d /dev/nbd0 >/dev/null # disconnect
# qemu-nbd test
qemu-nbd --connect=/dev/nbd0 --read-only --persistent "$image"
test_device "/dev/nbd0" "qemu-nbd"
# qemu-nbd teardown
qemu-nbd -d /dev/nbd0 >/dev/null # disconnect
}
test_xmount() {
#xmount test
${test_directory}/xmount/bin/xmount --in qemu "$image" \
--out raw "${mountpoint_xmount}"
loop_device="$(losetup -f)"
losetup "$loop_device" "${mountpoint_xmount}"/*.dd --partscan
test_device "$loop_device" "xmount"
# xmount teardown
losetup -d "$loop_device"
umount "$mountpoint_xmount"
}
test_qemu
test_xmount
chown $(who | awk '{print $1}') *.log
fio2gnuplot -b -g
popd
|