fsx/fsstress: round blocksize properly
[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
45 _require_scratch
46 _require_scratch_shutdown
47
48 _scratch_mkfs >/dev/null 2>&1
49 _require_metadata_journaling $SCRATCH_DEV
50 _qmount_option "prjquota"
51 _qmount
52 _require_prjquota $SCRATCH_DEV
53 _scratch_unmount
54
55 testfile=$SCRATCH_MNT/testfile
56
57 do_check()
58 {
59         _scratch_mount
60
61         touch $testfile
62
63         if [ "$1" == "sync" ]; then
64                 sync
65         fi
66
67         $XFS_IO_PROG -x -c "chproj 100" $testfile
68
69         before=`$XFS_IO_PROG -x -c "lsproj" $testfile`
70
71         $XFS_IO_PROG -f $testfile -c "fsync" | _filter_xfs_io
72
73         _scratch_shutdown | tee -a $seqres.full
74         _scratch_cycle_mount
75
76         after=`$XFS_IO_PROG -x -c "lsproj" $testfile`
77
78         # check inode's project quota id
79         if [ "$before" != "$after" ]; then
80                 echo "Before: $before"
81                 echo "After : $after"
82         fi
83         echo "Before: $before" >> $seqres.full
84         echo "After : $after" >> $seqres.full
85
86         rm -f $testfile
87         _scratch_unmount
88 }
89
90 echo "Silence is golden"
91
92 do_check
93 do_check sync
94
95 status=0
96 exit