tests: test recovery from an external journal

Add a couple of tests to verify that writing to and recovering from
an external journal work properly.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
crypto
Darrick J. Wong 2014-09-08 16:14:01 -07:00 committed by Theodore Ts'o
parent cdac96a8e1
commit b0295237b9
6 changed files with 348 additions and 0 deletions

View File

@ -0,0 +1,91 @@
Creating filesystem with 262144 1k blocks and 0 inodes
Superblock backups stored on blocks:
Zeroing journal device: 
Creating filesystem with 262144 1k blocks and 16384 inodes
Superblock backups stored on blocks:
8193, 24577, 40961, 57345, 73729, 204801, 221185
Allocating group tables: done
Writing inode tables: done
Writing superblocks and filesystem accounting information: done
debugfs add journal device/UUID
debugfs: feature has_journal
Filesystem features: has_journal ext_attr resize_inode dir_index filetype extent flex_bg sparse_super huge_file uninit_bg dir_nlink extra_isize
debugfs: ssv journal_dev 0x9999
debugfs: ssv journal_uuid 1db3f677-6832-4adb-bafc-8e4059c30a34
Pass 1: Checking inodes, blocks, and sizes
Pass 2: Checking directory structure
Pass 3: Checking directory connectivity
Pass 4: Checking reference counts
Pass 5: Checking group summary information
test_filesys: 11/16384 files (0.0% non-contiguous), 6239/262144 blocks
Exit status is 0
debugfs write journal
debugfs: logdump -c
Ext2 superblock header found.
Journal starts at block 3, transaction 1
Found expected sequence 1, type 1 (descriptor block) at block 3
Found expected sequence 1, type 1 (descriptor block) at block 128
Found expected sequence 1, type 1 (descriptor block) at block 253
Found expected sequence 1, type 1 (descriptor block) at block 378
Found expected sequence 1, type 1 (descriptor block) at block 503
Found expected sequence 1, type 1 (descriptor block) at block 628
Found expected sequence 1, type 1 (descriptor block) at block 753
Found expected sequence 1, type 1 (descriptor block) at block 878
Found expected sequence 1, type 1 (descriptor block) at block 1003
Found expected sequence 1, type 1 (descriptor block) at block 1128
Found expected sequence 1, type 1 (descriptor block) at block 1253
Found expected sequence 1, type 1 (descriptor block) at block 1378
Found expected sequence 1, type 1 (descriptor block) at block 1503
Found expected sequence 1, type 1 (descriptor block) at block 1628
Found expected sequence 1, type 1 (descriptor block) at block 1753
Found expected sequence 1, type 1 (descriptor block) at block 1878
Found expected sequence 1, type 1 (descriptor block) at block 2003
Found expected sequence 1, type 1 (descriptor block) at block 2128
Found expected sequence 1, type 1 (descriptor block) at block 2253
Found expected sequence 1, type 1 (descriptor block) at block 2378
Found expected sequence 1, type 1 (descriptor block) at block 2503
Found expected sequence 1, type 1 (descriptor block) at block 2628
Found expected sequence 1, type 1 (descriptor block) at block 2753
Found expected sequence 1, type 1 (descriptor block) at block 2878
Found expected sequence 1, type 1 (descriptor block) at block 3003
Found expected sequence 1, type 1 (descriptor block) at block 3128
Found expected sequence 1, type 1 (descriptor block) at block 3253
Found expected sequence 1, type 1 (descriptor block) at block 3378
Found expected sequence 1, type 1 (descriptor block) at block 3503
Found expected sequence 1, type 1 (descriptor block) at block 3628
Found expected sequence 1, type 1 (descriptor block) at block 3753
Found expected sequence 1, type 1 (descriptor block) at block 3878
Found expected sequence 1, type 1 (descriptor block) at block 4003
Found expected sequence 1, type 1 (descriptor block) at block 4128
Found expected sequence 1, type 2 (commit block) at block 4135
Found expected sequence 2, type 5 (revoke table) at block 4136
Found expected sequence 2, type 5 (revoke table) at block 4137
Found expected sequence 2, type 5 (revoke table) at block 4138
Found expected sequence 2, type 5 (revoke table) at block 4139
Found expected sequence 2, type 5 (revoke table) at block 4140
Found expected sequence 2, type 5 (revoke table) at block 4141
Found expected sequence 2, type 5 (revoke table) at block 4142
Found expected sequence 2, type 5 (revoke table) at block 4143
Found expected sequence 2, type 5 (revoke table) at block 4144
Found expected sequence 2, type 5 (revoke table) at block 4145
Found expected sequence 2, type 5 (revoke table) at block 4146
Found expected sequence 2, type 5 (revoke table) at block 4147
Found expected sequence 2, type 5 (revoke table) at block 4148
Found expected sequence 2, type 5 (revoke table) at block 4149
Found expected sequence 2, type 5 (revoke table) at block 4150
Found expected sequence 2, type 5 (revoke table) at block 4151
Found expected sequence 2, type 5 (revoke table) at block 4152
Found expected sequence 2, type 2 (commit block) at block 4153
No magic number at block 4154: end of journal.
debugfs fsck
test_filesys: recovering journal
Pass 1: Checking inodes, blocks, and sizes
Pass 2: Checking directory structure
Pass 3: Checking directory connectivity
Pass 4: Checking reference counts
Pass 5: Checking group summary information
test_filesys: 11/16384 files (0.0% non-contiguous), 6239/262144 blocks
Exit status is 0

View File

@ -0,0 +1 @@
revoked transaction nuking free space w/ ext. journal

View File

@ -0,0 +1,77 @@
if test -x $DEBUGFS_EXE; then
FSCK_OPT=-fy
OUT=$test_name.log
if [ -f $test_dir/expect.gz ]; then
EXP=$test_name.tmp
gunzip < $test_dir/expect.gz > $EXP1
else
EXP=$test_dir/expect
fi
cp /dev/null $OUT
JNLFILE=$TMPFILE.jnl
touch $JNLFILE
$MKE2FS -F -o Linux -b 1024 -O journal_dev -T ext4 -U 1db3f677-6832-4adb-bafc-8e4059c30a34 $JNLFILE 262144 2>&1 | sed -f $cmd_dir/filter.sed >> $OUT 2>&1
$MKE2FS -F -o Linux -b 1024 -O ^has_journal -T ext4 $TMPFILE 262144 2>&1 | sed -f $cmd_dir/filter.sed >> $OUT 2>&1
echo "debugfs add journal device/UUID" >> $OUT
$DEBUGFS -w -f - $TMPFILE <<- EOF >> $OUT.new 2>&1
feature has_journal
ssv journal_dev 0x9999
ssv journal_uuid 1db3f677-6832-4adb-bafc-8e4059c30a34
EOF
sed -f $cmd_dir/filter.sed -e "s;$TMPFILE;test.img;" $OUT.new >> $OUT
rm -f $OUT.new
$FSCK -fy -N test_filesys -j $JNLFILE $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
echo "debugfs write journal" >> $OUT
echo "jo -f $JNLFILE" > $TMPFILE.cmd
echo "jw -b 259-4356 /dev/zero" >> $TMPFILE.cmd
echo "jc" >> $TMPFILE.cmd
echo "jo -f $JNLFILE" >> $TMPFILE.cmd
echo "jw -r 259-4356 /dev/zero" >> $TMPFILE.cmd
echo "jc" >> $TMPFILE.cmd
$DEBUGFS_EXE -w $TMPFILE -f $TMPFILE.cmd 2>> $OUT.new > /dev/null
sed -f $cmd_dir/filter.sed < $OUT.new >> $OUT
rm -rf $OUT.new
test -d "$JOURNAL_DUMP_DIR" -a -w "$JOURNAL_DUMP_DIR" && cp "$TMPFILE" "$JOURNAL_DUMP_DIR/$test_name.img"
test -d "$JOURNAL_DUMP_DIR" -a -w "$JOURNAL_DUMP_DIR" && cp "$JNLFILE" "$JOURNAL_DUMP_DIR/$test_name.img.jnl"
echo "logdump -c -f $JNLFILE" > $TMPFILE.cmd
$DEBUGFS_EXE $TMPFILE -f $TMPFILE.cmd 2>&1 | sed -f $cmd_dir/filter.sed -e 's/logdump -c -f.*/logdump -c/g' >> $OUT
rm -rf $TMPFILE.cmd
echo "debugfs fsck" >> $OUT
$FSCK -fy -N test_filesys -j $JNLFILE $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
rm -f $TMPFILE $JNLFILE
cmp -s $OUT $EXP
status=$?
if [ "$status" = 0 ] ; then
echo "$test_name: $test_description: ok"
touch $test_name.ok
else
echo "$test_name: $test_description: failed"
diff $DIFF_OPTS $EXP $OUT > $test_name.failed
rm -f $test_name.tmp
fi
unset IMAGE FSCK_OPT OUT EXP JNLFILE
else #if test -x $DEBUGFS_EXE; then
echo "$test_name: $test_description: skipped"
fi

View File

@ -0,0 +1,104 @@
Creating filesystem with 262144 1k blocks and 0 inodes
Superblock backups stored on blocks:
Zeroing journal device: 
Creating filesystem with 262144 1k blocks and 16384 inodes
Superblock backups stored on blocks:
8193, 24577, 40961, 57345, 73729, 204801, 221185
Allocating group tables: done
Writing inode tables: done
Writing superblocks and filesystem accounting information: done
debugfs add journal device/UUID
debugfs: feature has_journal
Filesystem features: has_journal ext_attr resize_inode dir_index filetype extent flex_bg sparse_super huge_file uninit_bg dir_nlink extra_isize
debugfs: ssv journal_dev 0x9999
debugfs: ssv journal_uuid 1db3f677-6832-4adb-bafc-8e4059c30a34
Pass 1: Checking inodes, blocks, and sizes
Pass 2: Checking directory structure
Pass 3: Checking directory connectivity
Pass 4: Checking reference counts
Pass 5: Checking group summary information
test_filesys: 11/16384 files (0.0% non-contiguous), 6239/262144 blocks
Exit status is 0
debugfs write journal
debugfs: logdump -c
Ext2 superblock header found.
Journal starts at block 3, transaction 1
Found expected sequence 1, type 1 (descriptor block) at block 3
Found expected sequence 1, type 1 (descriptor block) at block 128
Found expected sequence 1, type 1 (descriptor block) at block 253
Found expected sequence 1, type 1 (descriptor block) at block 378
Found expected sequence 1, type 1 (descriptor block) at block 503
Found expected sequence 1, type 1 (descriptor block) at block 628
Found expected sequence 1, type 1 (descriptor block) at block 753
Found expected sequence 1, type 1 (descriptor block) at block 878
Found expected sequence 1, type 1 (descriptor block) at block 1003
Found expected sequence 1, type 1 (descriptor block) at block 1128
Found expected sequence 1, type 1 (descriptor block) at block 1253
Found expected sequence 1, type 1 (descriptor block) at block 1378
Found expected sequence 1, type 1 (descriptor block) at block 1503
Found expected sequence 1, type 1 (descriptor block) at block 1628
Found expected sequence 1, type 1 (descriptor block) at block 1753
Found expected sequence 1, type 1 (descriptor block) at block 1878
Found expected sequence 1, type 1 (descriptor block) at block 2003
Found expected sequence 1, type 1 (descriptor block) at block 2128
Found expected sequence 1, type 1 (descriptor block) at block 2253
Found expected sequence 1, type 1 (descriptor block) at block 2378
Found expected sequence 1, type 1 (descriptor block) at block 2503
Found expected sequence 1, type 1 (descriptor block) at block 2628
Found expected sequence 1, type 1 (descriptor block) at block 2753
Found expected sequence 1, type 1 (descriptor block) at block 2878
Found expected sequence 1, type 1 (descriptor block) at block 3003
Found expected sequence 1, type 1 (descriptor block) at block 3128
Found expected sequence 1, type 1 (descriptor block) at block 3253
Found expected sequence 1, type 1 (descriptor block) at block 3378
Found expected sequence 1, type 1 (descriptor block) at block 3503
Found expected sequence 1, type 1 (descriptor block) at block 3628
Found expected sequence 1, type 1 (descriptor block) at block 3753
Found expected sequence 1, type 1 (descriptor block) at block 3878
Found expected sequence 1, type 1 (descriptor block) at block 4003
Found expected sequence 1, type 1 (descriptor block) at block 4128
Found expected sequence 1, type 2 (commit block) at block 4135
No magic number at block 4136: end of journal.
debugfs fsck
test_filesys: recovering journal
Resize inode not valid. Recreate? yes
Pass 1: Checking inodes, blocks, and sizes
Root inode is not a directory. Clear? yes
Pass 2: Checking directory structure
Pass 3: Checking directory connectivity
Root inode not allocated. Allocate? yes
/lost+found not found. Create? yes
Pass 4: Checking reference counts
Pass 5: Checking group summary information
Block bitmap differences: +(1--259) +275 +(291--418) +2341
Fix? yes
Free blocks count wrong for group #0 (5838, counted=5851).
Fix? yes
Free blocks count wrong (255903, counted=255916).
Fix? yes
Inode bitmap differences: +1 +(3--10)
Fix? yes
Free inodes count wrong for group #0 (500, counted=501).
Fix? yes
Directories count wrong for group #0 (3, counted=2).
Fix? yes
Free inodes count wrong (16372, counted=16373).
Fix? yes
test_filesys: ***** FILE SYSTEM WAS MODIFIED *****
test_filesys: 11/16384 files (0.0% non-contiguous), 6228/262144 blocks
Exit status is 1

View File

@ -0,0 +1 @@
transaction nuking free space w/ ext. journal

View File

@ -0,0 +1,74 @@
if test -x $DEBUGFS_EXE; then
FSCK_OPT=-fy
OUT=$test_name.log
if [ -f $test_dir/expect.gz ]; then
EXP=$test_name.tmp
gunzip < $test_dir/expect.gz > $EXP1
else
EXP=$test_dir/expect
fi
cp /dev/null $OUT
JNLFILE=$TMPFILE.jnl
touch $JNLFILE
$MKE2FS -F -o Linux -b 1024 -O journal_dev -T ext4 -U 1db3f677-6832-4adb-bafc-8e4059c30a34 $JNLFILE 262144 2>&1 | sed -f $cmd_dir/filter.sed >> $OUT 2>&1
$MKE2FS -F -o Linux -b 1024 -O ^has_journal -T ext4 $TMPFILE 262144 2>&1 | sed -f $cmd_dir/filter.sed >> $OUT 2>&1
echo "debugfs add journal device/UUID" >> $OUT
$DEBUGFS -w -f - $TMPFILE <<- EOF >> $OUT.new 2>&1
feature has_journal
ssv journal_dev 0x9999
ssv journal_uuid 1db3f677-6832-4adb-bafc-8e4059c30a34
EOF
sed -f $cmd_dir/filter.sed -e "s;$TMPFILE;test.img;" $OUT.new >> $OUT
rm -f $OUT.new
$FSCK -fy -N test_filesys -j $JNLFILE $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
echo "debugfs write journal" >> $OUT
echo "jo -f $JNLFILE" > $TMPFILE.cmd
echo "jw -b 259-4356 /dev/zero" >> $TMPFILE.cmd
echo "jc" >> $TMPFILE.cmd
$DEBUGFS_EXE -w $TMPFILE -f $TMPFILE.cmd 2>> $OUT.new > /dev/null
sed -f $cmd_dir/filter.sed < $OUT.new >> $OUT
rm -rf $OUT.new
test -d "$JOURNAL_DUMP_DIR" -a -w "$JOURNAL_DUMP_DIR" && cp "$TMPFILE" "$JOURNAL_DUMP_DIR/$test_name.img"
test -d "$JOURNAL_DUMP_DIR" -a -w "$JOURNAL_DUMP_DIR" && cp "$JNLFILE" "$JOURNAL_DUMP_DIR/$test_name.img.jnl"
echo "logdump -c -f $JNLFILE" > $TMPFILE.cmd
$DEBUGFS_EXE $TMPFILE -f $TMPFILE.cmd 2>&1 | sed -f $cmd_dir/filter.sed -e 's/logdump -c -f.*/logdump -c/g' >> $OUT
rm -rf $TMPFILE.cmd
echo "debugfs fsck" >> $OUT
$FSCK -fy -N test_filesys -j $JNLFILE $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
rm -f $TMPFILE $JNLFILE
cmp -s $OUT $EXP
status=$?
if [ "$status" = 0 ] ; then
echo "$test_name: $test_description: ok"
touch $test_name.ok
else
echo "$test_name: $test_description: failed"
diff $DIFF_OPTS $EXP $OUT > $test_name.failed
rm -f $test_name.tmp
fi
unset IMAGE FSCK_OPT OUT EXP JNLFILE
else #if test -x $DEBUGFS_EXE; then
echo "$test_name: $test_description: skipped"
fi