xfs/007: fix regressions on V4 filesystems
[xfstests-dev.git] / tests / xfs / 325
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. 325
6 #
7 # Reflink a file with a few dozen extents, CoW a few blocks, and rm.
8 # Inject an error during extent freeing 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_error_injection
31 _require_xfs_io_error_injection "free_extent"
32
33 blksz=65536
34 blks=30
35 echo "Format filesystem"
36 _scratch_mkfs >/dev/null 2>&1
37 _scratch_mount >> $seqres.full
38
39 echo "Create files"
40 _pwrite_byte 0x66 0 $((blksz * blks)) $SCRATCH_MNT/file1 >> $seqres.full
41 _cp_reflink $SCRATCH_MNT/file1 $SCRATCH_MNT/file2
42 sync
43
44 echo "Check files"
45 md5sum $SCRATCH_MNT/file1 | _filter_scratch
46 md5sum $SCRATCH_MNT/file2 | _filter_scratch
47
48 echo "CoW a few blocks"
49 $XFS_IO_PROG -c "pwrite -W -S 0x67 $((10 * blksz)) $((10 * blksz))" $SCRATCH_MNT/file2 >> $seqres.full
50
51 echo "Inject error"
52 _scratch_inject_error "free_extent"
53
54 rm $SCRATCH_MNT/file1
55 sync
56 $XFS_IO_PROG -x -c 'freeze' -c 'thaw' $SCRATCH_MNT >> $seqres.full 2>&1
57
58 echo "FS should be shut down, touch will fail"
59 touch $SCRATCH_MNT/badfs 2>&1 | _filter_scratch
60
61 echo "Remount to replay log"
62 _scratch_inject_logprint >> $seqres.full
63
64 echo "FS should be online, touch should succeed"
65 touch $SCRATCH_MNT/goodfs
66
67 echo "Check files again"
68 md5sum $SCRATCH_MNT/file2 | _filter_scratch
69
70 echo "Done"
71
72 # success, all done
73 status=0
74 exit