master
text 71 lines 2 KB
Raw
1 #!/bin/bash
2 #
3 # Test lseek influence on qcow2 block-status
4 #
5 # Block layer may recursively check block_status in file child of qcow2, if
6 # qcow2 driver returned DATA. There are several test cases to check influence
7 # of lseek on block_status performance. To see real difference run on tmpfs.
8 #
9 # Copyright (c) 2019 Virtuozzo International GmbH. All rights reserved.
10 #
11 # Tests originally written by Kevin Wolf
12 #
13 # This program is free software; you can redistribute it and/or modify
14 # it under the terms of the GNU General Public License as published by
15 # the Free Software Foundation; either version 2 of the License, or
16 # (at your option) any later version.
17 #
18 # This program is distributed in the hope that it will be useful,
19 # but WITHOUT ANY WARRANTY; without even the implied warranty of
20 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 # GNU General Public License for more details.
22 #
23 # You should have received a copy of the GNU General Public License
24 # along with this program. If not, see <http://www.gnu.org/licenses/>.
25 #
26
27 if [ "$#" -lt 1 ]; then
28 echo "Usage: $0 SOURCE_FILE"
29 exit 1
30 fi
31
32 ROOT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )/../../../.." >/dev/null 2>&1 && pwd )"
33 QEMU_IMG="$ROOT_DIR/qemu-img"
34 QEMU_IO="$ROOT_DIR/qemu-io"
35
36 size=1G
37 src="$1"
38
39 # test-case plain
40
41 (
42 $QEMU_IMG create -f qcow2 "$src" $size
43 for i in $(seq 16384 -1 0); do
44 echo "write $((i * 65536)) 64k"
45 done | $QEMU_IO "$src"
46 ) > /dev/null
47
48 echo -n "plain: "
49 /usr/bin/time -f %e $QEMU_IMG convert -n "$src" null-co://
50
51 # test-case forward
52
53 (
54 $QEMU_IMG create -f qcow2 "$src" $size
55 for i in $(seq 0 2 16384); do
56 echo "write $((i * 65536)) 64k"
57 done | $QEMU_IO "$src"
58 for i in $(seq 1 2 16384); do
59 echo "write $((i * 65536)) 64k"
60 done | $QEMU_IO "$src"
61 ) > /dev/null
62
63 echo -n "forward: "
64 /usr/bin/time -f %e $QEMU_IMG convert -n "$src" null-co://
65
66 # test-case prealloc
67
68 $QEMU_IMG create -f qcow2 -o preallocation=metadata "$src" $size > /dev/null
69
70 echo -n "prealloc: "
71 /usr/bin/time -f %e $QEMU_IMG convert -n "$src" null-co://