4 # Test that we can not clone an inline extent into a non-zero file offset.
6 #-----------------------------------------------------------------------
8 # Copyright (C) 2015 SUSE Linux Products GmbH. All Rights Reserved.
9 # Author: Filipe Manana <fdmanana@suse.com>
11 # This program is free software; you can redistribute it and/or
12 # modify it under the terms of the GNU General Public License as
13 # published by the Free Software Foundation.
15 # This program is distributed in the hope that it would be useful,
16 # but WITHOUT ANY WARRANTY; without even the implied warranty of
17 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 # GNU General Public License for more details.
20 # You should have received a copy of the GNU General Public License
21 # along with this program; if not, write the Free Software Foundation,
22 # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
23 #-----------------------------------------------------------------------
27 seqres=$RESULT_DIR/$seq
28 echo "QA output created by $seq"
30 status=1 # failure is the default!
31 trap "_cleanup; exit \$status" 0 1 2 3 15
38 # get standard environment, filters and checks
42 # real QA test starts here
51 _scratch_mkfs >>$seqres.full 2>&1
54 BLOCK_SIZE=$(get_block_size $SCRATCH_MNT)
56 # Create our test files. File foo has the same 2k of data at offset $BLOCK_SIZE
57 # as file bar has at its offset 0.
58 $XFS_IO_PROG -f -s -c "pwrite -S 0xaa 0 $BLOCK_SIZE" \
59 -c "pwrite -S 0xbb $BLOCK_SIZE 2k" \
60 -c "pwrite -S 0xcc $(($BLOCK_SIZE * 2)) $BLOCK_SIZE" \
61 $SCRATCH_MNT/foo | _filter_xfs_io_blocks_modified
63 # File bar consists of a single inline extent (2k in size).
64 $XFS_IO_PROG -f -s -c "pwrite -S 0xbb 0 2k" \
65 $SCRATCH_MNT/bar | _filter_xfs_io_blocks_modified
67 # Now call the clone ioctl to clone the extent of file bar into file
68 # foo at its $BLOCK_SIZE offset. This made file foo have an inline
69 # extent at offset $BLOCK_SIZE, something which the btrfs code can not
70 # deal with in future IO operations because all inline extents are
71 # supposed to start at an offset of 0, resulting in all sorts of
73 # So here we validate that the clone ioctl returns an EOPNOTSUPP,
74 # which is what it returns for other cases dealing with inlined
76 $CLONER_PROG -s 0 -d $BLOCK_SIZE -l 2048 \
77 $SCRATCH_MNT/bar $SCRATCH_MNT/foo
79 # Because of the inline extent at offset $BLOCK_SIZE, the following
80 # write made the kernel crash with a BUG_ON().
81 $XFS_IO_PROG -c "pwrite -S 0xdd $(($BLOCK_SIZE + 2048)) 2k" \
82 $SCRATCH_MNT/foo | _filter_xfs_io_blocks_modified