2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2018 Red Hat Inc. All Rights Reserved.
7 # Verify if there's physical address overlap returned by FIBMAP, cover:
8 # 79b3dbe4adb3 fs: fix iomap_bmap position calculation
11 seqres=$RESULT_DIR/$seq
12 echo "QA output created by $seq"
16 status=1 # failure is the default!
17 trap "_cleanup; exit \$status" 0 1 2 3 15
25 # get standard environment, filters and checks
29 # remove previous $seqres.full before test
32 # real QA test starts here
36 _require_filefrag_options "es"
38 testfile="$SCRATCH_MNT/$seq-testfile"
40 # Use filefrag -B option to force the use of the older FIBMAP ioctl instead of
41 # the FIEMAP ioctl. Then verify if there's map overlap.
44 # record details in .full file
45 ${FILEFRAG_PROG} -Bes -v $testfile >> $seqres.full
47 # Due to physical things can't be golden image, so only output logical
49 ${FILEFRAG_PROG} -Be $testfile | _filter_filefrag | \
50 cut -d# -f1-2 > $tmp.filefrag
52 # Verify there's no physical address overlay
56 # create a lines array of the form begin#end offsets
60 lines[i++]=begin"#"end
65 # Dont check i-th line against itself
69 split(lines[i],i_line,"#")
70 split(lines[j],j_line,"#")
75 # Verify there is not:
81 if (! (v1 >= e2 || v2 <= e1))
82 print "find physical addr overlap " lines[i] " vs " lines[j]
89 _scratch_mkfs > $seqres.full 2>&1
93 echo "== FIBMAP on empty file =="
94 $XFS_IO_PROG -f -c "truncate 0" $testfile > /dev/null
97 echo "== FIBMAP on sparse file =="
98 $XFS_IO_PROG -f -t -c "pwrite -S 0xaa 0 1m" \
99 -c "pwrite -S 0xaa 2m 1m" \
100 -c "pwrite -S 0xaa 4m 1m" \
101 $testfile > /dev/null