2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2016 Fujitsu. All Rights Reserved.
7 # Check if fiemap ioctl returns correct SHARED flag on reflinked file
8 # before and after sync the fs
10 # Btrfs has a bug in checking shared extent, which can only handle metadata
11 # already committed to disk, but not delayed extent tree modification.
12 # This caused SHARED flag only occurs after sync.
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
35 # remove previous $seqres.full before test
38 # real QA test starts here
40 # Modify as appropriate.
43 _require_scratch_reflink
44 _require_xfs_io_command "fiemap"
46 _scratch_mkfs > /dev/null 2>&1
50 file1="$SCRATCH_MNT/file1"
51 file2="$SCRATCH_MNT/file2"
53 # write the initial file
54 _pwrite_byte 0xcdcdcdcd 0 $blocksize $file1 | _filter_xfs_io
56 # reflink initial file
57 _reflink_range $file1 0 $file2 0 $blocksize | _filter_xfs_io
59 # check their fiemap to make sure it's correct
61 echo "$file1" | _filter_scratch
62 $XFS_IO_PROG -c "fiemap -v" $file1 | _filter_fiemap_flags
63 echo "$file2" | _filter_scratch
64 $XFS_IO_PROG -c "fiemap -v" $file2 | _filter_fiemap_flags
66 # sync and recheck, to make sure the fiemap doesn't change just
70 echo "$file1" | _filter_scratch
71 $XFS_IO_PROG -c "fiemap -v" $file1 | _filter_fiemap_flags
72 echo "$file2" | _filter_scratch
73 $XFS_IO_PROG -c "fiemap -v" $file2 | _filter_fiemap_flags