xfstests 240: test non-aligned AIO hole-filling
[xfstests-dev.git] / 228
1 #! /bin/bash
2 # FS QA Test No. 228
3 #
4 # Check if fallocate respects RLIMIT_FSIZE
5 #
6 #-----------------------------------------------------------------------
7 # Copyright (c) 2010 IBM Corporation. All Rights Reserved.
8 #
9 # This program is free software; you can redistribute it and/or
10 # modify it under the terms of the GNU General Public License as
11 # published by the Free Software Foundation.
12 #
13 # This program is distributed in the hope that it would be useful,
14 # but WITHOUT ANY WARRANTY; without even the implied warranty of
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16 # GNU General Public License for more details.
17 #
18 # You should have received a copy of the GNU General Public License
19 # along with this program; if not, write the Free Software Foundation,
20 # Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
21 #
22 #-----------------------------------------------------------------------
23 #
24 # creator
25 owner=aarora@in.ibm.com
26
27 seq=`basename $0`
28 echo "QA output created by $seq"
29
30 _cleanup()
31 {
32         cd /
33         rm -f $tmp.*
34 }
35
36 here=`pwd`
37 tmp=$TEST_DIR/$$
38 status=1        # failure is the default!
39 trap "_cleanup; exit \$status" 0 1 2 3 15 25
40
41 # get standard environment, filters and checks
42 . ./common.rc
43
44 # real QA test starts here
45 # generic, but xfs_io's fallocate must work
46 _supported_fs generic
47 # only Linux supports fallocate
48 _supported_os Linux
49
50 [ -n "$XFS_IO_PROG" ] || _notrun "xfs_io executable not found"
51
52 rm -f $seq.full
53
54 # Sanity check to see if fallocate works
55 _require_xfs_io_falloc
56
57 # Check if we have good enough space available
58 avail=`df -P $TEST_DIR | awk 'END {print $4}'`
59 [ "$avail" -ge 104000 ] || _notrun "Test device is too small ($avail KiB)"
60
61 # Set the FSIZE ulimit to 100MB and check
62 ulimit -f 102400
63 flim=`ulimit -f`
64 [ "$flim" != "unlimited" ] || _notrun "Unable to set FSIZE ulimit"
65 [ "$flim" -eq 102400 ] || _notrun "FSIZE ulimit is not correct (100 MB)"
66
67 echo "File size limit is now set to 100 MB."
68 echo "Let us try to preallocate 101 MB. This should fail."
69 $XFS_IO_PROG -F -f -c 'falloc 0 101m' $TEST_DIR/ouch
70 rm -f $TEST_DIR/ouch
71
72 echo "Let us now try to preallocate 50 MB. This should succeed."
73 $XFS_IO_PROG -F -f -c 'falloc 0 50m' $TEST_DIR/ouch
74 rm -f $TEST_DIR/ouch
75
76 echo "Test over."
77 # success, all done
78 status=0
79 exit