xfs: Add test for too-small device with stripe geometry
[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 seq=`basename $0`
10 seqres=$RESULT_DIR/$seq
11 echo "QA output created by $seq"
12 tmp=/tmp/$$
13 status=1        # failure is the default!
14 trap "_cleanup; exit \$status" 0 1 2 3 15
15
16 _cleanup()
17 {
18         rm -f $tmp.*
19 }
20
21 # get standard environment, filters and checks
22 . ./common/rc
23 . ./common/filter
24 . ./common/filter.btrfs
25
26 # real QA test starts here
27 _supported_fs btrfs
28 _require_scratch
29 _require_cloner
30
31 rm -f $seqres.full
32
33 _scratch_mkfs >>$seqres.full 2>&1
34 _scratch_mount
35
36 BLOCK_SIZE=$(_get_block_size $SCRATCH_MNT)
37
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
44
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
48
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
54 # chaos.
55 # So here we validate that the clone ioctl returns an EOPNOTSUPP or
56 # EINVAL which is what it returns for other cases dealing with inlined
57 # extents.
58 $CLONER_PROG -s 0 -d $BLOCK_SIZE -l 2048 \
59         $SCRATCH_MNT/bar $SCRATCH_MNT/foo | _filter_btrfs_cloner_error
60
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
65
66 status=0
67 exit