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 seqres=$RESULT_DIR/$seq
15 echo "QA output created by $seq"
19 status=1 # failure is the default!
20 trap "_cleanup; exit \$status" 0 1 2 3 15
28 # get standard environment, filters and checks
33 # real QA test starts here
36 _require_xfs_io_command "fiemap"
40 testdir1=$TEST_DIR/test-$seq
45 for F in original copy1 copy2
47 md5sum $testdir1/$F | _filter_test_dir
53 echo "Create the original file and reflink to copy1, copy2"
54 $XFS_IO_PROG -f -c 'pwrite -S 0x61 0 9000' $testdir1/original \
56 cp --reflink $testdir1/original $testdir1/copy1
57 cp --reflink $testdir1/copy1 $testdir1/copy2
58 _verify_reflink $testdir1/original $testdir1/copy1
59 _verify_reflink $testdir1/original $testdir1/copy2
60 echo "Original md5sums:"
63 echo "Overwrite original file with new data"
64 $XFS_IO_PROG -c 'pwrite -S 0x62 0 9000' $testdir1/original \
66 echo "md5sums after overwriting original:"
69 echo "Overwrite copy1 with different new data"
70 $XFS_IO_PROG -c 'pwrite -S 0x63 0 9000' $testdir1/copy1 \
72 echo "md5sums after overwriting copy1:"