xfs/{263,106}: erase max warnings printout
[xfstests-dev.git] / tests / generic / 048
1 #! /bin/bash
2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2006 Silicon Graphics, Inc.  All Rights Reserved.
4 #
5 # FSQA Test No. 048
6 #
7 # Test for NULL files problem
8 # test inode size is on disk after sync
9 #
10 seq=`basename $0`
11 seqres=$RESULT_DIR/$seq
12 echo "QA output created by $seq"
13
14 here=`pwd`
15 tmp=/tmp/$$
16 status=1    # failure is the default!
17 trap "exit \$status" 0 1 2 3 15
18
19 # get standard environment, filters and checks
20 . ./common/rc
21 . ./common/filter
22
23 # real QA test starts here
24 _supported_fs generic
25 _supported_os Linux
26
27 _require_scratch
28 _require_scratch_shutdown
29 _require_xfs_io_command "fiemap"
30 _scratch_mkfs >/dev/null 2>&1
31 _require_metadata_journaling $SCRATCH_DEV
32 _scratch_mount
33
34 # Do we have enough space on disk?  10G
35 _require_fs_space $SCRATCH_MNT 10485760
36
37 _check_files()
38 {
39         # check file size and contents
40         i=1;
41         while [ $i -lt 1000 ]
42         do
43                 file=$SCRATCH_MNT/$i
44                 # if file is missing then sync failed
45                 if [ -e $file ]
46                 then
47                         # if file size is not 10MB then sync failed
48                         if [ `ls -l $file | tr -s ' ' | cut -d ' ' -f 5` -eq 10485760 ]
49                         then
50                                 # if file has non-zero size but no extents then it's contents will be NULLs, bad.
51                                 num_extents=`_count_extents $file`
52                                 if [ $num_extents -eq 0 ]; then
53                                         echo corrupt file $file - non-zero size but no extents
54                                 else
55                                         rm -f $file
56                                 fi
57                         else
58                                 echo file $file has incorrect size - sync failed
59                         fi
60                 else
61                         echo file $file missing - sync failed
62                 fi
63                 let i=$i+1
64         done
65 }
66
67 # create files and sync them
68 i=1;
69 while [ $i -lt 1000 ]
70 do
71         file=$SCRATCH_MNT/$i
72         $XFS_IO_PROG -f -c "pwrite -b 64k -S 0xff 0 10m" $file > /dev/null
73         if [ $? -ne 0 ]
74         then
75                 echo error creating/writing file $file
76                 exit
77         fi
78         let i=$i+1
79 done
80
81 # sync, then shutdown immediately after, then remount and test
82 sync
83 _scratch_shutdown
84 _scratch_unmount
85 _scratch_mount
86 _scratch_unmount
87 if [ ! _check_scratch_fs ]
88 then
89         echo error detected in filesystem
90         exit
91 fi
92 _scratch_mount
93 _check_files
94
95 status=0
96 exit