2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2014, Oracle and/or its affiliates. All Rights Reserved.
7 # Tests file clone functionality of btrfs ("reflinks"):
9 # - Reflink the reflinked file
10 # - Modify the original file
11 # - Modify the reflinked file
14 _begin_fstest auto quick clone
16 # Override the default cleanup function.
23 # Import common functions.
27 # real QA test starts here
30 _require_xfs_io_command "fiemap"
34 testdir1=$TEST_DIR/test-$seq
39 for F in original copy1 copy2
41 md5sum $testdir1/$F | _filter_test_dir
45 echo "Create the original file and reflink to copy1, copy2"
46 $XFS_IO_PROG -f -c 'pwrite -S 0x61 0 9000' $testdir1/original \
48 cp --reflink $testdir1/original $testdir1/copy1
49 cp --reflink $testdir1/copy1 $testdir1/copy2
50 _verify_reflink $testdir1/original $testdir1/copy1
51 _verify_reflink $testdir1/original $testdir1/copy2
52 echo "Original md5sums:"
55 echo "Overwrite original file with new data"
56 $XFS_IO_PROG -c 'pwrite -S 0x62 0 9000' $testdir1/original \
58 echo "md5sums after overwriting original:"
61 echo "Overwrite copy1 with different new data"
62 $XFS_IO_PROG -c 'pwrite -S 0x63 0 9000' $testdir1/copy1 \
64 echo "md5sums after overwriting copy1:"