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
51 _require_command "$LSATTR_PROG" lasttr
52 _require_command "$CHATTR_PROG" chattr
56 _require_scratch_shutdown
58 _scratch_mkfs >/dev/null 2>&1
59 _require_metadata_journaling $SCRATCH_DEV
61 testfile=$SCRATCH_MNT/testfile
71 if [ "$2" == "sync" ]; then
72 echo "sync" >> $seqres.full
76 echo "Test chattr +$1" >> $seqres.full
79 $CHATTR_PROG +$attr $testfile
81 before=`$LSATTR_PROG $testfile`
83 $XFS_IO_PROG -f $testfile -c "fsync" | _filter_xfs_io
85 _scratch_shutdown | tee -a $seqres.full
88 after=`$LSATTR_PROG $testfile`
90 # check inode's i_flags
91 if [ "$before" != "$after" ]; then
92 echo "Before: $before"
95 echo "Before: $before" >> $seqres.full
96 echo "After : $after" >> $seqres.full
98 echo "Test chattr -$1" >> $seqres.full
101 $CHATTR_PROG -$attr $testfile
103 before=`$LSATTR_PROG $testfile`
105 $XFS_IO_PROG -f $testfile -c "fsync" | _filter_xfs_io
107 _scratch_shutdown | tee -a $seqres.full
110 after=`$LSATTR_PROG $testfile`
112 # check inode's i_flags
113 if [ "$before" != "$after" ]; then
114 echo "Before: $before"
115 echo "After : $after"
117 echo "Before: $before" >> $seqres.full
118 echo "After : $after" >> $seqres.full
124 echo "Silence is golden"