generic/077: fall back to /usr if /lib/modules doesn't exist
[xfstests-dev.git] / tests / xfs / 205
1 #! /bin/bash
2 # FS QA Test No. 205
3 #
4 # Test out ENOSPC flushing on small filesystems.
5 #
6 #-----------------------------------------------------------------------
7 # Copyright (c) 2009 Dave Chinner
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 seq=`basename $0`
25 seqres=$RESULT_DIR/$seq
26 echo "QA output created by $seq"
27
28 here=`pwd`
29 tmp=/tmp/$$
30 status=1        # failure is the default!
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
42 rm -f $seqres.full
43
44 _scratch_mkfs_xfs -d size=16m -b size=512 -l size=4944b >> $seqres.full 2>&1
45 _scratch_mount
46
47 # fix the reserve block pool to a known size so that the enospc calculations
48 # work out correctly.
49 _scratch_resvblks 1024 >> $seqres.full 2>&1
50
51 # on a 16MB filesystem, there's 32768x512byte blocks. used is:
52 #       - 4944 in the log,
53 #       - 32+1 for the root inode cluster
54 #       - 4 for the AG header
55 #       - 2 for free space btrees
56 #       - 4 for the AGFL
57 #       - min(%5, 1024) = 1024 blocks for the reserve pool
58 #       - about 15 blocks I can't account for right now.
59 # That leaves ~26,745 blocks free to use.
60 #
61 # Writing the following three files fill the fs almost exactly.
62 #
63 # $ df -k /mnt/scratch
64 # Filesystem           1K-blocks      Used Available Use% Mounted on
65 # /dev/ubdc                13912     13908         4 100% /mnt/scratch
66 #
67 dd if=/dev/zero of=$SCRATCH_MNT/fred bs=512 count=25000 2>&1 | _filter_dd
68 dd if=/dev/zero of=$SCRATCH_MNT/fred2 bs=512 count=500 2>&1 | _filter_dd
69 dd if=/dev/zero of=$SCRATCH_MNT/fred3 bs=512 count=245 2>&1 | _filter_dd
70 rm -f $SCRATCH_MNT/fred*
71
72 echo "*** one file"
73 # now try a single file of that size
74 dd if=/dev/zero of=$SCRATCH_MNT/fred bs=512 count=26745 2>&1 | _filter_dd
75 #rm -f $SCRATCH_MNT/fred*
76
77 echo "*** one file, a few bytes at a time"
78 # now try a single file of that size
79 dd if=/dev/zero of=$SCRATCH_MNT/fred bs=15 count=$[26745/15*512] 2>&1 | _filter_dd
80
81 # success, all done
82 echo "*** done"
83 status=0