generic: test MADV_POPULATE_READ with IO errors
[xfstests-dev.git] / tests / ext4 / 052
1 #! /bin/bash
2 # SPDX-License-Identifier: GPL-2.0
3 #
4 # FS QA Test 052
5 #
6 # Test ext4's large_dir feature
7 #
8 # Create a directory with enough entries that we can exercise the large_dir
9 # code paths, and then verify that the resulting file system is valid using
10 # e2fsck.
11 #
12 . ./common/preamble
13 _begin_fstest auto quick dir
14
15 # Override the default cleanup function.
16 _cleanup()
17 {
18         cd /
19         rm -r -f $tmp.*
20         if [ ! -z "$loop_mnt" ]; then
21                 $UMOUNT_PROG $loop_mnt
22                 rm -rf $loop_mnt
23         fi
24         [ ! -z "$fs_img" ] && rm -rf $fs_img
25 }
26
27 # Import common functions.
28 # . ./common/filter
29
30 # real QA test starts here
31
32 # Modify as appropriate.
33 _supported_fs ext4
34 _require_test
35 _require_loop
36 _require_test_program "dirstress"
37 _require_scratch_ext4_feature "large_dir"
38
39 echo "Silence is golden"
40
41 loop_mnt=$TEST_DIR/$seq.mnt
42 fs_img=$TEST_DIR/$seq.img
43 status=0
44
45 $XFS_IO_PROG -f -c "truncate 20G" $fs_img >>$seqres.full 2>&1
46
47 # We need to create enough files (400,000) so that using a file system
48 # with a 1k block size, the hash tree created will have three levels
49 # (which is the distringuishing characteristics of a large_dir versus
50 # non-large_dir).  We use no journal mode to decrease the run time of
51 # the test by 25%.
52 ${MKFS_PROG} -t ${FSTYP} -b 1024 -N 400020 -O large_dir,^has_journal \
53              $fs_img 20G >> $seqres.full 2>&1 || _fail "mkfs failed"
54
55 mkdir -p $loop_mnt
56 _mount -o loop $fs_img $loop_mnt > /dev/null  2>&1 || \
57         _fail "Couldn't do initial mount"
58
59 if ! $here/src/dirstress -c -d $loop_mnt -p 1 -f 400000 -C >$tmp.out 2>&1
60 then
61     echo "    dirstress failed"
62     cat $tmp.out >> $seqres.full
63     echo "    dirstress failed" >> $seqres.full
64     status=1
65 fi
66
67 $UMOUNT_PROG $loop_mnt || _fail "umount failed"
68 loop_mnt=
69
70 $E2FSCK_PROG -fn $fs_img >> $seqres.full 2>&1 || _fail "file system corrupted"
71 exit