xfs/530: skip test if user MKFS_OPTIONS screw up formatting
[xfstests-dev.git] / tests / xfs / 536
1 #! /bin/bash
2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2021 Chandan Babu R.  All Rights Reserved.
4 #
5 # FS QA Test 536
6 #
7 # Verify that XFS does not cause inode fork's extent count to overflow when
8 # remapping extents from one file's inode fork to another.
9 . ./common/preamble
10 _begin_fstest auto quick reflink
11
12 # Import common functions.
13 . ./common/filter
14 . ./common/reflink
15 . ./common/inject
16
17 # real QA test starts here
18
19 _supported_fs xfs
20 _require_scratch
21 _require_scratch_reflink
22 _require_xfs_debug
23 _require_xfs_io_command "reflink"
24 _require_xfs_io_error_injection "reduce_max_iextents"
25
26 echo "* Reflink remap extents"
27
28 echo "Format and mount fs"
29 _scratch_mkfs >> $seqres.full
30 _scratch_mount >> $seqres.full
31
32 bsize=$(_get_block_size $SCRATCH_MNT)
33
34 srcfile=${SCRATCH_MNT}/srcfile
35 dstfile=${SCRATCH_MNT}/dstfile
36
37 nr_blks=15
38
39 echo "Create \$srcfile having an extent of length $nr_blks blocks"
40 $XFS_IO_PROG -f -c "pwrite -b $((nr_blks * bsize))  0 $((nr_blks * bsize))" \
41        -c fsync $srcfile >> $seqres.full
42
43 echo "Create \$dstfile having an extent of length $nr_blks blocks"
44 $XFS_IO_PROG -f -c "pwrite -b $((nr_blks * bsize))  0 $((nr_blks * bsize))" \
45        -c fsync $dstfile >> $seqres.full
46
47 echo "Inject reduce_max_iextents error tag"
48 _scratch_inject_error reduce_max_iextents 1
49
50 echo "Reflink every other block from \$srcfile into \$dstfile"
51 for i in $(seq 1 2 $((nr_blks - 1))); do
52         _reflink_range $srcfile $((i * bsize)) $dstfile $((i * bsize)) $bsize \
53                        >> $seqres.full 2>&1
54 done
55
56 echo "Verify \$dstfile's extent count"
57 nextents=$(_xfs_get_fsxattr nextents $dstfile)
58 if (( $nextents > 10 )); then
59         echo "Extent count overflow check failed: nextents = $nextents"
60         exit 1
61 fi
62
63 # success, all done
64 status=0
65 exit