fstests: move test group info to test files
[xfstests-dev.git] / tests / btrfs / 096
1 #! /bin/bash
2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (C) 2015 SUSE Linux Products GmbH. All Rights Reserved.
4 #
5 # FSQA Test No. 096
6 #
7 # Test that we can not clone an inline extent into a non-zero file offset.
8 #
9 . ./common/preamble
10 _begin_fstest auto quick clone
11
12 # Import common functions.
13 . ./common/filter
14 . ./common/filter.btrfs
15
16 # real QA test starts here
17 _supported_fs btrfs
18 _require_scratch
19 _require_cloner
20
21 _scratch_mkfs >>$seqres.full 2>&1
22 _scratch_mount
23
24 BLOCK_SIZE=$(_get_block_size $SCRATCH_MNT)
25
26 # Create our test files. File foo has the same 2k of data at offset $BLOCK_SIZE
27 # as file bar has at its offset 0.
28 $XFS_IO_PROG -f -s -c "pwrite -S 0xaa 0 $BLOCK_SIZE" \
29                 -c "pwrite -S 0xbb $BLOCK_SIZE 2k" \
30                 -c "pwrite -S 0xcc $(($BLOCK_SIZE * 2)) $BLOCK_SIZE" \
31                 $SCRATCH_MNT/foo | _filter_xfs_io_blocks_modified
32
33 # File bar consists of a single inline extent (2k in size).
34 $XFS_IO_PROG -f -s -c "pwrite -S 0xbb 0 2k" \
35                 $SCRATCH_MNT/bar | _filter_xfs_io_blocks_modified
36
37 # Now call the clone ioctl to clone the extent of file bar into file
38 # foo at its $BLOCK_SIZE offset. This made file foo have an inline
39 # extent at offset $BLOCK_SIZE, something which the btrfs code can not
40 # deal with in future IO operations because all inline extents are
41 # supposed to start at an offset of 0, resulting in all sorts of
42 # chaos.
43 # So here we validate that the clone ioctl returns an EOPNOTSUPP or
44 # EINVAL which is what it returns for other cases dealing with inlined
45 # extents.
46 $CLONER_PROG -s 0 -d $BLOCK_SIZE -l 2048 \
47         $SCRATCH_MNT/bar $SCRATCH_MNT/foo | _filter_btrfs_cloner_error
48
49 # Because of the inline extent at offset $BLOCK_SIZE, the following
50 # write made the kernel crash with a BUG_ON().
51 $XFS_IO_PROG -c "pwrite -S 0xdd $(($BLOCK_SIZE + 2048)) 2k" \
52              $SCRATCH_MNT/foo | _filter_xfs_io_blocks_modified
53
54 status=0
55 exit