2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2008 Silicon Graphics, Inc. All Rights Reserved.
7 # This test uses xfs_io to unreserve space in a file at various different
8 # offsets and sizes. The script then verifies the holes are in the correct
15 seqres=$RESULT_DIR/$seq
16 echo "QA output created by $seq"
20 status=0 # success is the default!
23 # get standard environment, filters and checks
27 # real QA test starts here
32 _scratch_mkfs_xfs >/dev/null 2>&1
35 fsblocksize=$(_get_file_block_size $SCRATCH_MNT)
37 #This is the list of holes to punch in the file limited to $filesize
38 #NOTE holes cannot overlap or this script will fail.
39 holes="$fsblocksize:$fsblocksize \
40 $(($fsblocksize * 74)):$fsblocksize \
41 $(($fsblocksize * 256)):$(($fsblocksize / 8)) \
42 $(echo scale=0\;$fsblocksize \* 256 \+ $fsblocksize \* 3 \/ 4 | bc):$(($fsblocksize * 2)) \
43 $(echo scale=0\;$fsblocksize \* 260 \+ $fsblocksize \* 1 \/ 4 | bc):$(($fsblocksize * 2)) \
44 $(($fsblocksize * 265)):$(echo scale=0\;$fsblocksize \+ $fsblocksize \* 3 \/ 4 | bc)"
47 filesize=$(($fsblocksize * 2560))
48 #Name of file to perform the test on
51 $XFS_IO_PROG -f -c "pwrite 0 $(($fsblocksize * 2560))" $SCRATCH_MNT/$filename >> $seqres.full 2>&1
53 # run DMAPI test using verbose output
54 echo Punching holes in file
55 echo Punching holes in file >> $seqres.full
57 echo $XFS_IO_PROG -c "unresvsp `echo $i |$SED_PROG 's/:/ /g'`" $SCRATCH_MNT/$filename >> $seqres.full
58 $XFS_IO_PROG -c "unresvsp `echo $i |$SED_PROG 's/:/ /g'`" $SCRATCH_MNT/$filename ;
61 echo Verifying holes are in the correct spots:
63 xfs_bmap=`xfs_bmap $SCRATCH_MNT/$filename`
64 xfs_bmap $SCRATCH_MNT/$filename >> $seqres.full
66 holeStart=$[`echo $i|$SED_PROG 's/:/ /g'|awk '{print $1}'`];
67 holeEnd=$[`echo $i|$SED_PROG 's/:/ /g'|awk '{print $2}'`];
69 #Round hole size down to a multiple of $fsblocksize
70 holeEnd=$[(($holeStart+$holeEnd)/$fsblocksize)*$fsblocksize]
72 #Round hole start up to a multiple of $fsblocksize
73 if [ $[$holeStart % $fsblocksize] -gt 0 ] ; then
74 holeStart=$[($holeStart/$fsblocksize +1) * $fsblocksize]
76 #xfs_bmap prints holes in the following format
78 bmap="\[$[$holeStart/512]..$[($holeEnd/512) -1]\]";
79 echo $bmap >> $seqres.full
80 if [ $holeEnd == $holeStart ] ; then
81 continue #there is no hole
83 if ! echo $xfs_bmap|grep -q $bmap; then
84 echo Offset $holeStart to $holeEnd basic blocks failed;
88 if [ $status == 0 ] ; then
89 echo Test $seq Passed.