generic: test MADV_POPULATE_READ with IO errors
[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 . ./common/preamble
20 _begin_fstest shutdown auto quick metadata quota
21
22 # Import common functions.
23 . ./common/filter
24 . ./common/quota
25
26 # real QA test starts here
27 _supported_fs generic
28
29 _require_scratch
30 _require_quota
31 _require_scratch_shutdown
32
33 _scratch_mkfs >/dev/null 2>&1
34 _scratch_enable_pquota
35 _require_metadata_journaling $SCRATCH_DEV
36 _qmount_option "prjquota"
37 _qmount
38 _require_prjquota $SCRATCH_DEV
39 _scratch_unmount
40
41 testfile=$SCRATCH_MNT/testfile
42
43 do_check()
44 {
45         _scratch_mount
46
47         touch $testfile
48
49         if [ "$1" == "sync" ]; then
50                 sync
51         fi
52
53         $XFS_IO_PROG -x -c "chproj 100" $testfile
54
55         before=`$XFS_IO_PROG -x -c "lsproj" $testfile`
56
57         $XFS_IO_PROG -f $testfile -c "fsync" | _filter_xfs_io
58
59         _scratch_shutdown | tee -a $seqres.full
60         _scratch_cycle_mount
61
62         after=`$XFS_IO_PROG -x -c "lsproj" $testfile`
63
64         # check inode's project quota id
65         if [ "$before" != "$after" ]; then
66                 echo "Before: $before"
67                 echo "After : $after"
68         fi
69         echo "Before: $before" >> $seqres.full
70         echo "After : $after" >> $seqres.full
71
72         rm -f $testfile
73         _scratch_unmount
74 }
75
76 echo "Silence is golden"
77
78 do_check
79 do_check sync
80
81 status=0
82 exit