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") on directory
9 # - Create directory and subdirectory, each having one file
10 # - Create 2 recursive reflinked copies of the tree
11 # - Modify the original files
12 # - Modify one of the copies
15 seqres=$RESULT_DIR/$seq
16 echo "QA output created by $seq"
20 status=1 # failure is the default!
21 trap "_cleanup; exit \$status" 0 1 2 3 15
29 # get standard environment, filters and checks
34 # real QA test starts here
38 _require_xfs_io_command "fiemap"
42 testdir1=$TEST_DIR/test-$seq
47 for F in original/file1 original/subdir/file2 \
48 copy1/file1 copy1/subdir/file2 \
49 copy2/file1 copy2/subdir/file2
51 md5sum $testdir1/$F | _filter_test_dir
57 mkdir $testdir1/original
58 mkdir $testdir1/original/subdir
60 echo "Create the original files and reflink dirs"
61 $XFS_IO_PROG -f -c 'pwrite -S 0x61 0 9000' $testdir1/original/file1 \
63 $XFS_IO_PROG -f -c 'pwrite -S 0x62 0 11000' \
64 $testdir1/original/subdir/file2 >> $seqres.full 2>&1
65 cp --recursive --reflink $testdir1/original $testdir1/copy1
66 cp --recursive --reflink $testdir1/copy1 $testdir1/copy2
68 _verify_reflink $testdir1/original/file1 $testdir1/copy1/file1
69 _verify_reflink $testdir1/original/subdir/file2 \
70 $testdir1/copy1/subdir/file2
71 _verify_reflink $testdir1/original/file1 $testdir1/copy2/file1
72 _verify_reflink $testdir1/original/subdir/file2 \
73 $testdir1/copy2/subdir/file2
75 echo "Original md5sums:"
78 echo "Overwrite original/file1 and original/subdir/file2 with new data"
79 $XFS_IO_PROG -c 'pwrite -S 0x63 0 13000' $testdir1/original/file1 \
81 $XFS_IO_PROG -c 'pwrite -S 0x64 5000 1000' \
82 $testdir1/original/subdir/file2 >> $seqres.full 2>&1
86 echo "Overwrite copy1/file1 and copy1/subdir/file2 with new data"
87 $XFS_IO_PROG -c 'pwrite -S 0x65 0 9000' $testdir1/copy1/file1 \
89 $XFS_IO_PROG -c 'pwrite -S 0x66 5000 25000' \
90 $testdir1/copy1/subdir/file2 >> $seqres.full 2>&1