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
13 #This is the list of holes to punch in the file limited to $filesize
14 #NOTE holes cannot overlap or this script will fail.
15 holes="4096:4096 303104:4096 1048576:512 1051648:8192 1065984:8192 1085440:7168"
18 #Name of file to perform the test on
22 seqres=$RESULT_DIR/$seq
23 echo "QA output created by $seq"
27 status=0 # success is the default!
30 # get standard environment, filters and checks
34 # real QA test starts here
39 _scratch_mkfs_xfs >/dev/null 2>&1
41 fsblocksize=`$XFS_INFO_PROG $SCRATCH_MNT|sed 's/=/ /g'|awk '/^data / { print $3 }'`
43 dd if=/dev/zero of=$SCRATCH_MNT/$filename bs=1024k count=10 >> $seqres.full 2>&1
45 # run DMAPI test using verbose output
46 echo Punching holes in file
47 echo Punching holes in file >> $seqres.full
49 echo $XFS_IO_PROG -c "unresvsp `echo $i |$SED_PROG 's/:/ /g'`" $SCRATCH_MNT/$filename >> $seqres.full
50 $XFS_IO_PROG -c "unresvsp `echo $i |$SED_PROG 's/:/ /g'`" $SCRATCH_MNT/$filename ;
53 echo Verifying holes are in the correct spots:
55 xfs_bmap=`xfs_bmap $SCRATCH_MNT/$filename`
56 xfs_bmap $SCRATCH_MNT/$filename >> $seqres.full
58 holeStart=$[`echo $i|$SED_PROG 's/:/ /g'|awk '{print $1}'`];
59 holeEnd=$[`echo $i|$SED_PROG 's/:/ /g'|awk '{print $2}'`];
61 #Round hole size down to a multiple of $fsblocksize
62 holeEnd=$[(($holeStart+$holeEnd)/$fsblocksize)*$fsblocksize]
64 #Round hole start up to a multiple of $fsblocksize
65 if [ $[$holeStart % $fsblocksize] -gt 0 ] ; then
66 holeStart=$[($holeStart/$fsblocksize +1) * $fsblocksize]
68 #xfs_bmap prints holes in the following format
70 bmap="\[$[$holeStart/512]..$[($holeEnd/512) -1]\]";
71 echo $bmap >> $seqres.full
72 if [ $holeEnd == $holeStart ] ; then
73 continue #there is no hole
75 if ! echo $xfs_bmap|grep -q $bmap; then
76 echo Offset $holeStart to $holeEnd basic blocks failed;
80 if [ $status == 0 ] ; then
81 echo Test $seq Passed.