generic: test MADV_POPULATE_READ with IO errors
[xfstests-dev.git] / tests / xfs / 322
1 #! /bin/bash
2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2016, Oracle and/or its affiliates.  All Rights Reserved.
4 #
5 # FS QA Test No. 322
6 #
7 # Reflink a file.
8 # Inject an error during rmap update to test log recovery.
9 #
10 . ./common/preamble
11 _begin_fstest auto quick clone
12
13 # Override the default cleanup function.
14 _cleanup()
15 {
16         cd /
17         _scratch_unmount > /dev/null 2>&1
18         rm -rf $tmp.*
19 }
20
21 # Import common functions.
22 . ./common/filter
23 . ./common/reflink
24 . ./common/inject
25
26 # real QA test starts here
27 _supported_fs xfs
28 _require_cp_reflink
29 _require_scratch_reflink
30 _require_xfs_scratch_rmapbt
31 _require_xfs_io_error_injection "rmap_finish_one"
32
33 blksz=65536
34 blks=64
35 sz=$((blksz * blks))
36 echo "Format filesystem"
37 _scratch_mkfs >/dev/null 2>&1
38 _scratch_mount >> $seqres.full
39
40 echo "Create files"
41 _pwrite_byte 0x66 0 $sz $SCRATCH_MNT/file1 >> $seqres.full
42 $XFS_IO_PROG -f -c "truncate $sz" $SCRATCH_MNT/file3 >> $seqres.full
43 sync
44
45 echo "Check files"
46 md5sum $SCRATCH_MNT/file1 | _filter_scratch
47 md5sum $SCRATCH_MNT/file3 | _filter_scratch
48
49 echo "Inject error"
50 _scratch_inject_error "rmap_finish_one"
51
52 echo "Try to reflink"
53 _reflink_range $SCRATCH_MNT/file1 0 $SCRATCH_MNT/file3 0 $sz >> $seqres.full
54
55 echo "FS should be shut down, touch will fail"
56 touch $SCRATCH_MNT/badfs 2>&1 | _filter_scratch
57
58 echo "Remount to replay log"
59 _scratch_remount_dump_log >> $seqres.full
60
61 echo "Check files"
62 md5sum $SCRATCH_MNT/file1 | _filter_scratch
63 md5sum $SCRATCH_MNT/file3 | _filter_scratch
64
65 echo "FS should be online, touch should succeed"
66 touch $SCRATCH_MNT/goodfs
67
68 echo "Done"
69
70 # success, all done
71 status=0
72 exit