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 seqres=$RESULT_DIR/$seq
14 echo "QA output created by $seq"
18 status=1 # failure is the default!
19 trap "_cleanup; exit \$status" 0 1 2 3 15
27 # get standard environment, filters and checks
32 # real QA test starts here
35 _require_xfs_io_command "fiemap"
41 testdir1=$TEST_DIR/test-$seq
45 echo "Create the original files and reflink dirs"
46 $XFS_IO_PROG -f -c 'pwrite -S 0x61 0 9000' $testdir1/original \
48 cp --reflink $testdir1/original $testdir1/copy
50 _verify_reflink $testdir1/original $testdir1/copy
52 echo "Move orig & reflink copy to subdir and md5sum:"
53 mkdir $testdir1/subdir
54 mv $testdir1/original $testdir1/subdir/original_moved
55 mv $testdir1/copy $testdir1/subdir/copy_moved
56 _verify_reflink $testdir1/subdir/original_moved \
57 $testdir1/subdir/copy_moved
59 md5sum $testdir1/subdir/original_moved | _filter_test_dir
60 md5sum $testdir1/subdir/copy_moved | _filter_test_dir
62 echo "remove orig from subdir and md5sum reflink copy:"
63 rm $testdir1/subdir/original_moved
64 md5sum $testdir1/subdir/copy_moved | _filter_test_dir
65 rm -rf $testdir1/subdir