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
45 # real QA test starts here
49 _require_xfs_io_command "fiemap"
55 TESTDIR1=$TEST_DIR/test-$seq
59 echo "Create the original files and reflink dirs"
60 $XFS_IO_PROG -f -c 'pwrite -S 0x61 0 9000' $TESTDIR1/original \
62 cp --reflink $TESTDIR1/original $TESTDIR1/copy
64 _verify_reflink $TESTDIR1/original $TESTDIR1/copy
66 echo "Move orig & reflink copy to subdir and md5sum:"
67 mkdir $TESTDIR1/subdir
68 mv $TESTDIR1/original $TESTDIR1/subdir/original_moved
69 mv $TESTDIR1/copy $TESTDIR1/subdir/copy_moved
70 _verify_reflink $TESTDIR1/subdir/original_moved \
71 $TESTDIR1/subdir/copy_moved
73 md5sum $TESTDIR1/subdir/original_moved | _filter_test_dir
74 md5sum $TESTDIR1/subdir/copy_moved | _filter_test_dir
76 echo "remove orig from subdir and md5sum reflink copy:"
77 rm $TESTDIR1/subdir/original_moved
78 md5sum $TESTDIR1/subdir/copy_moved | _filter_test_dir
79 rm -rf $TESTDIR1/subdir