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
37 _require_scratch_shutdown
38 _require_xfs_io_command "fpunch"
40 _scratch_mkfs >/dev/null 2>&1
41 _require_metadata_journaling $SCRATCH_DEV
44 testfile=$SCRATCH_MNT/testfile
46 # check inode metadata after shutdown
47 check_inode_metadata()
52 if [ $sync_mode = "fsync" ]; then
53 stat_opt='-c "b: %b s: %s a: %x m: %y c: %z"'
55 stat_opt='-c "b: %b s: %s"'
58 before=`stat "$stat_opt" $testfile`
60 $XFS_IO_PROG -c "$sync_mode" $testfile | _filter_xfs_io
61 _scratch_shutdown | tee -a $seqres.full
64 after=`stat "$stat_opt" $testfile`
66 if [ "$before" != "$after" ]; then
67 echo "Before: $before"
69 status=1; # this is a failure!
71 echo "Before: $before" >> $seqres.full
72 echo "After : $after" >> $seqres.full
76 # append XX KB with f{data}sync, followed by power-cut
79 echo "==== i_size $2 test with $1 ====" | tee -a $seqres.full
80 $XFS_IO_PROG -f -c "truncate 4M" \
85 check_inode_metadata $1
88 # update times with f{data}sync, followed by power-cut
91 echo "==== i_time test with $1 ====" | tee -a $seqres.full
92 $XFS_IO_PROG -f -c "truncate 4M" \
98 check_inode_metadata $1
101 # punch XX KB with f{data}sync, followed by power-cut
104 echo "==== fpunch $2 test with $1 ====" | tee -a $seqres.full
105 $XFS_IO_PROG -f -c "truncate 4202496" \
106 -c "pwrite 0 4202496" \
108 -c "fpunch 4194304 $2"\
110 check_inode_metadata $1
113 for i in fsync fdatasync; do