xfs: Check for extent overflow when trivally adding a new extent
[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
33 file=$SCRATCH_MNT/f
34
35 min_align=`_min_dio_alignment $SCRATCH_DEV`
36
37 do_pwrite()
38 {
39         offset=`expr $1 \* $min_align`
40         end=`expr $2 \* $min_align`
41         length=`expr $end - $offset`
42
43         $XFS_IO_PROG -d -f $file -c "pwrite $offset $length" >/dev/null
44 }
45
46 _require_scratch
47
48 _scratch_mkfs_xfs >/dev/null 2>&1
49 _scratch_mount
50
51 # Create a fragmented file
52 do_pwrite 30792 31039
53 do_pwrite 30320 30791
54 do_pwrite 29688 30319
55 do_pwrite 29536 29687
56 do_pwrite 27216 29535
57 do_pwrite 24368 27215
58 do_pwrite 21616 24367
59 do_pwrite 20608 21615
60 do_pwrite 19680 20607
61 do_pwrite 19232 19679
62 do_pwrite 17840 19231
63 do_pwrite 16928 17839
64 do_pwrite 15168 16927
65 do_pwrite 14048 15167
66 do_pwrite 12152 14047
67 do_pwrite 11344 12151
68 do_pwrite 8792 11343
69 do_pwrite 6456 8791
70 do_pwrite 5000 6455
71 do_pwrite 1728 4999
72 do_pwrite 0 1727
73
74 sync
75 sync
76
77 # and truncate it again
78 > $SCRATCH_MNT/bigfile
79
80 # success, all done
81 echo "*** done"
82 rm -f $seqres.full
83 status=0