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
51 _require_xfs_io_command "falloc"
55 ls -l $1 | $AWK_PROG -v bsize="$bsize" '{print "filesize = " $5 / bsize}'
60 $AWK_PROG -v bsize="$bsize" '
62 printf(" blocksize BSIZE\n")
69 offset = strtonum(off[2])
71 offset = offset / bsize
74 nr_blocks = strtonum(len[2])
76 nr_blocks = nr_blocks / bsize
78 printf(" %s %s off=%s, len=%d\n", $1, $2, offset, nr_blocks)
85 offset = strtonum(off[2])
87 offset = offset / bsize
91 nr_blocks = strtonum(len[2])
94 nr_blocks = nr_blocks / bsize
96 printf(" %s off=%s, len=%d %s\n", $1, offset, nr_blocks, $4)
103 offset = strtonum(off[2]) / bsize
105 printf(" %s off=%s\n", $1, offset)
110 /\[[0-9]+,[0-9]+\]:/ {
111 printf(" %s BLOCKRANGE\n", $1)
125 out=$SCRATCH_MNT/$$.tmp
127 # This isn't really related to fs block size, it's just what
128 # alloc uses for the "block" unit in it's input parameters...
129 # However, xfs_alloc_file_space() rounds up allocation
130 # request by the filesystem's block size.
131 bsize=$(_get_file_block_size $SCRATCH_MNT)
133 # since we're using a clean FS here, we make some assumptions
134 # about availability of contiguous blocks
136 # also interesting to note is that ALLOC == FREE. seriously.
137 # the _length is ignored_ in irix. the file is allocated up
138 # to the specified offset, and zero filled if previously
139 # unallocated. the file is truncated at the specified point.
141 echo "*** test 1 - reservations cleared on O_TRUNC"
143 cat <<EOF | $here/src/alloc -n -b $bsize -f $out | _block_filter
149 cat <<EOF | $here/src/alloc -n -b $bsize -f $out -t | _block_filter
154 echo "*** test 2 - reserve & filesize"
156 cat <<EOF | $here/src/alloc -n -b $bsize -f $out | _block_filter
162 echo "*** test 3 - alloc & filesize"
164 cat <<EOF | $here/src/alloc -n -b $bsize -f $out | _block_filter
170 echo "*** test 4 - allocations cleared on O_TRUNC"
172 cat <<EOF | $here/src/alloc -n -b $bsize -f $out | _block_filter
177 cat <<EOF | $here/src/alloc -n -b $bsize -f $out -t | _block_filter
182 echo "*** test 5 - reserve / unreserve"
184 cat <<EOF | $here/src/alloc -n -b $bsize -f $out | _block_filter
192 echo "*** test 6 - reserve adjacent"
194 cat <<EOF | $here/src/alloc -t -n -b $bsize -f $out | _block_filter
200 echo "*** test 7 - alloc"
202 cat <<EOF | $here/src/alloc -n -b $bsize -f $out | _block_filter
211 echo "*** test 8 - alloc & truncate"
213 cat <<EOF | $here/src/alloc -n -b $bsize -f $out | _block_filter
222 echo "*** test 9 - reserve & truncate"
224 cat <<EOF | $here/src/alloc -n -b $bsize -f $out | _block_filter