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
37 _require_xfs_io_command "fiemap"
41 testdir1=$TEST_DIR/test-$seq
46 for F in original/file1 original/subdir/file2 \
47 copy1/file1 copy1/subdir/file2 \
48 copy2/file1 copy2/subdir/file2
50 md5sum $testdir1/$F | _filter_test_dir
56 mkdir $testdir1/original
57 mkdir $testdir1/original/subdir
59 echo "Create the original files and reflink dirs"
60 $XFS_IO_PROG -f -c 'pwrite -S 0x61 0 9000' $testdir1/original/file1 \
62 $XFS_IO_PROG -f -c 'pwrite -S 0x62 0 11000' \
63 $testdir1/original/subdir/file2 >> $seqres.full 2>&1
64 cp --recursive --reflink $testdir1/original $testdir1/copy1
65 cp --recursive --reflink $testdir1/copy1 $testdir1/copy2
67 _verify_reflink $testdir1/original/file1 $testdir1/copy1/file1
68 _verify_reflink $testdir1/original/subdir/file2 \
69 $testdir1/copy1/subdir/file2
70 _verify_reflink $testdir1/original/file1 $testdir1/copy2/file1
71 _verify_reflink $testdir1/original/subdir/file2 \
72 $testdir1/copy2/subdir/file2
74 echo "Original md5sums:"
77 echo "Overwrite original/file1 and original/subdir/file2 with new data"
78 $XFS_IO_PROG -c 'pwrite -S 0x63 0 13000' $testdir1/original/file1 \
80 $XFS_IO_PROG -c 'pwrite -S 0x64 5000 1000' \
81 $testdir1/original/subdir/file2 >> $seqres.full 2>&1
85 echo "Overwrite copy1/file1 and copy1/subdir/file2 with new data"
86 $XFS_IO_PROG -c 'pwrite -S 0x65 0 9000' $testdir1/copy1/file1 \
88 $XFS_IO_PROG -c 'pwrite -S 0x66 5000 25000' \
89 $testdir1/copy1/subdir/file2 >> $seqres.full 2>&1