xfstests: stop special casing nfs and udf
[xfstests-dev.git] / tests / xfs / 180
1 #! /bin/bash
2 # FSQA Test No. 180
3 #
4 # Test for NULL files problem
5 # test inode size is on disk after sync
6 #
7 #-----------------------------------------------------------------------
8 # Copyright (c) 2006 Silicon Graphics, Inc.  All Rights Reserved.
9 #
10 # This program is free software; you can redistribute it and/or
11 # modify it under the terms of the GNU General Public License as
12 # published by the Free Software Foundation.
13 #
14 # This program is distributed in the hope that it would be useful,
15 # but WITHOUT ANY WARRANTY; without even the implied warranty of
16 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17 # GNU General Public License for more details.
18 #
19 # You should have received a copy of the GNU General Public License
20 # along with this program; if not, write the Free Software Foundation,
21 # Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
22 #
23 #-----------------------------------------------------------------------
24 #
25
26 seq=`basename $0`
27 seqres=$RESULT_DIR/$seq
28 echo "QA output created by $seq"
29
30 here=`pwd`
31 tmp=/tmp/$$
32 status=1    # failure is the default!
33 trap "exit \$status" 0 1 2 3 15
34
35 # get standard environment, filters and checks
36 . ./common/rc
37 . ./common/filter
38
39 # real QA test starts here
40 _supported_fs xfs
41 _supported_os Linux IRIX
42
43 _require_scratch
44 _scratch_mkfs_xfs >/dev/null 2>&1
45 _scratch_mount
46
47 # Do we have enough space on disk?  10G
48 _require_fs_space $SCRATCH_MNT 10485760
49
50 _check_files()
51 {
52         # check file size and contents
53         i=1;
54         while [ $i -lt 1000 ]
55         do
56                 file=$SCRATCH_MNT/$i
57                 # if file is missing then sync failed
58                 if [ -e $file ]
59                 then
60                         # if file size is not 10MB then sync failed
61                         if [ `ls -l $file | tr -s ' ' | cut -d ' ' -f 5` -eq 10485760 ]
62                         then
63                                 # if file has non-zero size but no extents then it's contents will be NULLs, bad.
64                                 if xfs_bmap $file | grep 'no extents' > /dev/null
65                                 then
66                                         echo corrupt file $file - non-zero size but no extents
67                                 else
68                                         rm -f $file
69                                 fi
70                         else
71                                 echo file $file has incorrect size - sync failed
72                         fi
73                 else
74                         echo file $file missing - sync failed
75                 fi
76                 let i=$i+1
77         done
78 }
79
80 # create files and sync them
81 i=1;
82 while [ $i -lt 1000 ]
83 do
84         file=$SCRATCH_MNT/$i
85         xfs_io -f -c "pwrite -b 64k -S 0xff 0 10m" $file > /dev/null
86         if [ $? -ne 0 ]
87         then
88                 echo error creating/writing file $file
89                 exit
90         fi
91         let i=$i+1
92 done
93
94 # sync, then shutdown immediately after, then remount and test
95 sync
96 src/godown $SCRATCH_MNT
97 umount $SCRATCH_MNT
98 _scratch_mount
99 umount $SCRATCH_MNT
100 if [ ! _check_scratch_fs ]
101 then
102         echo error detected in filesystem
103         exit
104 fi
105 _scratch_mount
106 _check_files
107
108 status=0
109 exit