xfs: convert tests to SPDX license tags
[xfstests-dev.git] / tests / xfs / 201
1 #! /bin/bash
2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2009 Christoph Hellwig.
4 #
5 # FS QA Test No. 201
6 #
7 # Test out the infamous xfs_btree_delrec corruption.
8 #
9 # Only happens on 32-bit kernels without CONFIG_LBD, but it should be harmless
10 # to run this everywhere.
11 #
12 seq=`basename $0`
13 seqres=$RESULT_DIR/$seq
14 echo "QA output created by $seq"
15
16 here=`pwd`
17 tmp=/tmp/$$
18 status=1        # failure is the default!
19
20 _cleanup()
21 {
22         _scratch_unmount
23 }
24 trap "_cleanup; exit \$status" 0 1 2 3 15
25
26 # get standard environment, filters and checks
27 . ./common/rc
28 . ./common/filter
29
30 # real QA test starts here
31 _supported_fs xfs
32 _supported_os Linux
33
34 file=$SCRATCH_MNT/f
35
36 min_align=`_min_dio_alignment $SCRATCH_DEV`
37
38 do_pwrite()
39 {
40         offset=`expr $1 \* $min_align`
41         end=`expr $2 \* $min_align`
42         length=`expr $end - $offset`
43
44         $XFS_IO_PROG -d -f $file -c "pwrite $offset $length" >/dev/null
45 }
46
47 _require_scratch
48
49 _scratch_mkfs_xfs >/dev/null 2>&1
50 _scratch_mount
51
52 # Create a fragmented file
53 do_pwrite 30792 31039
54 do_pwrite 30320 30791
55 do_pwrite 29688 30319
56 do_pwrite 29536 29687
57 do_pwrite 27216 29535
58 do_pwrite 24368 27215
59 do_pwrite 21616 24367
60 do_pwrite 20608 21615
61 do_pwrite 19680 20607
62 do_pwrite 19232 19679
63 do_pwrite 17840 19231
64 do_pwrite 16928 17839
65 do_pwrite 15168 16927
66 do_pwrite 14048 15167
67 do_pwrite 12152 14047
68 do_pwrite 11344 12151
69 do_pwrite 8792 11343
70 do_pwrite 6456 8791
71 do_pwrite 5000 6455
72 do_pwrite 1728 4999
73 do_pwrite 0 1727
74
75 sync
76 sync
77
78 # and truncate it again
79 > $SCRATCH_MNT/bigfile
80
81 # success, all done
82 echo "*** done"
83 rm -f $seqres.full
84 status=0