6a237c95a8f9e39953b3b5c876021e18c32a94d9
[xfstests-dev.git] / tests / shared / 006
1 #! /bin/bash
2 # FS QA Test No. shared/006
3 #
4 # Stress test fs by using up all inodes and check fs.
5 #
6 # Also a regression test for xfsprogs commit
7 # d586858 xfs_repair: fix sibling pointer tests in verify_dir2_path()
8 #
9 #-----------------------------------------------------------------------
10 # Copyright (c) 2014 Red Hat Inc.  All Rights Reserved.
11 #
12 # This program is free software; you can redistribute it and/or
13 # modify it under the terms of the GNU General Public License as
14 # published by the Free Software Foundation.
15 #
16 # This program is distributed in the hope that it would be useful,
17 # but WITHOUT ANY WARRANTY; without even the implied warranty of
18 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19 # GNU General Public License for more details.
20 #
21 # You should have received a copy of the GNU General Public License
22 # along with this program; if not, write the Free Software Foundation,
23 # Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
24 #-----------------------------------------------------------------------
25 #
26
27 seq=`basename $0`
28 seqres=$RESULT_DIR/$seq
29 echo "QA output created by $seq"
30
31 here=`pwd`
32 tmp=/tmp/$$
33 status=1        # failure is the default!
34 trap "_cleanup; exit \$status" 0 1 2 3 15
35
36 _cleanup()
37 {
38     cd /
39     rm -f $tmp.*
40 }
41
42 create_file()
43 {
44         local dir=$1
45         local nr_file=$2
46         local prefix=$3
47         local i=0
48
49         while [ $i -lt $nr_file ]; do
50                 echo -n > $dir/${prefix}_${i}
51                 let i=$i+1
52         done
53 }
54
55 # get standard environment, filters and checks
56 . ./common/rc
57 . ./common/filter
58
59 # real QA test starts here
60 _supported_fs ext4 ext3 ext2 xfs
61 _supported_os Linux
62
63 _require_scratch
64
65 rm -f $seqres.full
66 echo "Silence is golden"
67
68 _scratch_mkfs_sized $((1024 * 1024 * 1024)) >>$seqres.full 2>&1
69 _scratch_mount
70
71 i=0
72 free_inode=`_get_free_inode $SCRATCH_MNT`
73 file_per_dir=1000
74 loop=$((free_inode / file_per_dir + 1))
75 mkdir -p $SCRATCH_MNT/testdir
76
77 echo "Create $((loop * file_per_dir)) files in $SCRATCH_MNT/testdir" >>$seqres.full
78 while [ $i -lt $loop ]; do
79         create_file $SCRATCH_MNT/testdir $file_per_dir $i >>$seqres.full 2>&1 &
80         let i=$i+1
81 done
82 wait
83
84 # log inode status in $seqres.full for debug purpose
85 echo "Inode status after taking all inodes" >>$seqres.full
86 $DF_PROG -i $SCRATCH_MNT >>$seqres.full
87
88 _check_scratch_fs
89
90 # Check again after removing all the files
91 rm -rf $SCRATCH_MNT/testdir
92 echo "Inode status after deleting all test files" >>$seqres.full
93 $DF_PROG -i $SCRATCH_MNT >>$seqres.full
94
95 status=0
96 exit