2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2016 Jaegeuk Kim. All Rights Reserved.
7 # Test inode's metadata after fsync or fdatasync calls.
8 # In the case of fsync, filesystem should recover all the inode metadata, while
9 # recovering i_blocks and i_size at least for fdatasync.
12 seqres=$RESULT_DIR/$seq
13 echo "QA output created by $seq"
17 status=0 # failure will be detected in runtime!
18 trap "_cleanup; exit \$status" 0 1 2 3 15
26 # get standard environment, filters and checks
31 # real QA test starts here
36 _require_scratch_shutdown
37 _require_xfs_io_command "fpunch"
39 _scratch_mkfs >/dev/null 2>&1
40 _require_metadata_journaling $SCRATCH_DEV
43 testfile=$SCRATCH_MNT/testfile
45 # check inode metadata after shutdown
46 check_inode_metadata()
51 if [ $sync_mode = "fsync" ]; then
52 stat_opt='-c "b: %b s: %s a: %x m: %y c: %z"'
54 stat_opt='-c "b: %b s: %s"'
57 before=`stat "$stat_opt" $testfile`
59 $XFS_IO_PROG -c "$sync_mode" $testfile | _filter_xfs_io
60 _scratch_shutdown | tee -a $seqres.full
63 after=`stat "$stat_opt" $testfile`
65 if [ "$before" != "$after" ]; then
66 echo "Before: $before"
68 status=1; # this is a failure!
70 echo "Before: $before" >> $seqres.full
71 echo "After : $after" >> $seqres.full
75 # append XX KB with f{data}sync, followed by power-cut
78 echo "==== i_size $2 test with $1 ====" | tee -a $seqres.full
79 $XFS_IO_PROG -f -c "truncate 4M" \
84 check_inode_metadata $1
87 # update times with f{data}sync, followed by power-cut
90 echo "==== i_time test with $1 ====" | tee -a $seqres.full
91 $XFS_IO_PROG -f -c "truncate 4M" \
97 check_inode_metadata $1
100 # punch XX KB with f{data}sync, followed by power-cut
103 echo "==== fpunch $2 test with $1 ====" | tee -a $seqres.full
104 $XFS_IO_PROG -f -c "truncate 4202496" \
105 -c "pwrite 0 4202496" \
107 -c "fpunch 4194304 $2"\
109 check_inode_metadata $1
112 for i in fsync fdatasync; do