279: test mkfs with various sector sizes & alignments
[xfstests-dev.git] / 179
1 #! /bin/bash
2 # FSQA Test No. 179
3 #
4 # Test for NULL files problem
5 # test inode size is on disk after fsync
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 # creator
26 owner=lachlan@sgi.com
27
28 seq=`basename $0`
29 echo "QA output created by $seq"
30
31 here=`pwd`
32 tmp=/tmp/$$
33 status=1    # failure is the default!
34 trap "_cleanup; exit \$status" 0 1 2 3 15
35
36 _cleanup()
37 {
38     _cleanup_testdir
39 }
40
41 # get standard environment, filters and checks
42 . ./common.rc
43 . ./common.filter
44
45 # real QA test starts here
46 _supported_fs xfs
47 _supported_os Linux IRIX
48
49 _setup_testdir
50 _require_scratch
51 _scratch_mkfs_xfs >/dev/null 2>&1
52 _scratch_mount
53
54 _check_files()
55 {
56         # check file size and contents
57         i=1;
58         while [ $i -lt 1000 ]
59         do
60                 file=$SCRATCH_MNT/$i
61                 # if file is missing then fsync failed
62                 if [ -e $file ]
63                 then
64                         # if file size is not 32KB then fsync failed
65                         if [ `ls -l $file | tr -s ' ' | cut -d ' ' -f 5` -eq 32768 ]
66                         then
67                                 # if file has non-zero size but no extents then it's contents will be NULLs, bad.
68                                 if xfs_bmap $file | grep 'no extents' > /dev/null
69                                 then
70                                         echo corrupt file $file - non-zero size but no extents
71                                 else
72                                         rm -f $file
73                                 fi
74                         else
75                                 echo file $file has incorrect size - fsync failed
76                         fi
77                 else
78                         echo file $file missing - fsync failed
79                 fi
80                 let i=$i+1
81         done
82 }
83
84 # create files and fsync them
85 i=1;
86 while [ $i -lt 1000 ]
87 do
88         file=$SCRATCH_MNT/$i
89         xfs_io -f -c "pwrite -b 32k -S 0xff 0 32k" -c "fsync" $file > /dev/null
90         if [ $? -ne 0 ]
91         then
92                 echo error creating/writing file $file
93                 exit
94         fi
95         let i=$i+1
96 done
97
98 # shutdown immediately after, then remount and test
99 src/godown $SCRATCH_MNT
100 umount $SCRATCH_MNT
101 _scratch_mount
102 umount $SCRATCH_MNT
103 if [ ! _check_scratch_fs ]
104 then
105         echo error detected in filesystem
106         exit
107 fi
108 _scratch_mount
109 _check_files
110
111 status=0
112 exit