2015-11-17 08:39:50 +11:00
|
|
|
#! /bin/bash
|
2018-06-09 11:35:42 +10:00
|
|
|
# SPDX-License-Identifier: GPL-2.0
|
|
|
|
|
# Copyright (c) 2015, Oracle and/or its affiliates. All Rights Reserved.
|
|
|
|
|
#
|
2015-11-17 08:39:50 +11:00
|
|
|
# FS QA Test No. 158
|
|
|
|
|
#
|
|
|
|
|
# Check that various invalid dedupe scenarios are rejected.
|
|
|
|
|
#
|
2016-02-10 00:33:10 -08:00
|
|
|
seq=`basename $0`
|
|
|
|
|
seqres=$RESULT_DIR/$seq
|
2015-11-17 08:39:50 +11:00
|
|
|
echo "QA output created by $seq"
|
|
|
|
|
|
|
|
|
|
here=`pwd`
|
|
|
|
|
tmp=/tmp/$$
|
|
|
|
|
status=1 # failure is the default!
|
|
|
|
|
trap "_cleanup; exit \$status" 0 1 2 3 15
|
|
|
|
|
|
|
|
|
|
_cleanup()
|
|
|
|
|
{
|
|
|
|
|
cd /
|
2016-02-10 00:33:10 -08:00
|
|
|
rm -rf $tmp.* $testdir1
|
2015-11-17 08:39:50 +11:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
# get standard environment, filters and checks
|
|
|
|
|
. ./common/rc
|
|
|
|
|
. ./common/filter
|
|
|
|
|
. ./common/attr
|
|
|
|
|
. ./common/reflink
|
|
|
|
|
|
|
|
|
|
# real QA test starts here
|
|
|
|
|
_supported_os Linux
|
|
|
|
|
_require_test_dedupe
|
|
|
|
|
_require_scratch_dedupe
|
|
|
|
|
|
2016-02-10 00:33:10 -08:00
|
|
|
rm -f $seqres.full
|
2015-11-17 08:39:50 +11:00
|
|
|
|
|
|
|
|
echo "Format and mount"
|
2016-02-10 00:33:10 -08:00
|
|
|
_scratch_mkfs > $seqres.full 2>&1
|
|
|
|
|
_scratch_mount >> $seqres.full 2>&1
|
2015-11-17 08:39:50 +11:00
|
|
|
|
2016-02-08 09:27:15 +11:00
|
|
|
testdir1="$TEST_DIR/test-$seq"
|
2016-02-10 00:33:10 -08:00
|
|
|
rm -rf $testdir1
|
|
|
|
|
mkdir $testdir1
|
2015-11-17 08:39:50 +11:00
|
|
|
|
2016-02-08 09:27:15 +11:00
|
|
|
testdir2=$SCRATCH_MNT/test-$seq
|
2016-02-10 00:33:10 -08:00
|
|
|
mkdir $testdir2
|
2015-11-17 08:39:50 +11:00
|
|
|
|
|
|
|
|
echo "Create the original files"
|
2017-01-04 17:04:48 -08:00
|
|
|
blksz="$(_get_block_size $testdir1)"
|
2016-02-08 09:27:15 +11:00
|
|
|
blks=1000
|
2016-02-08 09:27:15 +11:00
|
|
|
margin='7%'
|
2016-02-08 09:27:15 +11:00
|
|
|
sz=$((blksz * blks))
|
|
|
|
|
free_blocks0=$(stat -f $testdir1 -c '%f')
|
|
|
|
|
nr=4
|
2016-02-10 00:33:10 -08:00
|
|
|
filesize=$((blksz * nr))
|
|
|
|
|
_pwrite_byte 0x61 0 $sz $testdir1/file1 >> $seqres.full
|
|
|
|
|
_pwrite_byte 0x61 0 $sz $testdir1/file2 >> $seqres.full
|
|
|
|
|
_pwrite_byte 0x61 0 $sz $testdir1/file3 >> $seqres.full
|
|
|
|
|
_pwrite_byte 0x61 0 $sz $testdir2/file1 >> $seqres.full
|
|
|
|
|
_pwrite_byte 0x61 0 $sz $testdir2/file2 >> $seqres.full
|
|
|
|
|
mkdir $testdir1/dir1
|
2016-02-08 09:27:15 +11:00
|
|
|
seq 1 $((2 * blksz / 250)) | while read f; do
|
2016-02-10 00:33:10 -08:00
|
|
|
touch $testdir1/dir1/$f
|
2015-11-17 08:39:50 +11:00
|
|
|
done
|
2016-02-10 00:33:10 -08:00
|
|
|
mknod $testdir1/dev1 c 1 3
|
|
|
|
|
mkfifo $testdir1/fifo1
|
2015-11-17 08:39:50 +11:00
|
|
|
sync
|
|
|
|
|
|
2015-12-21 18:08:01 +11:00
|
|
|
_filter_enotty() {
|
2016-12-30 11:34:19 +08:00
|
|
|
_filter_dedupe_error | \
|
2015-12-21 18:08:01 +11:00
|
|
|
sed -e 's/Inappropriate ioctl for device/Invalid argument/g'
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
_filter_eperm() {
|
2016-12-30 11:34:19 +08:00
|
|
|
_filter_dedupe_error | \
|
2015-12-21 18:08:01 +11:00
|
|
|
sed -e 's/Permission denied/Invalid argument/g'
|
|
|
|
|
}
|
|
|
|
|
|
2015-11-17 08:39:50 +11:00
|
|
|
echo "Try cross-device dedupe"
|
2016-12-30 11:34:19 +08:00
|
|
|
_dedupe_range $testdir1/file1 0 $testdir2/file1 0 $blksz \
|
|
|
|
|
2>&1 | _filter_dedupe_error
|
2015-11-17 08:39:50 +11:00
|
|
|
|
|
|
|
|
echo "Try unaligned dedupe"
|
2016-12-30 11:34:19 +08:00
|
|
|
_dedupe_range $testdir1/file1 37 $testdir1/file1 59 23 \
|
|
|
|
|
2>&1 | _filter_dedupe_error
|
2015-11-17 08:39:50 +11:00
|
|
|
|
|
|
|
|
echo "Try overlapping dedupe"
|
2016-12-30 11:34:19 +08:00
|
|
|
_dedupe_range $testdir1/file1 0 $testdir1/file1 1 $((blksz * 2)) \
|
|
|
|
|
2>&1 | _filter_dedupe_error
|
2015-11-17 08:39:50 +11:00
|
|
|
|
2016-02-19 10:43:04 +11:00
|
|
|
echo "Try dedupe from past EOF"
|
2016-12-30 11:34:19 +08:00
|
|
|
_dedupe_range $testdir1/file1 $(( (blks + 10) * blksz)) $testdir1/file1 0 $blksz \
|
|
|
|
|
2>&1 | _filter_dedupe_error
|
2015-11-17 08:39:50 +11:00
|
|
|
|
2016-02-19 10:43:04 +11:00
|
|
|
echo "Try dedupe to past EOF, destination offset beyond EOF"
|
2016-12-30 11:34:19 +08:00
|
|
|
_dedupe_range $testdir1/file1 0 $testdir1/file1 $(( (blks + 10) * blksz)) $blksz \
|
|
|
|
|
2>&1 | _filter_dedupe_error
|
2016-02-19 10:43:04 +11:00
|
|
|
|
|
|
|
|
echo "Try dedupe to past EOF, destination offset behind EOF"
|
2016-12-30 11:34:19 +08:00
|
|
|
_dedupe_range $testdir1/file1 0 $testdir1/file1 $(( (blks - 1) * blksz)) $((blksz * 2)) \
|
|
|
|
|
2>&1 | _filter_dedupe_error
|
2016-02-19 10:43:04 +11:00
|
|
|
|
2015-11-17 08:39:50 +11:00
|
|
|
echo "Try to dedupe a dir"
|
2016-12-30 11:34:19 +08:00
|
|
|
_dedupe_range $testdir1/dir1 0 $testdir1/file2 0 $blksz 2>&1 | _filter_dedupe_error
|
2015-11-17 08:39:50 +11:00
|
|
|
|
|
|
|
|
echo "Try to dedupe a device"
|
2016-02-10 00:33:10 -08:00
|
|
|
_dedupe_range $testdir1/dev1 0 $testdir1/file2 0 $blksz 2>&1 | _filter_enotty
|
2015-11-17 08:39:50 +11:00
|
|
|
|
|
|
|
|
echo "Try to dedupe to a dir"
|
2016-12-30 11:34:19 +08:00
|
|
|
_dedupe_range $testdir1/file1 0 $testdir1/dir1 0 $blksz \
|
|
|
|
|
2>&1 | _filter_test_dir | _filter_dedupe_error
|
2015-11-17 08:39:50 +11:00
|
|
|
|
|
|
|
|
echo "Try to dedupe to a device"
|
2016-02-10 00:33:10 -08:00
|
|
|
_dedupe_range $testdir1/file1 0 $testdir1/dev1 0 $blksz 2>&1 | _filter_eperm
|
2015-11-17 08:39:50 +11:00
|
|
|
|
|
|
|
|
echo "Try to dedupe to a fifo"
|
2016-02-10 00:33:10 -08:00
|
|
|
_dedupe_range $testdir1/file1 0 $testdir1/fifo1 0 $blksz -n 2>&1 | _filter_eperm
|
2015-11-17 08:39:50 +11:00
|
|
|
|
|
|
|
|
echo "Try to dedupe an append-only file"
|
2016-12-30 11:34:19 +08:00
|
|
|
_dedupe_range $testdir1/file1 0 $testdir1/file3 0 $blksz -a \
|
|
|
|
|
2>&1 >> $seqres.full | _filter_dedupe_error
|
2015-11-17 08:39:50 +11:00
|
|
|
|
|
|
|
|
echo "Dedupe two files"
|
2016-02-10 00:33:10 -08:00
|
|
|
_dedupe_range $testdir1/file1 0 $testdir1/file2 0 $blksz >> $seqres.full
|
|
|
|
|
_dedupe_range $testdir2/file1 0 $testdir2/file2 0 $blksz >> $seqres.full
|
2015-11-17 08:39:50 +11:00
|
|
|
|
|
|
|
|
# success, all done
|
|
|
|
|
status=0
|
|
|
|
|
exit
|