summaryrefslogtreecommitdiff
path: root/tests/perf/block/qcow2/convert-blockstatus
blob: a1a3c1ef43857c49be0fca18791743f6509bbba6 (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
#!/bin/bash
#
# Test lseek influence on qcow2 block-status
#
# Block layer may recursively check block_status in file child of qcow2, if
# qcow2 driver returned DATA. There are several test cases to check influence
# of lseek on block_status performance. To see real difference run on tmpfs.
#
# Copyright (c) 2019 Virtuozzo International GmbH. All rights reserved.
#
# Tests originally written by Kevin Wolf
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
#

if [ "$#" -lt 1 ]; then
    echo "Usage: $0 SOURCE_FILE"
    exit 1
fi

ROOT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )/../../../.." >/dev/null 2>&1 && pwd )"
QEMU_IMG="$ROOT_DIR/qemu-img"
QEMU_IO="$ROOT_DIR/qemu-io"

size=1G
src="$1"

# test-case plain

(
$QEMU_IMG create -f qcow2 "$src" $size
for i in $(seq 16384 -1 0); do
    echo "write $((i * 65536)) 64k"
done | $QEMU_IO "$src"
) > /dev/null

echo -n "plain: "
/usr/bin/time -f %e $QEMU_IMG convert -n "$src" null-co://

# test-case forward

(
$QEMU_IMG create -f qcow2 "$src" $size
for i in $(seq 0 2 16384); do
    echo "write $((i * 65536)) 64k"
done | $QEMU_IO "$src"
for i in $(seq 1 2 16384); do
    echo "write $((i * 65536)) 64k"
done | $QEMU_IO "$src"
) > /dev/null

echo -n "forward: "
/usr/bin/time -f %e $QEMU_IMG convert -n "$src" null-co://

# test-case prealloc

$QEMU_IMG create -f qcow2 -o preallocation=metadata "$src" $size > /dev/null

echo -n "prealloc: "
/usr/bin/time -f %e $QEMU_IMG convert -n "$src" null-co://