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 _begin_fstest auto quick
13 # Import common functions.
16 # real QA test starts here
20 _require_filefrag_options "es"
22 testfile="$SCRATCH_MNT/$seq-testfile"
24 # Use filefrag -B option to force the use of the older FIBMAP ioctl instead of
25 # the FIEMAP ioctl. Then verify if there's map overlap.
28 # record details in .full file
29 ${FILEFRAG_PROG} -Bes -v $testfile >> $seqres.full
31 # Due to physical things can't be golden image, so only output logical
33 ${FILEFRAG_PROG} -Be $testfile | _filter_filefrag | \
34 cut -d# -f1-2 > $tmp.filefrag
36 # Verify there's no physical address overlay
40 # create a lines array of the form begin#end offsets
44 lines[i++]=begin"#"end
49 # Dont check i-th line against itself
53 split(lines[i],i_line,"#")
54 split(lines[j],j_line,"#")
59 # Verify there is not:
65 if (! (v1 >= e2 || v2 <= e1))
66 print "find physical addr overlap " lines[i] " vs " lines[j]
73 _scratch_mkfs > $seqres.full 2>&1
77 echo "== FIBMAP on empty file =="
78 $XFS_IO_PROG -f -c "truncate 0" $testfile > /dev/null
81 echo "== FIBMAP on sparse file =="
82 $XFS_IO_PROG -f -t -c "pwrite -S 0xaa 0 1m" \
83 -c "pwrite -S 0xaa 2m 1m" \
84 -c "pwrite -S 0xaa 4m 1m" \