2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2000-2002 Silicon Graphics, Inc. All Rights Reserved.
7 # XFS allocator test (preallocation - allocp, resvsp ,etc)
10 seqres=$RESULT_DIR/$seq
11 echo "QA output created by $seq"
15 status=1 # failure is the default!
16 trap "_cleanup; exit \$status" 0 1 2 3 15
27 if ! _scratch_mkfs_xfs >$tmp.out 2>&1
30 echo "failed to mkfs $SCRATCH_DEV"
35 if ! _try_scratch_mount
37 echo "failed to mount $SCRATCH_DEV"
42 # get standard environment, filters and checks
46 # real QA test starts here
50 _require_xfs_io_command "falloc"
54 ls -l $1 | $AWK_PROG -v bsize="$bsize" '{print "filesize = " $5 / bsize}'
59 $AWK_PROG -v bsize="$bsize" '
61 printf(" blocksize BSIZE\n")
68 offset = strtonum(off[2])
70 offset = offset / bsize
73 nr_blocks = strtonum(len[2])
75 nr_blocks = nr_blocks / bsize
77 printf(" %s %s off=%s, len=%d\n", $1, $2, offset, nr_blocks)
84 offset = strtonum(off[2])
86 offset = offset / bsize
90 nr_blocks = strtonum(len[2])
93 nr_blocks = nr_blocks / bsize
95 printf(" %s off=%s, len=%d %s\n", $1, offset, nr_blocks, $4)
102 offset = strtonum(off[2]) / bsize
104 printf(" %s off=%s\n", $1, offset)
109 /\[[0-9]+,[0-9]+\]:/ {
110 printf(" %s BLOCKRANGE\n", $1)
124 out=$SCRATCH_MNT/$$.tmp
126 # This isn't really related to fs block size, it's just what
127 # alloc uses for the "block" unit in it's input parameters...
128 # However, xfs_alloc_file_space() rounds up allocation
129 # request by the filesystem's block size.
130 bsize=$(_get_file_block_size $SCRATCH_MNT)
132 # since we're using a clean FS here, we make some assumptions
133 # about availability of contiguous blocks
135 # also interesting to note is that ALLOC == FREE. seriously.
136 # the _length is ignored_ in irix. the file is allocated up
137 # to the specified offset, and zero filled if previously
138 # unallocated. the file is truncated at the specified point.
140 echo "*** test 1 - reservations cleared on O_TRUNC"
142 cat <<EOF | $here/src/alloc -n -b $bsize -f $out | _block_filter
148 cat <<EOF | $here/src/alloc -n -b $bsize -f $out -t | _block_filter
153 echo "*** test 2 - reserve & filesize"
155 cat <<EOF | $here/src/alloc -n -b $bsize -f $out | _block_filter
161 echo "*** test 3 - alloc & filesize"
163 cat <<EOF | $here/src/alloc -n -b $bsize -f $out | _block_filter
169 echo "*** test 4 - allocations cleared on O_TRUNC"
171 cat <<EOF | $here/src/alloc -n -b $bsize -f $out | _block_filter
176 cat <<EOF | $here/src/alloc -n -b $bsize -f $out -t | _block_filter
181 echo "*** test 5 - reserve / unreserve"
183 cat <<EOF | $here/src/alloc -n -b $bsize -f $out | _block_filter
191 echo "*** test 6 - reserve adjacent"
193 cat <<EOF | $here/src/alloc -t -n -b $bsize -f $out | _block_filter
199 echo "*** test 7 - alloc"
201 cat <<EOF | $here/src/alloc -n -b $bsize -f $out | _block_filter
210 echo "*** test 8 - alloc & truncate"
212 cat <<EOF | $here/src/alloc -n -b $bsize -f $out | _block_filter
221 echo "*** test 9 - reserve & truncate"
223 cat <<EOF | $here/src/alloc -n -b $bsize -f $out | _block_filter