| #! /bin/bash |
| # SPDX-License-Identifier: GPL-2.0 |
| # Copyright (C) 2015 SUSE Linux Products GmbH. All Rights Reserved. |
| # |
| # FSQA Test No. 096 |
| # |
| # Test that we can not clone an inline extent into a non-zero file offset. |
| # |
| . ./common/preamble |
| _begin_fstest auto quick clone |
| |
| . ./common/filter |
| . ./common/filter.btrfs |
| |
| _require_scratch |
| _require_cloner |
| |
| _scratch_mkfs >>$seqres.full 2>&1 |
| _scratch_mount |
| |
| BLOCK_SIZE=$(_get_block_size $SCRATCH_MNT) |
| |
| # Create our test files. File foo has the same 2k of data at offset $BLOCK_SIZE |
| # as file bar has at its offset 0. |
| $XFS_IO_PROG -f -s -c "pwrite -S 0xaa 0 $BLOCK_SIZE" \ |
| -c "pwrite -S 0xbb $BLOCK_SIZE 2k" \ |
| -c "pwrite -S 0xcc $(($BLOCK_SIZE * 2)) $BLOCK_SIZE" \ |
| $SCRATCH_MNT/foo | _filter_xfs_io_blocks_modified |
| |
| # File bar consists of a single inline extent (2k in size). |
| $XFS_IO_PROG -f -s -c "pwrite -S 0xbb 0 2k" \ |
| $SCRATCH_MNT/bar | _filter_xfs_io_blocks_modified |
| |
| # Now call the clone ioctl to clone the extent of file bar into file |
| # foo at its $BLOCK_SIZE offset. This made file foo have an inline |
| # extent at offset $BLOCK_SIZE, something which the btrfs code can not |
| # deal with in future IO operations because all inline extents are |
| # supposed to start at an offset of 0, resulting in all sorts of |
| # chaos. |
| # So here we validate that the clone ioctl returns an EOPNOTSUPP or |
| # EINVAL which is what it returns for other cases dealing with inlined |
| # extents. |
| $CLONER_PROG -s 0 -d $BLOCK_SIZE -l 2048 \ |
| $SCRATCH_MNT/bar $SCRATCH_MNT/foo | _filter_btrfs_cloner_error |
| |
| # Because of the inline extent at offset $BLOCK_SIZE, the following |
| # write made the kernel crash with a BUG_ON(). |
| $XFS_IO_PROG -c "pwrite -S 0xdd $(($BLOCK_SIZE + 2048)) 2k" \ |
| $SCRATCH_MNT/foo | _filter_xfs_io_blocks_modified |
| |
| status=0 |
| exit |