2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2014, Oracle and/or its affiliates. All Rights Reserved.
7 # Moving and deleting cloned ("reflinked") files on btrfs:
8 # - Create a file and a reflink
9 # - Move both to a directory
10 # - Delete the original (moved) file, check that the copy still exists.
13 _begin_fstest auto quick clone
15 # Override the default cleanup function.
22 # Import common functions.
26 # real QA test starts here
29 _require_xfs_io_command "fiemap"
33 testdir1=$TEST_DIR/test-$seq
37 echo "Create the original files and reflink dirs"
38 $XFS_IO_PROG -f -c 'pwrite -S 0x61 0 9000' $testdir1/original \
40 cp --reflink $testdir1/original $testdir1/copy
42 _verify_reflink $testdir1/original $testdir1/copy
44 echo "Move orig & reflink copy to subdir and md5sum:"
45 mkdir $testdir1/subdir
46 mv $testdir1/original $testdir1/subdir/original_moved
47 mv $testdir1/copy $testdir1/subdir/copy_moved
48 _verify_reflink $testdir1/subdir/original_moved \
49 $testdir1/subdir/copy_moved
51 md5sum $testdir1/subdir/original_moved | _filter_test_dir
52 md5sum $testdir1/subdir/copy_moved | _filter_test_dir
54 echo "remove orig from subdir and md5sum reflink copy:"
55 rm $testdir1/subdir/original_moved
56 md5sum $testdir1/subdir/copy_moved | _filter_test_dir
57 rm -rf $testdir1/subdir