xfs/530: skip test if user MKFS_OPTIONS screw up formatting
[xfstests-dev.git] / tests / xfs / 315
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. 315
6 #
7 # Reflink a file with a few dozen extents and CoW a few blocks.
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_command "cowextsize"
32 _require_xfs_io_error_injection "free_extent"
33
34 blksz=65536
35 blks=4
36 sz=$((blksz * blks))
37 echo "Format filesystem"
38 _scratch_mkfs >/dev/null 2>&1
39 _scratch_mount >> $seqres.full
40
41 $XFS_IO_PROG -c "cowextsize $sz" $SCRATCH_MNT
42
43 echo "Create files"
44 _pwrite_byte 0x66 0 $sz $SCRATCH_MNT/file1 >> $seqres.full
45 _pwrite_byte 0x66 $((sz / 2)) $((sz / 2)) $SCRATCH_MNT/file2 >> $seqres.full
46 _reflink_range $SCRATCH_MNT/file1 0 $SCRATCH_MNT/file2 0 $((sz / 2)) >> $seqres.full
47 sync
48
49 echo "Check files"
50 md5sum $SCRATCH_MNT/file1 | _filter_scratch
51 md5sum $SCRATCH_MNT/file2 | _filter_scratch
52
53 echo "Inject error"
54 _scratch_inject_error "free_extent"
55
56 echo "CoW a few blocks"
57 $XFS_IO_PROG -c "pwrite -W -S 0x67 -b $sz 0 $sz" $SCRATCH_MNT/file1 >> $seqres.full 2>&1
58 sync
59
60 echo "FS should be shut down, touch will fail"
61 touch $SCRATCH_MNT/badfs 2>&1 | _filter_scratch
62
63 echo "Remount to replay log"
64 _scratch_inject_logprint >> $seqres.full
65
66 echo "FS should be online, touch should succeed"
67 touch $SCRATCH_MNT/goodfs
68
69 echo "Check files again"
70 md5sum $SCRATCH_MNT/file1 | _filter_scratch
71 md5sum $SCRATCH_MNT/file2 | _filter_scratch
72
73 echo "Done"
74
75 # success, all done
76 status=0
77 exit