2014-01-20 13:56:36 +11:00
|
|
|
#! /bin/bash
|
2018-06-09 11:35:42 +10:00
|
|
|
# SPDX-License-Identifier: GPL-2.0
|
|
|
|
|
# Copyright (c) 2014, Oracle and/or its affiliates. All Rights Reserved.
|
|
|
|
|
#
|
2015-11-17 08:39:09 +11:00
|
|
|
# FS QA Test No. 115
|
2014-01-20 13:56:36 +11:00
|
|
|
#
|
|
|
|
|
# Moving and deleting cloned ("reflinked") files on btrfs:
|
|
|
|
|
# - Create a file and a reflink
|
|
|
|
|
# - Move both to a directory
|
|
|
|
|
# - Delete the original (moved) file, check that the copy still exists.
|
|
|
|
|
#
|
|
|
|
|
seq=`basename $0`
|
2014-01-24 12:06:45 +11:00
|
|
|
seqres=$RESULT_DIR/$seq
|
2014-01-20 13:56:36 +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 -f $tmp.* $testdir
|
2014-01-20 13:56:36 +11:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
# get standard environment, filters and checks
|
|
|
|
|
. ./common/rc
|
|
|
|
|
. ./common/filter
|
2015-11-17 08:39:17 +11:00
|
|
|
. ./common/reflink
|
2014-01-20 13:56:36 +11:00
|
|
|
|
|
|
|
|
# real QA test starts here
|
2015-11-17 08:39:17 +11:00
|
|
|
_require_test_reflink
|
2014-01-20 13:56:36 +11:00
|
|
|
_supported_os Linux
|
|
|
|
|
|
2014-04-28 10:55:12 +10:00
|
|
|
_require_xfs_io_command "fiemap"
|
2014-01-20 13:56:36 +11:00
|
|
|
_require_cp_reflink
|
2014-08-13 11:08:41 +10:00
|
|
|
_require_test
|
2014-01-20 13:56:36 +11:00
|
|
|
|
|
|
|
|
rm -f $seqres.full
|
|
|
|
|
|
2016-02-08 09:27:15 +11:00
|
|
|
testdir1=$TEST_DIR/test-$seq
|
|
|
|
|
rm -rf $testdir1
|
|
|
|
|
mkdir $testdir1
|
2014-01-20 13:56:36 +11:00
|
|
|
|
|
|
|
|
echo "Create the original files and reflink dirs"
|
2016-02-08 09:27:15 +11:00
|
|
|
$XFS_IO_PROG -f -c 'pwrite -S 0x61 0 9000' $testdir1/original \
|
2014-01-20 13:56:36 +11:00
|
|
|
>> $seqres.full
|
2016-02-08 09:27:15 +11:00
|
|
|
cp --reflink $testdir1/original $testdir1/copy
|
2014-01-20 13:56:36 +11:00
|
|
|
|
2016-02-08 09:27:15 +11:00
|
|
|
_verify_reflink $testdir1/original $testdir1/copy
|
2014-01-20 13:56:36 +11:00
|
|
|
|
|
|
|
|
echo "Move orig & reflink copy to subdir and md5sum:"
|
2016-02-08 09:27:15 +11:00
|
|
|
mkdir $testdir1/subdir
|
|
|
|
|
mv $testdir1/original $testdir1/subdir/original_moved
|
|
|
|
|
mv $testdir1/copy $testdir1/subdir/copy_moved
|
|
|
|
|
_verify_reflink $testdir1/subdir/original_moved \
|
|
|
|
|
$testdir1/subdir/copy_moved
|
2014-01-20 13:56:36 +11:00
|
|
|
|
2016-02-08 09:27:15 +11:00
|
|
|
md5sum $testdir1/subdir/original_moved | _filter_test_dir
|
|
|
|
|
md5sum $testdir1/subdir/copy_moved | _filter_test_dir
|
2014-01-20 13:56:36 +11:00
|
|
|
|
|
|
|
|
echo "remove orig from subdir and md5sum reflink copy:"
|
2016-02-08 09:27:15 +11:00
|
|
|
rm $testdir1/subdir/original_moved
|
|
|
|
|
md5sum $testdir1/subdir/copy_moved | _filter_test_dir
|
|
|
|
|
rm -rf $testdir1/subdir
|
2014-01-20 13:56:36 +11:00
|
|
|
|
|
|
|
|
# success, all done
|
|
|
|
|
status=0
|
|
|
|
|
exit
|