All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jan Kara <jack@suse.cz>
To: Ted Tso <tytso@mit.edu>
Cc: <linux-ext4@vger.kernel.org>, Jan Kara <jack@suse.cz>
Subject: [PATCH 6/7] tests: Add test to excercise indexed directories with metadata_csum
Date: Thu, 13 Feb 2020 11:16:01 +0100	[thread overview]
Message-ID: <20200213101602.29096-7-jack@suse.cz> (raw)
In-Reply-To: <20200213101602.29096-1-jack@suse.cz>

Indexed directories have somewhat different format when metadata_csum is
enabled. Add test to excercise linking in indexed directories and e2fsck
rehash code in this case.

Signed-off-by: Jan Kara <jack@suse.cz>
---
 tests/f_large_dir_csum/expect       | 32 ++++++++++++++
 tests/f_large_dir_csum/is_slow_test |  0
 tests/f_large_dir_csum/name         |  1 +
 tests/f_large_dir_csum/script       | 84 +++++++++++++++++++++++++++++++++++++
 4 files changed, 117 insertions(+)
 create mode 100644 tests/f_large_dir_csum/expect
 create mode 100644 tests/f_large_dir_csum/is_slow_test
 create mode 100644 tests/f_large_dir_csum/name
 create mode 100644 tests/f_large_dir_csum/script

diff --git a/tests/f_large_dir_csum/expect b/tests/f_large_dir_csum/expect
new file mode 100644
index 000000000000..aa9f33f1d25d
--- /dev/null
+++ b/tests/f_large_dir_csum/expect
@@ -0,0 +1,32 @@
+Creating filesystem with 31002 1k blocks and 64 inodes
+Superblock backups stored on blocks: 
+	8193, 24577
+
+Allocating group tables:    \b\b\bdone                            
+Writing inode tables:    \b\b\bdone                            
+Writing superblocks and filesystem accounting information:    \b\b\bdone
+
+Pass 1: Checking inodes, blocks, and sizes
+Pass 2: Checking directory structure
+Pass 3: Checking directory connectivity
+Pass 3A: Optimizing directories
+Pass 4: Checking reference counts
+Inode 13 ref count is 1, should be 5.  Fix? yes
+
+Pass 5: Checking group summary information
+
+test.img: ***** FILE SYSTEM WAS MODIFIED *****
+test.img: 13/64 files (0.0% non-contiguous), 766/31002 blocks
+Exit status is 1
+Pass 1: Checking inodes, blocks, and sizes
+Pass 2: Checking directory structure
+Pass 3: Checking directory connectivity
+Pass 3A: Optimizing directories
+Pass 4: Checking reference counts
+Inode 13 ref count is 5, should be 46504.  Fix? yes
+
+Pass 5: Checking group summary information
+
+test.img: ***** FILE SYSTEM WAS MODIFIED *****
+test.img: 13/64 files (0.0% non-contiguous), 16390/31002 blocks
+Exit status is 1
diff --git a/tests/f_large_dir_csum/is_slow_test b/tests/f_large_dir_csum/is_slow_test
new file mode 100644
index 000000000000..e69de29bb2d1
diff --git a/tests/f_large_dir_csum/name b/tests/f_large_dir_csum/name
new file mode 100644
index 000000000000..2b37c8c21f79
--- /dev/null
+++ b/tests/f_large_dir_csum/name
@@ -0,0 +1 @@
+optimize 3 level htree directories with metadata checksums
diff --git a/tests/f_large_dir_csum/script b/tests/f_large_dir_csum/script
new file mode 100644
index 000000000000..286a965d5e6a
--- /dev/null
+++ b/tests/f_large_dir_csum/script
@@ -0,0 +1,84 @@
+OUT=$test_name.log
+EXP=$test_dir/expect
+E2FSCK=../e2fsck/e2fsck
+
+NAMELEN=255
+DIRENT_SZ=8
+BLOCKSZ=1024
+INODESZ=128
+CSUM_SZ=8
+CSUM_TAIL_SZ=12
+DIRENT_PER_LEAF=$(((BLOCKSZ - CSUM_TAIL_SZ) / (NAMELEN + DIRENT_SZ)))
+HEADER=32
+INDEX_SZ=8
+INDEX_L1=$(((BLOCKSZ - HEADER - CSUM_SZ) / INDEX_SZ))
+INDEX_L2=$(((BLOCKSZ - DIRENT_SZ - CSUM_SZ) / INDEX_SZ))
+DIRBLK=$((3 + INDEX_L1 * INDEX_L2))
+ENTRIES=$((DIRBLK * DIRENT_PER_LEAF))
+# directory leaf blocks - get twice as much because the leaves won't be full
+# and there are also other filesystem blocks.
+FSIZE=$((DIRBLK * 2))
+
+$MKE2FS -b 1024 -O extents,64bit,large_dir,uninit_bg,metadata_csum -N 50 \
+	-I $INODESZ -F $TMPFILE $FSIZE > $OUT.new 2>&1
+RC=$?
+if [ $RC -eq 0 ]; then
+{
+	# First some initial fs setup to create indexed dir
+	echo "mkdir /foo"
+	echo "cd /foo"
+	touch $TMPFILE.tmp
+	echo "write $TMPFILE.tmp foofile"
+	i=0
+	while test $i -lt $DIRENT_PER_LEAF ; do
+		printf "ln foofile f%0254u\n" $i
+		i=$((i + 1));
+	done
+	echo "expand ./"
+	printf "ln foofile f%0254u\n" $i
+} | $DEBUGFS -w $TMPFILE > /dev/null 2>> $OUT.new
+	RC=$?
+	# e2fsck should optimize the dir to become indexed
+	$E2FSCK -yfD $TMPFILE >> $OUT.new 2>&1
+	status=$?
+	echo Exit status is $status >> $OUT.new
+fi
+
+if [ $RC -eq 0 ]; then
+{
+	START=$SECONDS
+	i=$(($DIRENT_PER_LEAF+1))
+	last=$i
+	echo "cd /foo"
+	while test $i -lt $ENTRIES ; do
+	    ELAPSED=$((SECONDS - START))
+	    if test $((i % 5000)) -eq 0 -a $ELAPSED -gt 10; then
+		RATE=$(((i - last) / ELAPSED))
+		echo "$test_name: $i/$ENTRIES links, ${ELAPSED}s @ $RATE/s" >&2
+		START=$SECONDS
+		last=$i
+	    fi
+	    printf "ln foofile f%0254u\n" $i
+	    i=$((i + 1))
+	done
+} | $DEBUGFS -w $TMPFILE > /dev/null 2>> $OUT.new
+	RC=$?
+fi
+
+if [ $RC -eq 0 ]; then
+	$E2FSCK -yfD $TMPFILE >> $OUT.new 2>&1
+	status=$?
+	echo Exit status is $status >> $OUT.new
+	sed -f $cmd_dir/filter.sed -e "s;$TMPFILE;test.img;" $OUT.new > $OUT
+	rm -f $OUT.new
+
+	cmp -s $OUT $EXP
+	RC=$?
+fi
+if [ $RC -eq 0 ]; then
+	echo "$test_name: $test_description: ok"
+	touch $test_name.ok
+else
+	echo "$test_name: $test_description: failed"
+	diff -u $EXP $OUT > $test_name.failed
+fi
-- 
2.16.4


  parent reply	other threads:[~2020-02-13 10:16 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-02-13 10:15 [PATCH 0/7 v2] e2fsprogs: Better handling of indexed directories Jan Kara
2020-02-13 10:15 ` [PATCH 1/7] e2fsck: Clarify overflow link count error message Jan Kara
2020-02-14 19:27   ` Andreas Dilger
2020-03-07 18:52   ` Theodore Y. Ts'o
2020-02-13 10:15 ` [PATCH 2/7] e2fsck: Fix indexed dir rehash failure with metadata_csum enabled Jan Kara
2020-02-14 19:28   ` Andreas Dilger
2020-03-07 23:17   ` Theodore Y. Ts'o
2020-03-16  9:30     ` Jan Kara
2020-02-13 10:15 ` [PATCH 3/7] ext2fs: Update allocation info earlier in ext2fs_mkdir() and ext2fs_symlink() Jan Kara
2020-02-14 19:37   ` Andreas Dilger
2020-03-08  0:02   ` Theodore Y. Ts'o
2020-03-08  2:20     ` Theodore Y. Ts'o
2020-03-15 16:15       ` Theodore Y. Ts'o
2020-03-16  9:32         ` Jan Kara
2020-02-13 10:15 ` [PATCH 4/7] ext2fs: Implement dir entry creation in htree directories Jan Kara
2020-03-15 16:43   ` Theodore Y. Ts'o
2020-02-13 10:16 ` [PATCH 5/7] tests: Modify f_large_dir test to excercise indexed dir handling Jan Kara
2020-02-18 20:29   ` Andreas Dilger
2020-03-15 16:43   ` Theodore Y. Ts'o
2020-02-13 10:16 ` Jan Kara [this message]
2020-02-18 20:34   ` [PATCH 6/7] tests: Add test to excercise indexed directories with metadata_csum Andreas Dilger
2020-02-13 10:16 ` [PATCH 7/7] tune2fs: Update dir checksums when clearing dir_index feature Jan Kara
2020-02-18 20:50   ` Andreas Dilger
2020-02-19 10:23     ` Jan Kara
2020-03-15 17:15   ` Theodore Y. Ts'o
2020-03-16  0:11     ` Andreas Dilger
2020-03-16  9:27     ` Jan Kara
2020-03-26 14:27     ` Jan Kara

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200213101602.29096-7-jack@suse.cz \
    --to=jack@suse.cz \
    --cc=linux-ext4@vger.kernel.org \
    --cc=tytso@mit.edu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.