4 # Check if fiemap ioctl returns correct SHARED flag on reflinked file
5 # before and after sync the fs
7 # Btrfs has a bug in checking shared extent, which can only handle metadata
8 # already committed to disk, but not delayed extent tree modification.
9 # This caused SHARED flag only occurs after sync.
11 #-----------------------------------------------------------------------
12 # Copyright (c) 2016 Fujitsu. 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 #-----------------------------------------------------------------------
30 seqres=$RESULT_DIR/$seq
31 echo "QA output created by $seq"
35 status=1 # failure is the default!
36 trap "_cleanup; exit \$status" 0 1 2 3 15
44 # get standard environment, filters and checks
50 # remove previous $seqres.full before test
53 # real QA test starts here
55 # Modify as appropriate.
58 _require_scratch_reflink
61 _scratch_mkfs > /dev/null 2>&1
65 file1="$SCRATCH_MNT/file1"
66 file2="$SCRATCH_MNT/file2"
68 # write the initial file
69 _pwrite_byte 0xcdcdcdcd 0 $blocksize $file1 | _filter_xfs_io
71 # reflink initial file
72 _reflink_range $file1 0 $file2 0 $blocksize | _filter_xfs_io
74 # check their fiemap to make sure it's correct
76 echo "$file1" | _filter_scratch
77 $XFS_IO_PROG -c "fiemap -v" $file1 | _filter_fiemap_flags
78 echo "$file2" | _filter_scratch
79 $XFS_IO_PROG -c "fiemap -v" $file2 | _filter_fiemap_flags
81 # sync and recheck, to make sure the fiemap doesn't change just
85 echo "$file1" | _filter_scratch
86 $XFS_IO_PROG -c "fiemap -v" $file1 | _filter_fiemap_flags
87 echo "$file2" | _filter_scratch
88 $XFS_IO_PROG -c "fiemap -v" $file2 | _filter_fiemap_flags