4 # Check if there are two threads,one keeps calling read() or lseek(), and
5 # the other calling readdir(), both on the same directory fd.
7 # Testing on ext3: with dir_index disabled results in the following
8 # dmesg output: (also occurs when testing ext2 and ext4)
10 # EXT3-fs error (device sdb): ext3_readdir: bad entry in directory #1134241:
11 # rec_len % 4 != 0 - offset=2704, inode=16973836, rec_len=12850, name_len=52
12 # EXT3-fs error (device sdb): ext3_readdir: bad entry in directory #1134241:
13 # directory entry across blocks - offset=1672, inode=16973836, rec_len=14132,
16 # The filesystem mount option 'errors=' will define the behavior
17 # when an error is encountered. (see mount manpage)
19 # The test is based on a testcase from Li Zefan <lizefan@huawei.com>.
21 # http://marc.info/?l=linux-kernel&m=136123703211869&w=2
23 #-----------------------------------------------------------------------
24 # Copyright (c) 2013 HuaWei. All Rights Reserved.
26 # This program is free software; you can redistribute it and/or
27 # modify it under the terms of the GNU General Public License as
28 # published by the Free Software Foundation.
30 # This program is distributed in the hope that it would be useful,
31 # but WITHOUT ANY WARRANTY; without even the implied warranty of
32 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
33 # GNU General Public License for more details.
35 # You should have received a copy of the GNU General Public License
36 # along with this program; if not, write the Free Software Foundation,
37 # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
38 #-----------------------------------------------------------------------
42 seqres=$RESULT_DIR/$seq
43 echo "QA output created by $seq"
45 status=1 # failure is the default!
51 trap "_cleanup; exit \$status" 0 1 2 3 15
53 # get standard environment, filters and checks
57 # real QA test starts here
63 nr_bug=`dmesg | grep -c "kernel BUG"`
64 nr_error=`dmesg | grep -c "error"`
65 nr_null=`dmesg | grep -c "kernel NULL pointer dereference"`
66 nr_warning=`dmesg | grep -c "^WARNING"`
67 nr_lockdep=`dmesg | grep -c "possible recursive locking detected"`
69 #check if some kind of kernel bug happened
72 new_bug=`dmesg | grep -c "kernel BUG"`
73 new_error=`dmesg | grep -c "error"`
74 new_null=`dmesg | grep -c "kernel NULL pointer dereference"`
75 new_warning=`dmesg | grep -c "^WARNING"`
76 new_lockdep=`dmesg | grep -c "possible recursive locking detected"`
79 # no kernel bug is detected
80 if [ $new_bug -eq $nr_bug -a $new_error -eq $nr_error -a \
81 $new_null -eq $nr_null -a $new_warning -eq $nr_warning -a \
82 $new_lockdep -eq $nr_lockdep ]; then
89 nr_warning=$new_warning
90 nr_lockdep=$new_lockdep
93 for n in {1..4096}; do
94 touch $TEST_DIR/tmp/$n
99 src/t_readdir_1 $TEST_DIR/tmp &
101 killall src/t_readdir_1
103 if [ $? -eq 1 ]; then
106 echo "error: kernel bug was found, you can see the
107 dmesg for more infomation."
113 src/t_readdir_2 $TEST_DIR/tmp &
115 killall src/t_readdir_2
117 if [ $? -eq 1 ]; then
120 echo "error: kernel bug was found, you can see the
121 dmesg for more infomation."