Whamcloud - gitweb
tests, mke2fs: add option to suppress xattr copying to fix f_extent_htree
[tools/e2fsprogs.git] / tests / f_extent_htree / script
1 #!/bin/bash
2 TMPDIR=${TMPDIR:-"/tmp"}
3 OUT=$test_name.log
4
5 FSCK_OPT="-fyvD"
6 SKIP_GUNZIP="true"
7
8 NAMELEN=250
9 SRC=$TMPDIR/$test_name.tmp
10 SUB=subdir
11 BASE=$SRC/$SUB/$(yes | tr -d '\n' | dd bs=$NAMELEN count=1 2> /dev/null)
12 TMPFILE=${TMPFILE:-"$TMPDIR/image"}
13 BSIZE=1024
14
15 > $OUT
16 mkdir -p $SRC/$SUB
17 # calculate the number of files needed to create the directory extent tree
18 # deep enough to exceed the in-inode index and spill into an index block.
19 #
20 # dirents per block * extents per block * (index blocks > i_blocks)
21 NUM=$(((BSIZE / (NAMELEN + 8)) * (BSIZE / 12) * 2))
22 # Create source files. Unfortunately hard links will be copied as links,
23 # and blocks with only NULs will be turned into holes.
24 if [ ! -f $BASE.1 ]; then
25         for N in $(seq $NUM); do
26                 echo "foo" > $BASE.$N
27         done >> $OUT
28 fi
29
30 # make filesystem with enough inodes and blocks to hold all the test files
31 > $TMPFILE
32 NUM=$((NUM * 5 / 3))
33 echo "mke2fs -b $BSIZE -O dir_index,extent -E no_copy_xattrs -d$SRC -N$NUM $TMPFILE $NUM" >> $OUT
34 $MKE2FS -b $BSIZE -O dir_index,extent -E no_copy_xattrs -d$SRC -N$NUM $TMPFILE $NUM >> $OUT 2>&1
35 rm -r $SRC
36
37 # Run e2fsck to convert dir to htree before deleting the files, as mke2fs
38 # doesn't do this.  Run second e2fsck to verify there is no corruption yet.
39 (
40         EXP1=$test_dir/expect.pre.1
41         EXP2=$test_dir/expect.pre.2
42         OUT1=$test_name.pre.1.log
43         OUT2=$test_name.pre.2.log
44         DESCRIPTION="$(cat $test_dir/name) setup"
45         . $cmd_dir/run_e2fsck
46 )
47
48 # generate a list of filenames for debugfs to delete, one from each leaf block
49 DELETE_LIST=$TMPDIR/delete.$$
50 $DEBUGFS -c -R "htree subdir" $TMPFILE 2>> $OUT |
51         grep -A2 "Reading directory block" |
52         awk '/yyyyy/ { print "rm '$SUB'/"$4 }' > $DELETE_LIST
53 $DEBUGFS -w -f $DELETE_LIST $TMPFILE >> $OUT 2>&1
54 rm $DELETE_LIST
55
56 . $cmd_dir/run_e2fsck