4 # Moving and deleting cloned ("reflinked") files on btrfs:
5 # - Create a file and a reflink
6 # - Move both to a directory
7 # - Delete the original (moved) file, check that the copy still exists.
9 #-----------------------------------------------------------------------
10 # Copyright (c) 2014, Oracle and/or its affiliates. All Rights Reserved.
12 # This program is free software; you can redistribute it and/or
13 # modify it under the terms of the GNU General Public License as
14 # published by the Free Software Foundation.
16 # This program is distributed in the hope that it would be useful,
17 # but WITHOUT ANY WARRANTY; without even the implied warranty of
18 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 # GNU General Public License for more details.
21 # You should have received a copy of the GNU General Public License
22 # along with this program; if not, write the Free Software Foundation,
23 # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
24 #-----------------------------------------------------------------------
27 seqres=$RESULT_DIR/$seq
28 echo "QA output created by $seq"
32 status=1 # failure is the default!
33 trap "_cleanup; exit \$status" 0 1 2 3 15
41 # get standard environment, filters and checks
46 # real QA test starts here
50 _require_xfs_io_command "fiemap"
56 testdir1=$TEST_DIR/test-$seq
60 echo "Create the original files and reflink dirs"
61 $XFS_IO_PROG -f -c 'pwrite -S 0x61 0 9000' $testdir1/original \
63 cp --reflink $testdir1/original $testdir1/copy
65 _verify_reflink $testdir1/original $testdir1/copy
67 echo "Move orig & reflink copy to subdir and md5sum:"
68 mkdir $testdir1/subdir
69 mv $testdir1/original $testdir1/subdir/original_moved
70 mv $testdir1/copy $testdir1/subdir/copy_moved
71 _verify_reflink $testdir1/subdir/original_moved \
72 $testdir1/subdir/copy_moved
74 md5sum $testdir1/subdir/original_moved | _filter_test_dir
75 md5sum $testdir1/subdir/copy_moved | _filter_test_dir
77 echo "remove orig from subdir and md5sum reflink copy:"
78 rm $testdir1/subdir/original_moved
79 md5sum $testdir1/subdir/copy_moved | _filter_test_dir
80 rm -rf $testdir1/subdir