summaryrefslogtreecommitdiff
path: root/tests/xfs/201
blob: b9f2aab1a71372d10e34893b4e7b220ef37f73eb (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
#! /bin/bash
# SPDX-License-Identifier: GPL-2.0
# Copyright (c) 2009 Christoph Hellwig.
#
# FS QA Test No. 201
#
# Test out the infamous xfs_btree_delrec corruption.
#
# Only happens on 32-bit kernels without CONFIG_LBD, but it should be harmless
# to run this everywhere.
#
. ./common/preamble
_begin_fstest metadata auto quick

# Override the default cleanup function.
_cleanup()
{
	_scratch_unmount
}

# Import common functions.
. ./common/filter

# real QA test starts here
_supported_fs xfs

file=$SCRATCH_MNT/f

min_align=`_min_dio_alignment $SCRATCH_DEV`

do_pwrite()
{
	offset=`expr $1 \* $min_align`
	end=`expr $2 \* $min_align`
	length=`expr $end - $offset`

	$XFS_IO_PROG -d -f $file -c "pwrite $offset $length" >/dev/null
}

_require_scratch

_scratch_mkfs_xfs >/dev/null 2>&1
_scratch_mount

# Create a fragmented file
do_pwrite 30792 31039
do_pwrite 30320 30791
do_pwrite 29688 30319
do_pwrite 29536 29687
do_pwrite 27216 29535
do_pwrite 24368 27215
do_pwrite 21616 24367
do_pwrite 20608 21615
do_pwrite 19680 20607
do_pwrite 19232 19679
do_pwrite 17840 19231
do_pwrite 16928 17839
do_pwrite 15168 16927
do_pwrite 14048 15167
do_pwrite 12152 14047
do_pwrite 11344 12151
do_pwrite 8792 11343
do_pwrite 6456 8791
do_pwrite 5000 6455
do_pwrite 1728 4999
do_pwrite 0 1727

sync
sync

# and truncate it again
> $SCRATCH_MNT/bigfile

# success, all done
echo "*** done"
status=0