4 # Tests file clone functionality of btrfs ("reflinks") on directory
6 # - Create directory and subdirectory, each having one file
7 # - Create 2 recursive reflinked copies of the tree
8 # - Modify the original files
9 # - Modify one of the copies
11 #-----------------------------------------------------------------------
12 # Copyright (c) 2014, Oracle and/or its affiliates. All Rights Reserved.
14 # This program is free software; you can redistribute it and/or
15 # modify it under the terms of the GNU General Public License as
16 # published by the Free Software Foundation.
18 # This program is distributed in the hope that it would be useful,
19 # but WITHOUT ANY WARRANTY; without even the implied warranty of
20 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 # GNU General Public License for more details.
23 # You should have received a copy of the GNU General Public License
24 # along with this program; if not, write the Free Software Foundation,
25 # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
26 #-----------------------------------------------------------------------
29 seqres=$RESULT_DIR/$seq
30 echo "QA output created by $seq"
34 status=1 # failure is the default!
35 trap "_cleanup; exit \$status" 0 1 2 3 15
43 # get standard environment, filters and checks
48 # real QA test starts here
52 _require_xfs_io_command "fiemap"
56 TESTDIR1=$TEST_DIR/test-$seq
61 for F in original/file1 original/subdir/file2 \
62 copy1/file1 copy1/subdir/file2 \
63 copy2/file1 copy2/subdir/file2
65 md5sum $TESTDIR1/$F | _filter_test_dir
71 mkdir $TESTDIR1/original
72 mkdir $TESTDIR1/original/subdir
74 echo "Create the original files and reflink dirs"
75 $XFS_IO_PROG -f -c 'pwrite -S 0x61 0 9000' $TESTDIR1/original/file1 \
77 $XFS_IO_PROG -f -c 'pwrite -S 0x62 0 11000' \
78 $TESTDIR1/original/subdir/file2 >> $seqres.full 2>&1
79 cp --recursive --reflink $TESTDIR1/original $TESTDIR1/copy1
80 cp --recursive --reflink $TESTDIR1/copy1 $TESTDIR1/copy2
82 _verify_reflink $TESTDIR1/original/file1 $TESTDIR1/copy1/file1
83 _verify_reflink $TESTDIR1/original/subdir/file2 \
84 $TESTDIR1/copy1/subdir/file2
85 _verify_reflink $TESTDIR1/original/file1 $TESTDIR1/copy2/file1
86 _verify_reflink $TESTDIR1/original/subdir/file2 \
87 $TESTDIR1/copy2/subdir/file2
89 echo "Original md5sums:"
92 echo "Overwrite original/file1 and original/subdir/file2 with new data"
93 $XFS_IO_PROG -c 'pwrite -S 0x63 0 13000' $TESTDIR1/original/file1 \
95 $XFS_IO_PROG -c 'pwrite -S 0x64 5000 1000' \
96 $TESTDIR1/original/subdir/file2 >> $seqres.full 2>&1
100 echo "Overwrite copy1/file1 and copy1/subdir/file2 with new data"
101 $XFS_IO_PROG -c 'pwrite -S 0x65 0 9000' $TESTDIR1/copy1/file1 \
103 $XFS_IO_PROG -c 'pwrite -S 0x66 5000 25000' \
104 $TESTDIR1/copy1/subdir/file2 >> $seqres.full 2>&1