Update xfsprogs to latest kernel headers and functions
[xfstests-dev.git] / 190
1 #! /bin/sh
2 # FSQA Test No. 190
3 #
4 # This test uses xfs_io to unreserve space in a file at various different
5 # offsets and sizes. The script then verifies the holes are in the correct
6 # location.
7 #
8 # PV 985792
9 #-----------------------------------------------------------------------
10 #  Copyright (c) 2008 Silicon Graphics, Inc.  All Rights Reserved.
11 #-----------------------------------------------------------------------
12 #
13 # creator
14 owner=pleckie@sgi.com
15
16 #This is the list of holes to punch in the file limited to $filesize
17 #NOTE holes cannot overlap or this script will fail.
18 holes="4096:4096 303104:4096 1048576:512 1051648:8192 1065984:8192 1085440:7168"
19 #filesize in MB
20 filesize=10
21 #Name of file to perform the test on
22 filename=test-190
23
24 seq=`basename $0`
25 echo "QA output created by $seq"
26
27 here=`pwd`
28 tmp=/tmp/$$
29 status=0    # success is the default!
30 rm -f $seq.full
31
32 # get standard environment, filters and checks
33 . ./common.rc
34 . ./common.filter
35
36 # real QA test starts here
37 _supported_fs xfs
38 _supported_os Linux
39
40 _require_scratch
41 _scratch_mkfs_xfs >/dev/null 2>&1
42 _scratch_mount
43 fsblocksize=`xfs_info $SCRATCH_MNT|sed 's/=/ /g'|awk '/^data / { print $3 }'`
44
45 dd if=/dev/zero of=$SCRATCH_MNT/$filename bs=1024k count=10 >> $seq.full 2>&1
46
47 # run DMAPI test using verbose output
48 echo Punching holes in file
49 echo Punching holes in file >> $seq.full
50 for i in $holes ; do
51         echo xfs_io -c "unresvsp `echo $i |$SED_PROG 's/:/ /g'`" $SCRATCH_MNT/$filename >> $seq.full
52         xfs_io -c "unresvsp `echo $i |$SED_PROG 's/:/ /g'`" $SCRATCH_MNT/$filename ;
53 done
54
55 echo Verifying holes are in the correct spots:
56
57 xfs_bmap=`xfs_bmap $SCRATCH_MNT/$filename`
58 xfs_bmap $SCRATCH_MNT/$filename >> $seq.full
59 for i in $holes ; do
60         holeStart=$[`echo $i|$SED_PROG 's/:/ /g'|awk '{print $1}'`];
61         holeEnd=$[`echo $i|$SED_PROG 's/:/ /g'|awk '{print $2}'`];
62
63         #Round hole size down to a multiple of $fsblocksize
64         holeEnd=$[(($holeStart+$holeEnd)/$fsblocksize)*$fsblocksize]
65
66         #Round hole start up to a multiple of $fsblocksize
67         if [ $[$holeStart % $fsblocksize] -gt 0 ] ; then
68                 holeStart=$[($holeStart/$fsblocksize +1) * $fsblocksize]
69         fi
70         #xfs_bmap prints holes in the following format
71         #                1: [8..15]: hole
72         bmap="\[$[$holeStart/512]..$[($holeEnd/512) -1]\]";
73         echo $bmap >> $seq.full
74         if [ $holeEnd == $holeStart ] ; then
75                 continue #there is no hole
76         fi
77         if ! echo $xfs_bmap|grep -q $bmap; then
78                 echo Offset $holeStart to $holeEnd  basic blocks failed;
79                 status=1;
80         fi
81 done
82 if [ $status == 0 ] ; then
83         echo Test $seq Passed.
84 fi
85
86 exit