2015-08-04 14:10:49 +10:00
|
|
|
#! /bin/bash
|
2018-06-09 11:35:50 +10:00
|
|
|
# SPDX-License-Identifier: GPL-2.0
|
|
|
|
|
# Copyright (C) 2015 SUSE Linux Products GmbH. All Rights Reserved.
|
|
|
|
|
#
|
2015-08-04 14:10:49 +10:00
|
|
|
# FSQA Test No. 096
|
|
|
|
|
#
|
|
|
|
|
# Test that we can not clone an inline extent into a non-zero file offset.
|
|
|
|
|
#
|
|
|
|
|
seq=`basename $0`
|
|
|
|
|
seqres=$RESULT_DIR/$seq
|
|
|
|
|
echo "QA output created by $seq"
|
|
|
|
|
tmp=/tmp/$$
|
|
|
|
|
status=1 # failure is the default!
|
|
|
|
|
trap "_cleanup; exit \$status" 0 1 2 3 15
|
|
|
|
|
|
|
|
|
|
_cleanup()
|
|
|
|
|
{
|
|
|
|
|
rm -f $tmp.*
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
# get standard environment, filters and checks
|
|
|
|
|
. ./common/rc
|
|
|
|
|
. ./common/filter
|
2018-11-05 11:15:24 +00:00
|
|
|
. ./common/filter.btrfs
|
2015-08-04 14:10:49 +10:00
|
|
|
|
|
|
|
|
# real QA test starts here
|
|
|
|
|
_supported_fs btrfs
|
|
|
|
|
_supported_os Linux
|
|
|
|
|
_require_scratch
|
|
|
|
|
_require_cloner
|
|
|
|
|
|
|
|
|
|
rm -f $seqres.full
|
|
|
|
|
|
|
|
|
|
_scratch_mkfs >>$seqres.full 2>&1
|
|
|
|
|
_scratch_mount
|
|
|
|
|
|
2017-01-04 17:04:48 -08:00
|
|
|
BLOCK_SIZE=$(_get_block_size $SCRATCH_MNT)
|
2015-08-04 14:10:49 +10:00
|
|
|
|
2015-12-21 18:01:46 +11:00
|
|
|
# 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
|
2015-08-04 14:10:49 +10:00
|
|
|
|
2015-12-21 18:01:46 +11:00
|
|
|
# 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.
|
2018-11-05 11:15:24 +00:00
|
|
|
# So here we validate that the clone ioctl returns an EOPNOTSUPP or
|
|
|
|
|
# EINVAL which is what it returns for other cases dealing with inlined
|
2015-12-21 18:01:46 +11:00
|
|
|
# extents.
|
|
|
|
|
$CLONER_PROG -s 0 -d $BLOCK_SIZE -l 2048 \
|
2018-11-05 11:15:24 +00:00
|
|
|
$SCRATCH_MNT/bar $SCRATCH_MNT/foo | _filter_btrfs_cloner_error
|
2015-08-04 14:10:49 +10:00
|
|
|
|
2015-12-21 18:01:46 +11:00
|
|
|
# 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
|
2015-08-04 14:10:49 +10:00
|
|
|
|
|
|
|
|
status=0
|
|
|
|
|
exit
|