4 # Test inode's metadata after fsync or fdatasync calls.
5 # In the case of fsync, filesystem should recover all the inode metadata, while
6 # recovering i_blocks and i_size at least for fdatasync.
8 #-----------------------------------------------------------------------
9 # Copyright (c) 2016 Jaegeuk Kim. All Rights Reserved.
11 # This program is free software; you can redistribute it and/or
12 # modify it under the terms of the GNU General Public License as
13 # published by the Free Software Foundation.
15 # This program is distributed in the hope that it would be useful,
16 # but WITHOUT ANY WARRANTY; without even the implied warranty of
17 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 # GNU General Public License for more details.
20 # You should have received a copy of the GNU General Public License
21 # along with this program; if not, write the Free Software Foundation,
22 # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
23 #-----------------------------------------------------------------------
27 seqres=$RESULT_DIR/$seq
28 echo "QA output created by $seq"
32 status=0 # failure will be detected in runtime!
33 trap "_cleanup; exit \$status" 0 1 2 3 15
41 # get standard environment, filters and checks
46 # real QA test starts here
52 _require_scratch_shutdown
53 _require_xfs_io_command "fpunch"
55 _scratch_mkfs >/dev/null 2>&1
56 _require_metadata_journaling $SCRATCH_DEV
59 testfile=$SCRATCH_MNT/testfile
61 # check inode metadata after shutdown
62 check_inode_metadata()
67 if [ $sync_mode = "fsync" ]; then
68 stat_opt='-c "b: %b s: %s a: %x m: %y c: %z"'
70 stat_opt='-c "b: %b s: %s"'
73 before=`stat "$stat_opt" $testfile`
75 $XFS_IO_PROG -c "$sync_mode" $testfile | _filter_xfs_io
76 src/godown $SCRATCH_MNT | tee -a $seqres.full
79 after=`stat "$stat_opt" $testfile`
81 if [ "$before" != "$after" ]; then
82 echo "Before: $before"
84 status=1; # this is a failure!
86 echo "Before: $before" >> $seqres.full
87 echo "After : $after" >> $seqres.full
91 # append XX KB with f{data}sync, followed by power-cut
94 echo "==== i_size $2 test with $1 ====" | tee -a $seqres.full
95 $XFS_IO_PROG -f -c "truncate 4M" \
100 check_inode_metadata $1
103 # update times with f{data}sync, followed by power-cut
106 echo "==== i_time test with $1 ====" | tee -a $seqres.full
107 $XFS_IO_PROG -f -c "truncate 4M" \
113 check_inode_metadata $1
116 # punch XX KB with f{data}sync, followed by power-cut
119 echo "==== fpunch $2 test with $1 ====" | tee -a $seqres.full
120 $XFS_IO_PROG -f -c "truncate 4202496" \
121 -c "pwrite 0 4202496" \
123 -c "fpunch 4194304 $2"\
125 check_inode_metadata $1
128 for i in fsync fdatasync; do