fsx/fsstress: round blocksize properly
[xfstests-dev.git] / tests / xfs / 323
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. 323
6 #
7 # Reflink a file.
8 # Inject an error during extent free 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_fs xfs
34 _require_cp_reflink
35 _require_scratch_reflink
36 _require_xfs_io_error_injection "free_extent"
37
38 rm -f $seqres.full
39
40 blksz=65536
41 blks=64
42 sz=$((blksz * blks))
43 echo "Format filesystem"
44 _scratch_mkfs >/dev/null 2>&1
45 _scratch_mount >> $seqres.full
46
47 echo "Create files"
48 _pwrite_byte 0x66 0 $sz $SCRATCH_MNT/file1 >> $seqres.full
49 _pwrite_byte 0x67 0 $sz $SCRATCH_MNT/file3 >> $seqres.full
50 sync
51
52 echo "Check files"
53 md5sum $SCRATCH_MNT/file1 | _filter_scratch
54 md5sum $SCRATCH_MNT/file3 | _filter_scratch
55
56 echo "Inject error"
57 _scratch_inject_error "free_extent"
58
59 echo "Try to reflink"
60 _reflink_range $SCRATCH_MNT/file1 0 $SCRATCH_MNT/file3 0 $sz >> $seqres.full
61
62 echo "FS should be shut down, touch will fail"
63 touch $SCRATCH_MNT/badfs 2>&1 | _filter_scratch
64
65 echo "Remount to replay log"
66 _scratch_inject_logprint >> $seqres.full
67
68 echo "FS should be online, touch should succeed"
69 touch $SCRATCH_MNT/goodfs
70
71 echo "Done"
72
73 # success, all done
74 status=0
75 exit