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