common/fuzzy: try to clear blocking flags first in _scratch_fuzz_modify
[xfstests-dev.git] / tests / generic / 506
1 #! /bin/bash
2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2018 Huawei.  All Rights Reserved.
4 #
5 # FS QA Test 506
6 #
7 # This testcase is trying to test recovery flow of generic filesystem, w/ below
8 # steps, once project id changes, after we fsync that file, we can expect that
9 # project id can be recovered after sudden power-cuts.
10 # 1. touch testfile;
11 # 1.1 sync (optional)
12 # 2. chattr -p 100 testfile;
13 # 3. xfs_io -f testfile -c "fsync";
14 # 4. godown;
15 # 5. umount;
16 # 6. mount;
17 # 7. check project id
18 #
19 seq=`basename $0`
20 seqres=$RESULT_DIR/$seq
21 echo "QA output created by $seq"
22
23 here=`pwd`
24 tmp=/tmp/$$
25 status=1        # failure is the default!
26 trap "_cleanup; exit \$status" 0 1 2 3 15
27
28 _cleanup()
29 {
30         cd /
31         rm -f $tmp.*
32 }
33
34 # get standard environment, filters and checks
35 . ./common/rc
36 . ./common/filter
37 . ./common/quota
38
39 # remove previous $seqres.full before test
40 rm -f $seqres.full
41
42 # real QA test starts here
43 _supported_fs generic
44 _supported_os Linux
45
46 _require_scratch
47 _require_scratch_shutdown
48
49 _scratch_mkfs >/dev/null 2>&1
50 _require_metadata_journaling $SCRATCH_DEV
51 _qmount_option "prjquota"
52 _qmount
53 _require_prjquota $SCRATCH_DEV
54 _scratch_unmount
55
56 testfile=$SCRATCH_MNT/testfile
57
58 do_check()
59 {
60         _scratch_mount
61
62         touch $testfile
63
64         if [ "$1" == "sync" ]; then
65                 sync
66         fi
67
68         $XFS_IO_PROG -x -c "chproj 100" $testfile
69
70         before=`$XFS_IO_PROG -x -c "lsproj" $testfile`
71
72         $XFS_IO_PROG -f $testfile -c "fsync" | _filter_xfs_io
73
74         _scratch_shutdown | tee -a $seqres.full
75         _scratch_cycle_mount
76
77         after=`$XFS_IO_PROG -x -c "lsproj" $testfile`
78
79         # check inode's project quota id
80         if [ "$before" != "$after" ]; then
81                 echo "Before: $before"
82                 echo "After : $after"
83         fi
84         echo "Before: $before" >> $seqres.full
85         echo "After : $after" >> $seqres.full
86
87         rm -f $testfile
88         _scratch_unmount
89 }
90
91 echo "Silence is golden"
92
93 do_check
94 do_check sync
95
96 status=0
97 exit