2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2013 HuaWei. All Rights Reserved.
7 # Check if there are two threads,one keeps calling read() or lseek(), and
8 # the other calling readdir(), both on the same directory fd.
10 # Testing on ext3: with dir_index disabled results in the following
11 # dmesg output: (also occurs when testing ext2 and ext4)
13 # EXT3-fs error (device sdb): ext3_readdir: bad entry in directory #1134241:
14 # rec_len % 4 != 0 - offset=2704, inode=16973836, rec_len=12850, name_len=52
15 # EXT3-fs error (device sdb): ext3_readdir: bad entry in directory #1134241:
16 # directory entry across blocks - offset=1672, inode=16973836, rec_len=14132,
19 # The filesystem mount option 'errors=' will define the behavior
20 # when an error is encountered. (see mount manpage)
22 # The test is based on a testcase from Li Zefan <lizefan@huawei.com>.
24 # http://marc.info/?l=linux-kernel&m=136123703211869&w=2
29 # Override the default cleanup function.
35 # Import common functions.
38 # real QA test starts here
41 _require_command "$KILLALL_PROG" killall
45 nr_bug=`dmesg | grep -c "kernel BUG"`
46 nr_error=`dmesg | grep -wc "error"`
47 nr_null=`dmesg | grep -c "kernel NULL pointer dereference"`
48 nr_warning=`dmesg | grep -c "^WARNING"`
49 nr_lockdep=`dmesg | grep -c "possible recursive locking detected"`
51 #check if some kind of kernel bug happened
54 new_bug=`dmesg | grep -c "kernel BUG"`
55 new_error=`dmesg | grep -wc "error"`
56 new_null=`dmesg | grep -c "kernel NULL pointer dereference"`
57 new_warning=`dmesg | grep -c "^WARNING"`
58 new_lockdep=`dmesg | grep -c "possible recursive locking detected"`
60 # no kernel bug is detected
61 if [ $new_bug -eq $nr_bug -a $new_error -eq $nr_error -a \
62 $new_null -eq $nr_null -a $new_warning -eq $nr_warning -a \
63 $new_lockdep -eq $nr_lockdep ]; then
70 nr_warning=$new_warning
71 nr_lockdep=$new_lockdep
75 RUN_TIME=$((30 * $TIME_FACTOR))
77 SEQ_DIR=$TEST_DIR/$seq
79 for n in {1..4096}; do
85 $here/src/t_readdir_1 $SEQ_DIR &
87 $KILLALL_PROG t_readdir_1
90 _fatal "kernel bug detected, check dmesg for more infomation."
96 $here/src/t_readdir_2 $SEQ_DIR &
98 $KILLALL_PROG t_readdir_2
100 if [ $? -ne 0 ]; then
101 _fatal "kernel bug detected, check dmesg for more infomation."