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. 160
|
|
|
|
|
#
|
|
|
|
|
# Check that we can't dedupe immutable files
|
|
|
|
|
#
|
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
|
2018-05-06 09:36:08 +03:00
|
|
|
_require_chattr i
|
2015-11-17 08:39:50 +11:00
|
|
|
_require_test_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-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
|
|
|
|
|
|
|
|
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
|
2015-11-17 08:39:50 +11:00
|
|
|
sync
|
|
|
|
|
|
2016-08-25 16:28:44 -07:00
|
|
|
do_filter_output()
|
|
|
|
|
{
|
|
|
|
|
_filter_test_dir | sed -e 's/Operation not permitted/Permission denied/g'
|
|
|
|
|
}
|
|
|
|
|
|
2015-11-17 08:39:50 +11:00
|
|
|
echo "Try dedupe on immutable files"
|
2016-02-08 09:27:15 +11:00
|
|
|
$CHATTR_PROG +i $testdir1/file1 $testdir1/file2
|
2016-08-25 16:28:44 -07:00
|
|
|
_dedupe_range $testdir1/file1 0 $testdir1/file2 0 $blksz 2>&1 | do_filter_output
|
2016-02-08 09:27:15 +11:00
|
|
|
$CHATTR_PROG -i $testdir1/file1 $testdir1/file2
|
2015-11-17 08:39:50 +11:00
|
|
|
|
|
|
|
|
# success, all done
|
|
|
|
|
status=0
|
|
|
|
|
exit
|