generic: test MADV_POPULATE_READ with IO errors
[xfstests-dev.git] / tests / generic / 505
1 #! /bin/bash
2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2018 Huawei.  All Rights Reserved.
4 #
5 # FS QA Test 505
6 #
7 # This testcase is trying to test recovery flow of generic filesystem, w/ below
8 # steps, once uid or gid changes, after we fsync that file, we can expect that
9 # uid/gid can be recovered after sudden power-cuts.
10 # 1. touch testfile;
11 # 1.1 sync (optional)
12 # 2. chown 100 testfile;
13 # 3. chgrp 100 testfile;
14 # 4. xfs_io -f testfile -c "fsync";
15 # 5. godown;
16 # 6. umount;
17 # 7. mount;
18 # 8. check uid/gid
19 #
20 . ./common/preamble
21 _begin_fstest shutdown auto quick metadata
22
23 # Import common functions.
24 . ./common/filter
25
26 # real QA test starts here
27 _supported_fs generic
28
29 _require_scratch
30 _require_scratch_shutdown
31
32 _scratch_mkfs >/dev/null 2>&1
33 _require_metadata_journaling $SCRATCH_DEV
34
35 testfile=$SCRATCH_MNT/testfile
36 stat_opt='-c "uid: %u, gid: %g"'
37
38 do_check()
39 {
40         _scratch_mount
41
42         touch $testfile
43
44         if [ "$1" == "sync" ]; then
45                 sync
46         fi
47
48         chown 100 $testfile
49         chgrp 100 $testfile
50
51         before=`stat "$stat_opt" $testfile`
52
53         $XFS_IO_PROG -f $testfile -c "fsync" | _filter_xfs_io
54
55         _scratch_shutdown | tee -a $seqres.full
56         _scratch_cycle_mount
57
58         after=`stat "$stat_opt" $testfile`
59
60         # check inode's uid/gid
61         if [ "$before" != "$after" ]; then
62                 echo "Before: $before"
63                 echo "After : $after"
64         fi
65         echo "Before: $before" >> $seqres.full
66         echo "After : $after" >> $seqres.full
67
68         rm $testfile
69         _scratch_unmount
70 }
71
72 echo "Silence is golden"
73 do_check
74 do_check sync
75
76 status=0
77 exit