blob: 629cb55b2e736c3d3c3b60624377302321b5d2b1 (
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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
|
#! /bin/bash
# SPDX-License-Identifier: GPL-2.0
# Copyright (c) 2011 Oracle Inc. All Rights Reserved.
#
# FS QA Test No. 286
#
# SEEK_DATA/SEEK_HOLE copy tests.
#
. ./common/preamble
_begin_fstest auto quick other seek prealloc
# Import common functions.
. ./common/filter
# real QA test starts here
_supported_fs generic
_require_test
_require_xfs_io_command "falloc"
_require_seek_data_hole
src=$TEST_DIR/seek_copy_testfile
dest=$TEST_DIR/seek_copy_testfile.dest
_require_test_program "seek_copy_test"
# Override the default cleanup function.
_cleanup()
{
rm -f $src $dest
}
# seek_copy_test_01: tests file with holes and written data extents.
# verify results:
# 1. file size is identical.
# 2. perform cmp(1) to compare SRC and DEST file byte by byte.
test01()
{
rm -f $src $dest
write_cmd="-c \"truncate 100m\""
for i in $(seq 0 5 100); do
offset=$(($i * $((1 << 20))))
write_cmd="$write_cmd -c \"pwrite $offset 1m\""
done
echo "*** test01() create sparse file ***" >>$seqres.full
eval ${XFS_IO_PROG} -f "${write_cmd}" $src >>$seqres.full 2>&1 ||
_fail "create sparse file failed!"
echo "*** test01() create sparse file done ***" >>$seqres.full
echo >>$seqres.full
$here/src/seek_copy_test $src $dest
test $(_get_filesize $src) = $(_get_filesize $dest) ||
_fail "TEST01: file size check failed"
cmp $src $dest || _fail "TEST01: file bytes check failed"
}
# seek_copy_test_02 - tests file with holes, written and unwritten extents.
# verify results:
# 1. file size is identical.
# 2. perform cmp(1) to compare SRC and DEST file byte by byte.
test02()
{
rm -rf $src $dest
write_cmd="-c \"truncate 200m\""
for i in $(seq 0 10 100); do
offset=$(($((6 << 20)) + $i * $((1 << 20))))
write_cmd="$write_cmd -c \"falloc $offset 3m\" -c \"pwrite $offset 1m\""
done
echo "*** test02() create sparse file ***" >>$seqres.full
eval ${XFS_IO_PROG} -f "${write_cmd}" $src >>$seqres.full 2>&1 ||
_fail "create sparse file failed!"
echo "*** test02() create sparse file done ***" >>$seqres.full
echo >>$seqres.full
$here/src/seek_copy_test $src $dest
test $(_get_filesize $src) = $(_get_filesize $dest) ||
_fail "TEST02: file size check failed"
cmp $src $dest || _fail "TEST02: file bytes check failed"
}
# seek_copy_test_03 - tests file with unwritten with data, repeated unwritten
# without data, as well as data extents mapping.
# verify results:
# 1. file size is identical.
# 2. perform cmp(1) to compare SRC and DEST file byte by byte.
test03()
{
rm -rf $src $dest
write_cmd="-c \"truncate 200m\""
#
# Firstly, make the file with allocated && reserved extents
# mapping without real data wrote.
#
for i in $(seq 0 10 180); do
offset=$(($((10 << 20)) + $i * $((1 << 20))))
write_cmd="$write_cmd -c \"falloc $offset 10m\""
done
#
# Secondly, write data to some unwritten extents, hence we
# have a test file will extents mapping as:
# |data|multiple unwritten_without_data|data| repeat...
for i in $(seq 0 60 180); do
offset=$(($((20 << 20)) + $i * $((1 << 20))))
write_cmd="$write_cmd -c \"pwrite $offset 10m\""
done
echo "*** test03() create sparse file ***" >>$seqres.full
eval ${XFS_IO_PROG} -f "${write_cmd}" $src >>$seqres.full 2>&1 ||
_fail "create sparse file failed!"
echo "*** test03() create sparse file done ***" >>$seqres.full
echo >>$seqres.full
$here/src/seek_copy_test $src $dest
test $(_get_filesize $src) = $(_get_filesize $dest) ||
_fail "TEST03: file size check failed"
cmp $src $dest || _fail "TEST03: file bytes check failed"
}
# seek_copy_test_04 - tests file with hole, repeated unwritten
# without data, as well as data extents mapping.
# verify results:
# 1. file size is identical.
# 2. perform cmp(1) to compare SRC and DEST file byte by byte.
test04()
{
rm -rf $src $dest
write_cmd="-c \"truncate 200m\""
#
# Firstly, make the file with allocated && reserved extents
# mapping without real data wrote.
#
for i in $(seq 30 30 180); do
offset=$(($((30 << 20)) + $i * $((1 << 20))))
write_cmd="$write_cmd -c \"falloc $offset 5m\""
done
#
# Secondly, write data to some unwritten extents, hence we
# have a test file will extents mapping as:
# |hole|multiple unwritten_without_data|hole|data| repeat...
for i in $(seq 30 90 180); do
offset=$(($((30 << 20)) + $i * $((1 << 20))))
write_cmd="$write_cmd -c \"pwrite $offset 2m\""
done
echo "*** test04() create sparse file ***" >>$seqres.full
eval ${XFS_IO_PROG} -f "${write_cmd}" $src >>$seqres.full 2>&1 ||
_fail "create sparse file failed!"
echo "*** test04() create sparse file done ***" >>$seqres.full
echo >>$seqres.full
$here/src/seek_copy_test $src $dest
test $(_get_filesize $src) = $(_get_filesize $dest) ||
_fail "TEST04: file size check failed"
cmp $src $dest || _fail "TEST04: file bytes check failed"
}
test01
test02
test03
test04
status=0
exit
|