generic: test MADV_POPULATE_READ with IO errors
[xfstests-dev.git] / tests / generic / 508
1 #! /bin/bash
2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2018 Huawei.  All Rights Reserved.
4 #
5 # FS QA Test 508
6 #
7 # This testcase is trying to test recovery flow of generic filesystem, it needs
8 # creation time support on specified filesystem.
9 # With below steps, once the file is created, creation time attribute should be
10 # valid on the file, after we fsync that file, it expects creation time can be
11 # recovered after sudden power-cuts.
12 # 1. touch testfile;
13 # 1.1 sync (optional)
14 # 2. xfs_io -f testfile -c "fsync";
15 # 3. godown;
16 # 4. umount;
17 # 5. mount;
18 # 6. check creation time
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_test_lsattr
30 _require_statx
31 _require_xfs_io_command "statx" "-v"
32
33 _require_scratch
34 _require_scratch_shutdown
35 _require_scratch_btime
36
37 _scratch_mkfs >/dev/null 2>&1
38 _require_metadata_journaling $SCRATCH_DEV
39
40 testfile=$SCRATCH_MNT/testfile
41
42 do_check()
43 {
44         _scratch_mount
45
46         touch $testfile
47
48         if [ "$1" == "sync" ]; then
49                 sync
50         fi
51
52         before=`$XFS_IO_PROG -f $testfile -c "statx -v" | grep btime`
53
54         $XFS_IO_PROG -f $testfile -c "fsync" | _filter_xfs_io
55
56         _scratch_shutdown | tee -a $seqres.full
57         _scratch_cycle_mount
58
59         after=`$XFS_IO_PROG -f $testfile -c "statx -v" | grep btime`
60
61         # check inode's creation time
62         if [ "$before" != "$after" ]; then
63                 echo "Before: $before"
64                 echo "After : $after"
65         fi
66         echo "Before: $before" >> $seqres.full
67         echo "After : $after" >> $seqres.full
68
69         rm -f $testfile
70         _scratch_unmount
71 }
72
73 echo "Silence is golden"
74
75 do_check
76 do_check sync
77
78 status=0
79 exit