Use upstream version of fstrim instead of the local one
[xfstests-dev.git] / 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 # creator
24 owner=david@fromorbit.com
25
26 seq=`basename $0`
27 echo "QA output created by $seq"
28
29 here=`pwd`
30 tmp=/tmp/$$
31 status=1        # failure is the default!
32
33 # get standard environment, filters and checks
34 . ./common.rc
35 . ./common.filter
36
37 # real QA test starts here
38 _supported_fs xfs
39 _supported_os Linux
40
41 _require_scratch
42
43 rm -f $seq.full
44
45 _scratch_mkfs_xfs -d size=16m -b size=512 >> $seq.full 2>&1
46 _scratch_mount
47
48 # fix the reserve block pool to a known size so that the enospc calculations
49 # work out correctly.
50 _scratch_resvblks 1024 >> $seq.full 2>&1
51
52 # on a 16MB filesystem, there's 32768x512byte blocks. used is:
53 #       - 4944 in the log,
54 #       - 32+1 for the root inode cluster
55 #       - 4 for the AG header
56 #       - 2 for free space btrees
57 #       - 4 for the AGFL
58 #       - min(%5, 1024) = 1024 blocks for the reserve pool
59 #       - about 15 blocks I can't account for right now.
60 # That leaves ~26,745 blocks free to use.
61 #
62 # Writing the following three files fill the fs almost exactly.
63 #
64 # $ df -k /mnt/scratch
65 # Filesystem           1K-blocks      Used Available Use% Mounted on
66 # /dev/ubdc                13912     13908         4 100% /mnt/scratch
67 #
68 dd if=/dev/zero of=$SCRATCH_MNT/fred bs=512 count=25000 2>&1 | _filter_dd
69 dd if=/dev/zero of=$SCRATCH_MNT/fred2 bs=512 count=500 2>&1 | _filter_dd
70 dd if=/dev/zero of=$SCRATCH_MNT/fred3 bs=512 count=245 2>&1 | _filter_dd
71 rm -f $SCRATCH_MNT/fred*
72
73 echo "*** one file"
74 # now try a single file of that size
75 dd if=/dev/zero of=$SCRATCH_MNT/fred bs=512 count=26745 2>&1 | _filter_dd
76 #rm -f $SCRATCH_MNT/fred*
77
78 echo "*** one file, a few bytes at a time"
79 # now try a single file of that size
80 dd if=/dev/zero of=$SCRATCH_MNT/fred bs=15 count=$[26745/15*512] 2>&1 | _filter_dd
81
82 # success, all done
83 echo "*** done"
84 status=0