b9953f7ebf6a33a38600f3095b24a6a41d0583da
[xfstests-dev.git] / tests / xfs / 250
1 #! /bin/bash
2 # FS QA Test No. 250
3 #
4 # Bmap btree corruption regression test
5 #
6 #-----------------------------------------------------------------------
7 # Copyright (c) 2011 Red Hat, Inc.  All Rights Reserved.
8 #
9 # This program is free software; you can redistribute it and/or
10 # modify it under the terms of the GNU General Public License as
11 # published by the Free Software Foundation.
12 #
13 # This program is distributed in the hope that it would be useful,
14 # but WITHOUT ANY WARRANTY; without even the implied warranty of
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16 # GNU General Public License for more details.
17 #
18 # You should have received a copy of the GNU General Public License
19 # along with this program; if not, write the Free Software Foundation,
20 # Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
21 #-----------------------------------------------------------------------
22 #
23
24 seq=`basename $0`
25 seqres=$RESULT_DIR/$seq
26 echo "QA output created by $seq"
27
28 here=`pwd`
29 tmp=/tmp/$$
30 status=1  # failure is the default!
31 trap "_cleanup; exit \$status" 0 1 2 3 15
32
33 _cleanup()
34 {
35         cd /
36         umount -d $LOOP_MNT 2>/dev/null
37         rm -f $LOOP_DEV
38         rmdir $LOOP_MNT
39         _cleanup_testdir
40 }
41
42 # get standard environment, filters and checks
43 . ./common/rc
44 . ./common/filter
45
46 # real QA test starts here
47 _supported_fs xfs
48 _supported_os Linux
49 _require_loop
50
51 LOOP_DEV=$TEST_DIR/$seq.fs
52 LOOP_MNT=$TEST_DIR/$seq.mnt
53
54 _filter_io()
55 {
56         sed -e '/.* ops; /d'
57 }
58
59 # real QA test starts here
60
61 echo "*** create loop mount point"
62 rmdir $LOOP_MNT 2>/dev/null
63 mkdir -p $LOOP_MNT || _fail "cannot create loopback mount point"
64
65 _test_loop()
66 {
67         size=$1
68         agsize=$2
69         fsize=$3
70
71         dparam="file,name=$LOOP_DEV,size=$size"
72         if [ -n "$agsize" ]; then
73                 dparam="$dparam,agsize=$agsize"
74         fi
75
76         echo "*** mkfs loop file (size=$size)"
77         $MKFS_XFS_PROG -d $dparam \
78                 | _filter_mkfs 2>/dev/null
79
80         echo "*** mount loop filesystem"
81         mount -t xfs -o loop $LOOP_DEV $LOOP_MNT
82
83         echo "*** preallocate large file"
84         xfs_io -f -c "resvsp 0 $fsize" $LOOP_MNT/foo | _filter_io
85
86         echo "*** unmount loop filesystem"
87         umount -d $LOOP_MNT > /dev/null 2>&1
88
89         echo "*** check loop filesystem"
90          _check_xfs_filesystem $LOOP_DEV none none
91 }
92
93 _test_loop 50g 16m 40G
94 echo "*** done"
95 status=0
96 exit