aa65e9a29e7b2d282013eb6406777853b20c3892
[xfstests-dev.git] / tests / shared / 006
1 #! /bin/bash
2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2014 Red Hat Inc.  All Rights Reserved.
4 #
5 # FS QA Test No. shared/006
6 #
7 # Stress test fs by using up all inodes and check fs.
8 #
9 # Also a regression test for xfsprogs commit
10 # d586858 xfs_repair: fix sibling pointer tests in verify_dir2_path()
11 #
12 seq=`basename $0`
13 seqres=$RESULT_DIR/$seq
14 echo "QA output created by $seq"
15
16 here=`pwd`
17 tmp=/tmp/$$
18 status=1        # failure is the default!
19 trap "_cleanup; exit \$status" 0 1 2 3 15
20
21 _cleanup()
22 {
23     cd /
24     rm -f $tmp.*
25 }
26
27 create_file()
28 {
29         local dir=$1
30         local nr_file=$2
31         local prefix=$3
32         local i=0
33
34         while [ $i -lt $nr_file ]; do
35                 echo -n > $dir/${prefix}_${i}
36                 let i=$i+1
37         done
38 }
39
40 # get standard environment, filters and checks
41 . ./common/rc
42 . ./common/filter
43
44 # real QA test starts here
45 _supported_fs ext4 ext3 ext2 xfs
46 _supported_os Linux
47
48 _require_scratch
49
50 rm -f $seqres.full
51 echo "Silence is golden"
52
53 _scratch_mkfs_sized $((1024 * 1024 * 1024)) >>$seqres.full 2>&1
54 _scratch_mount
55
56 i=0
57 free_inode=`_get_free_inode $SCRATCH_MNT`
58 file_per_dir=1000
59 loop=$((free_inode / file_per_dir + 1))
60 mkdir -p $SCRATCH_MNT/testdir
61
62 echo "Create $((loop * file_per_dir)) files in $SCRATCH_MNT/testdir" >>$seqres.full
63 while [ $i -lt $loop ]; do
64         create_file $SCRATCH_MNT/testdir $file_per_dir $i >>$seqres.full 2>&1 &
65         let i=$i+1
66 done
67 wait
68
69 # log inode status in $seqres.full for debug purpose
70 echo "Inode status after taking all inodes" >>$seqres.full
71 $DF_PROG -i $SCRATCH_MNT >>$seqres.full
72
73 _check_scratch_fs
74
75 # Check again after removing all the files
76 rm -rf $SCRATCH_MNT/testdir
77 echo "Inode status after deleting all test files" >>$seqres.full
78 $DF_PROG -i $SCRATCH_MNT >>$seqres.full
79
80 status=0
81 exit