2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (C) 2015 SUSE Linux Products GmbH. All Rights Reserved.
7 # Test that we can not clone an inline extent into a non-zero file offset.
10 seqres=$RESULT_DIR/$seq
11 echo "QA output created by $seq"
13 status=1 # failure is the default!
14 trap "_cleanup; exit \$status" 0 1 2 3 15
21 # get standard environment, filters and checks
25 # real QA test starts here
33 _scratch_mkfs >>$seqres.full 2>&1
36 BLOCK_SIZE=$(_get_block_size $SCRATCH_MNT)
38 # Create our test files. File foo has the same 2k of data at offset $BLOCK_SIZE
39 # as file bar has at its offset 0.
40 $XFS_IO_PROG -f -s -c "pwrite -S 0xaa 0 $BLOCK_SIZE" \
41 -c "pwrite -S 0xbb $BLOCK_SIZE 2k" \
42 -c "pwrite -S 0xcc $(($BLOCK_SIZE * 2)) $BLOCK_SIZE" \
43 $SCRATCH_MNT/foo | _filter_xfs_io_blocks_modified
45 # File bar consists of a single inline extent (2k in size).
46 $XFS_IO_PROG -f -s -c "pwrite -S 0xbb 0 2k" \
47 $SCRATCH_MNT/bar | _filter_xfs_io_blocks_modified
49 # Now call the clone ioctl to clone the extent of file bar into file
50 # foo at its $BLOCK_SIZE offset. This made file foo have an inline
51 # extent at offset $BLOCK_SIZE, something which the btrfs code can not
52 # deal with in future IO operations because all inline extents are
53 # supposed to start at an offset of 0, resulting in all sorts of
55 # So here we validate that the clone ioctl returns an EOPNOTSUPP,
56 # which is what it returns for other cases dealing with inlined
58 $CLONER_PROG -s 0 -d $BLOCK_SIZE -l 2048 \
59 $SCRATCH_MNT/bar $SCRATCH_MNT/foo
61 # Because of the inline extent at offset $BLOCK_SIZE, the following
62 # write made the kernel crash with a BUG_ON().
63 $XFS_IO_PROG -c "pwrite -S 0xdd $(($BLOCK_SIZE + 2048)) 2k" \
64 $SCRATCH_MNT/foo | _filter_xfs_io_blocks_modified