xfs/004: don't fail test due to realtime files
[xfstests-dev.git] / tests / xfs / 074
1 #! /bin/bash
2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2015 Red Hat, Inc. All Rights Reserved.
4 #
5 # FS QA Test 074-extsz-hints-vs-maxextlen
6 #
7 # Check some extent size hint boundary conditions that can result in
8 # MAXEXTLEN overflows.
9 #
10 # In xfs_bmap_extsize_align(), we had,
11 #       if ((temp = (align_alen % extsz))) {
12 #               align_alen += extsz - temp;
13 #       }
14 # align_alen had the value of 2097151 (i.e. MAXEXTLEN) blocks. extsz had
15 # the value of 4096 blocks.
16 #
17 # align_alen % extsz will be 4095. so align_alen will end up having
18 # 2097151 + (4096 - 4095) = 2097152 i.e. (MAXEXTLEN + 1). Thus the length
19 # of the new extent will be larger than MAXEXTLEN. This will later cause
20 # the bmbt leaf to have an entry whose length is set to zero block count.
21 #
22 seq=`basename $0`
23 seqres=$RESULT_DIR/$seq
24 echo "QA output created by $seq"
25
26 _cleanup()
27 {
28         cd /
29         _destroy_loop_device $LOOP_DEV
30         rm -f $tmp.* $LOOP_FILE
31 }
32
33 here=`pwd`
34 tmp=/tmp/$$
35 status=1        # failure is the default!
36 trap "_cleanup; exit \$status" 0 1 2 3 15
37
38 # get standard environment, filters and checks
39 . ./common/rc
40 . ./common/filter
41
42 # real QA test starts here
43 _supported_fs xfs
44
45 rm -f $seqres.full
46
47 _require_test
48 _require_xfs_io_command "falloc"
49
50 # we use loop devices for this so that we can create large files for prealloc
51 # without having to care about the underlying device size.
52 _require_loop
53
54 LOOP_FILE=$TEST_DIR/$seq.img
55 LOOP_MNT=$TEST_DIR/$seq.mnt
56 mkdir -p $LOOP_MNT
57 $XFS_IO_PROG -ft -c "truncate 1t" $LOOP_FILE >> $seqres.full
58 LOOP_DEV=`_create_loop_device $LOOP_FILE`
59
60 _mkfs_dev -d size=260g,agcount=2 $LOOP_DEV
61 _mount $LOOP_DEV $LOOP_MNT
62
63 BLOCK_SIZE=$(_get_file_block_size $LOOP_MNT)
64
65 # Corrupt the BMBT by creating extents larger than MAXEXTLEN
66 # For 4k blocksize, MAXEXTLEN * 4k = 2097151 * 4k = 8589930496 = ~8GiB
67 $XFS_IO_PROG -ft \
68         -c "extsize $(($BLOCK_SIZE * 4096))" \
69         -c "falloc 0 $(($BLOCK_SIZE * 2097152))" \
70         $LOOP_MNT/foo >> $seqres.full
71
72 umount $LOOP_MNT
73 _check_xfs_filesystem $LOOP_DEV none none
74
75 _mkfs_dev -f $LOOP_DEV
76 _mount $LOOP_DEV $LOOP_MNT
77
78 # check we trim both ends of the extent approproiately; this will fail
79 # on 1k block size filesystems without the correct fixes in place.
80 $XFS_IO_PROG -ft \
81         -c "extsize 1g" \
82         -c "falloc 1023m 2g" \
83         $LOOP_MNT/foo >> $seqres.full
84
85 umount $LOOP_MNT
86 _check_xfs_filesystem $LOOP_DEV none none
87
88 # success, all done
89 echo "Silence is golden"
90 status=0
91 exit