fstests: check for filesystem FS_IOC_FSSETXATTR support
[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 seq=`basename $0`
11 seqres=$RESULT_DIR/$seq
12 echo "QA output created by $seq"
13
14 here=`pwd`
15 tmp=/tmp/$$
16 status=1    # failure is the default!
17 trap "_cleanup; exit \$status" 0 1 2 3 15
18
19 _cleanup()
20 {
21         cd /
22         _scratch_unmount > /dev/null 2>&1
23         rm -rf $tmp.*
24 }
25
26 # get standard environment, filters and checks
27 . ./common/rc
28 . ./common/filter
29 . ./common/reflink
30 . ./common/inject
31
32 # real QA test starts here
33 _supported_os Linux
34 _supported_fs xfs
35 _require_cp_reflink
36 _require_scratch_reflink
37 _require_error_injection
38 _require_xfs_io_command "cowextsize"
39 _require_xfs_io_error_injection "free_extent"
40
41 rm -f $seqres.full
42
43 blksz=65536
44 blks=4
45 sz=$((blksz * blks))
46 echo "Format filesystem"
47 _scratch_mkfs >/dev/null 2>&1
48 _scratch_mount >> $seqres.full
49
50 $XFS_IO_PROG -c "cowextsize $sz" $SCRATCH_MNT
51
52 echo "Create files"
53 _pwrite_byte 0x66 0 $sz $SCRATCH_MNT/file1 >> $seqres.full
54 _pwrite_byte 0x66 $((sz / 2)) $((sz / 2)) $SCRATCH_MNT/file2 >> $seqres.full
55 _reflink_range $SCRATCH_MNT/file1 0 $SCRATCH_MNT/file2 0 $((sz / 2)) >> $seqres.full
56 sync
57
58 echo "Check files"
59 md5sum $SCRATCH_MNT/file1 | _filter_scratch
60 md5sum $SCRATCH_MNT/file2 | _filter_scratch
61
62 echo "Inject error"
63 _scratch_inject_error "free_extent"
64
65 echo "CoW a few blocks"
66 $XFS_IO_PROG -c "pwrite -W -S 0x67 -b $sz 0 $sz" $SCRATCH_MNT/file1 >> $seqres.full 2>&1
67 sync
68
69 echo "FS should be shut down, touch will fail"
70 touch $SCRATCH_MNT/badfs 2>&1 | _filter_scratch
71
72 echo "Remount to replay log"
73 _scratch_inject_logprint >> $seqres.full
74
75 echo "FS should be online, touch should succeed"
76 touch $SCRATCH_MNT/goodfs
77
78 echo "Check files again"
79 md5sum $SCRATCH_MNT/file1 | _filter_scratch
80 md5sum $SCRATCH_MNT/file2 | _filter_scratch
81
82 echo "Done"
83
84 # success, all done
85 status=0
86 exit