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
31 _scratch_mkfs_xfs >/dev/null 2>&1
34 fsblocksize=$(_get_file_block_size $SCRATCH_MNT)
36 #This is the list of holes to punch in the file limited to $filesize
37 #NOTE holes cannot overlap or this script will fail.
38 holes="$fsblocksize:$fsblocksize \
39 $(($fsblocksize * 74)):$fsblocksize \
40 $(($fsblocksize * 256)):$(($fsblocksize / 8)) \
41 $(echo scale=0\;$fsblocksize \* 256 \+ $fsblocksize \* 3 \/ 4 | bc):$(($fsblocksize * 2)) \
42 $(echo scale=0\;$fsblocksize \* 260 \+ $fsblocksize \* 1 \/ 4 | bc):$(($fsblocksize * 2)) \
43 $(($fsblocksize * 265)):$(echo scale=0\;$fsblocksize \+ $fsblocksize \* 3 \/ 4 | bc)"
46 filesize=$(($fsblocksize * 2560))
47 #Name of file to perform the test on
50 $XFS_IO_PROG -f -c "pwrite 0 $(($fsblocksize * 2560))" $SCRATCH_MNT/$filename >> $seqres.full 2>&1
52 # run DMAPI test using verbose output
53 echo Punching holes in file
54 echo Punching holes in file >> $seqres.full
56 echo $XFS_IO_PROG -c "unresvsp `echo $i |$SED_PROG 's/:/ /g'`" $SCRATCH_MNT/$filename >> $seqres.full
57 $XFS_IO_PROG -c "unresvsp `echo $i |$SED_PROG 's/:/ /g'`" $SCRATCH_MNT/$filename ;
60 echo Verifying holes are in the correct spots:
62 xfs_bmap=`xfs_bmap $SCRATCH_MNT/$filename`
63 xfs_bmap $SCRATCH_MNT/$filename >> $seqres.full
65 holeStart=$[`echo $i|$SED_PROG 's/:/ /g'|awk '{print $1}'`];
66 holeEnd=$[`echo $i|$SED_PROG 's/:/ /g'|awk '{print $2}'`];
68 #Round hole size down to a multiple of $fsblocksize
69 holeEnd=$[(($holeStart+$holeEnd)/$fsblocksize)*$fsblocksize]
71 #Round hole start up to a multiple of $fsblocksize
72 if [ $[$holeStart % $fsblocksize] -gt 0 ] ; then
73 holeStart=$[($holeStart/$fsblocksize +1) * $fsblocksize]
75 #xfs_bmap prints holes in the following format
77 bmap="\[$[$holeStart/512]..$[($holeEnd/512) -1]\]";
78 echo $bmap >> $seqres.full
79 if [ $holeEnd == $holeStart ] ; then
80 continue #there is no hole
82 if ! echo $xfs_bmap|grep -q $bmap; then
83 echo Offset $holeStart to $holeEnd basic blocks failed;
87 if [ $status == 0 ] ; then
88 echo Test $seq Passed.