2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2018 Huawei. All Rights Reserved.
7 # This testcase is trying to test recovery flow of generic filesystem, w/ below
8 # steps, once i_flags changes, after we fsync that file, we can expect that
9 # i_flags can be recovered after sudden power-cuts.
12 # 2. chattr +[AsSu] testfile
13 # 3. xfs_io -f testfile -c "fsync";
18 # 8. chattr -[AsSu] testfile
19 # 9. xfs_io -f testfile -c "fsync";
26 seqres=$RESULT_DIR/$seq
27 echo "QA output created by $seq"
31 status=1 # failure is the default!
32 trap "_cleanup; exit \$status" 0 1 2 3 15
40 # get standard environment, filters and checks
44 # remove previous $seqres.full before test
47 # real QA test starts here
50 _require_command "$LSATTR_PROG" lasttr
51 _require_command "$CHATTR_PROG" chattr
55 _require_scratch_shutdown
57 _scratch_mkfs >/dev/null 2>&1
58 _require_metadata_journaling $SCRATCH_DEV
60 testfile=$SCRATCH_MNT/testfile
70 if [ "$2" == "sync" ]; then
71 echo "sync" >> $seqres.full
75 echo "Test chattr +$1" >> $seqres.full
78 $CHATTR_PROG +$attr $testfile
80 before=`$LSATTR_PROG $testfile`
82 $XFS_IO_PROG -f $testfile -c "fsync" | _filter_xfs_io
84 _scratch_shutdown | tee -a $seqres.full
87 after=`$LSATTR_PROG $testfile`
89 # check inode's i_flags
90 if [ "$before" != "$after" ]; then
91 echo "Before: $before"
94 echo "Before: $before" >> $seqres.full
95 echo "After : $after" >> $seqres.full
97 echo "Test chattr -$1" >> $seqres.full
100 $CHATTR_PROG -$attr $testfile
102 before=`$LSATTR_PROG $testfile`
104 $XFS_IO_PROG -f $testfile -c "fsync" | _filter_xfs_io
106 _scratch_shutdown | tee -a $seqres.full
109 after=`$LSATTR_PROG $testfile`
111 # check inode's i_flags
112 if [ "$before" != "$after" ]; then
113 echo "Before: $before"
114 echo "After : $after"
116 echo "Before: $before" >> $seqres.full
117 echo "After : $after" >> $seqres.full
123 echo "Silence is golden"