linux-ext4.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Darrick J. Wong" <darrick.wong@oracle.com>
To: tytso@mit.edu, darrick.wong@oracle.com
Cc: linux-ext4@vger.kernel.org
Subject: [PATCH 28/47] resize2fs: set bg flags and unused inode count when resizing
Date: Fri, 07 Nov 2014 13:53:48 -0800	[thread overview]
Message-ID: <20141107215348.883.19810.stgit@birch.djwong.org> (raw)
In-Reply-To: <20141107215042.883.49888.stgit@birch.djwong.org>

Recalculate the unused inode count and the block/inode uninit flags
when resizing a filesystem.  This can speed up future e2fsck runs
considerably and will reduce mount times.

v2: Use a library function to take care of this.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
---
 resize/resize2fs.c              |    4 ++++
 tests/r_fixup_lastbg/expect     |   39 +++++++++++++++++++++++++++++++++++
 tests/r_fixup_lastbg/script     |   37 ++++++++++++++++++++++++++++++++++
 tests/r_fixup_lastbg_big/expect |   43 +++++++++++++++++++++++++++++++++++++++
 tests/r_fixup_lastbg_big/script |   37 ++++++++++++++++++++++++++++++++++
 5 files changed, 160 insertions(+)
 create mode 100644 tests/r_fixup_lastbg/expect
 create mode 100755 tests/r_fixup_lastbg/script
 create mode 100644 tests/r_fixup_lastbg_big/expect
 create mode 100755 tests/r_fixup_lastbg_big/script


diff --git a/resize/resize2fs.c b/resize/resize2fs.c
index da1ec9c..94c0643 100644
--- a/resize/resize2fs.c
+++ b/resize/resize2fs.c
@@ -198,6 +198,10 @@ errcode_t resize_fs(ext2_filsys fs, blk64_t *new_size, int flags,
 	if (retval)
 		goto errout;
 
+	retval = ext2fs_set_gdt_csum(rfs->new_fs);
+	if (retval)
+		goto errout;
+
 	rfs->new_fs->super->s_state &= ~EXT2_ERROR_FS;
 	rfs->new_fs->flags &= ~EXT2_FLAG_MASTER_SB_ONLY;
 
diff --git a/tests/r_fixup_lastbg/expect b/tests/r_fixup_lastbg/expect
new file mode 100644
index 0000000..96b154a
--- /dev/null
+++ b/tests/r_fixup_lastbg/expect
@@ -0,0 +1,39 @@
+Creating filesystem with 20000 1k blocks and 1248 inodes
+Superblock backups stored on blocks: 
+	8193
+
+Allocating group tables:    \b\b\bdone                            
+Writing inode tables:    \b\b\bdone                            
+Creating journal (1024 blocks): done
+Writing superblocks and filesystem accounting information:    \b\b\bdone
+
+Group 2: (Blocks 16385-19999) [INODE_UNINIT, ITABLE_ZEROED]
+  Block bitmap at 83 (bg #0 + 82)
+  Inode bitmap at 86 (bg #0 + 85)
+  Inode table at 295-398 (bg #0 + 294)
+  3615 free blocks, 416 free inodes, 0 directories, 416 unused inodes
+  Free blocks: 16385-19999
+  Free inodes: 833-1248
+Group 2: (Blocks 16385-19999)
+  Block bitmap at 83 (bg #0 + 82)
+  Inode bitmap at 86 (bg #0 + 85)
+  Inode table at 295-398 (bg #0 + 294)
+  3615 free blocks, 416 free inodes, 0 directories
+  Free blocks: 16385-19999
+  Free inodes: 833-1248
+Resizing the filesystem on test.img to 20004 (1k) blocks.
+The filesystem on test.img is now 20004 (1k) blocks long.
+
+Group 2: (Blocks 16385-20003) [INODE_UNINIT]
+  Block bitmap at 83 (bg #0 + 82)
+  Inode bitmap at 86 (bg #0 + 85)
+  Inode table at 295-398 (bg #0 + 294)
+  3619 free blocks, 416 free inodes, 0 directories, 416 unused inodes
+  Free blocks: 16385-20003
+  Free inodes: 833-1248
+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.img: 11/1248 files (0.0% non-contiguous), 1517/20004 blocks
diff --git a/tests/r_fixup_lastbg/script b/tests/r_fixup_lastbg/script
new file mode 100755
index 0000000..6a5c5af
--- /dev/null
+++ b/tests/r_fixup_lastbg/script
@@ -0,0 +1,37 @@
+if test -x $RESIZE2FS_EXE -a -x $DEBUGFS_EXE; then
+test_description="fix up last bg when expanding within the last bg"
+
+EXP=$test_dir/expect
+OUT=$test_name.out
+LOG=$test_name.log
+E2FSCK=../e2fsck/e2fsck
+
+$MKE2FS -T ext4 -b 1024 -F -U 56d3ee50-8532-4f29-8181-d7c6ea4a94a6 $TMPFILE 20000 > $OUT 2>&1
+$DUMPE2FS $TMPFILE 2>&1 | grep -A10 '^Group 2:' >> $OUT
+$DEBUGFS -R "set_bg 2 itable_unused 0" -w $TMPFILE > /dev/null 2>&1
+$DEBUGFS -R "set_bg 2 flags 0" -w $TMPFILE > /dev/null 2>&1
+$DEBUGFS -R "set_bg 2 checksum 0xd318" -w $TMPFILE > /dev/null 2>&1
+$DUMPE2FS $TMPFILE 2>&1 | grep -A10 '^Group 2:' >> $OUT
+#dd if=/dev/zero of=$TMPFILE bs=1 count=1 seek=$((1024 * 20004)) conv=notrunc >> $OUT 2> /dev/null
+$RESIZE2FS_EXE -f -p $TMPFILE 20004 >> $OUT 2>&1
+$DUMPE2FS $TMPFILE 2>&1 | grep -A10 '^Group 2:' >> $OUT
+$E2FSCK -fy $TMPFILE >> $OUT 2>&1
+
+sed -f $cmd_dir/filter.sed -e "s;$TMPFILE;test.img;" < $OUT > $LOG
+rm -rf $OUT
+
+cmp -s $LOG $EXP
+RC=$?
+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 $LOG > $test_name.failed
+fi
+
+unset EXP LOG OUT E2FSCK
+
+else #if test -x $RESIZE2FS_EXE -a -x $DEBUGFS_EXE; then
+	echo "$test_name: $test_description: skipped"
+fi
diff --git a/tests/r_fixup_lastbg_big/expect b/tests/r_fixup_lastbg_big/expect
new file mode 100644
index 0000000..8f302a3
--- /dev/null
+++ b/tests/r_fixup_lastbg_big/expect
@@ -0,0 +1,43 @@
+Creating filesystem with 20000 1k blocks and 1248 inodes
+Superblock backups stored on blocks: 
+	8193
+
+Allocating group tables:    \b\b\bdone                            
+Writing inode tables:    \b\b\bdone                            
+Creating journal (1024 blocks): done
+Writing superblocks and filesystem accounting information:    \b\b\bdone
+
+Group 2: (Blocks 16385-19999) [INODE_UNINIT, ITABLE_ZEROED]
+  Block bitmap at 83 (bg #0 + 82)
+  Inode bitmap at 86 (bg #0 + 85)
+  Inode table at 295-398 (bg #0 + 294)
+  3615 free blocks, 416 free inodes, 0 directories, 416 unused inodes
+  Free blocks: 16385-19999
+  Free inodes: 833-1248
+Group 2: (Blocks 16385-19999)
+  Block bitmap at 83 (bg #0 + 82)
+  Inode bitmap at 86 (bg #0 + 85)
+  Inode table at 295-398 (bg #0 + 294)
+  3615 free blocks, 416 free inodes, 0 directories
+  Free blocks: 16385-19999
+  Free inodes: 833-1248
+Resizing the filesystem on test.img to 40000 (1k) blocks.
+The filesystem on test.img is now 40000 (1k) blocks long.
+
+Group 2: (Blocks 16385-24576) [INODE_UNINIT, BLOCK_UNINIT]
+  Block bitmap at 83 (bg #0 + 82)
+  Inode bitmap at 86 (bg #0 + 85)
+  Inode table at 295-398 (bg #0 + 294)
+  8192 free blocks, 416 free inodes, 0 directories, 416 unused inodes
+  Free blocks: 16385-24576
+  Free inodes: 833-1248
+Group 3: (Blocks 24577-32768) [INODE_UNINIT]
+  Backup superblock at 24577, Group descriptors at 24578-24578
+  Reserved GDT blocks at 24579-24656
+  Block bitmap at 413 (bg #0 + 412)
+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.img: 11/2080 files (0.0% non-contiguous), 1809/40000 blocks
diff --git a/tests/r_fixup_lastbg_big/script b/tests/r_fixup_lastbg_big/script
new file mode 100755
index 0000000..4c4a351
--- /dev/null
+++ b/tests/r_fixup_lastbg_big/script
@@ -0,0 +1,37 @@
+if test -x $RESIZE2FS_EXE -a -x $DEBUGFS_EXE; then
+test_description="fix up last bg when expanding beyond the last bg"
+
+EXP=$test_dir/expect
+OUT=$test_name.out
+LOG=$test_name.log
+E2FSCK=../e2fsck/e2fsck
+
+$MKE2FS -T ext4 -b 1024 -F -U 56d3ee50-8532-4f29-8181-d7c6ea4a94a6 $TMPFILE 20000 > $OUT 2>&1
+$DUMPE2FS $TMPFILE 2>&1 | grep -A10 '^Group 2:' >> $OUT
+$DEBUGFS -R "set_bg 2 itable_unused 0" -w $TMPFILE > /dev/null 2>&1
+$DEBUGFS -R "set_bg 2 flags 0" -w $TMPFILE > /dev/null 2>&1
+$DEBUGFS -R "set_bg 2 checksum 0xd318" -w $TMPFILE > /dev/null 2>&1
+$DUMPE2FS $TMPFILE 2>&1 | grep -A10 '^Group 2:' >> $OUT
+dd if=/dev/zero of=$TMPFILE bs=1 count=1 seek=$((1024 * 40000)) conv=notrunc >> $OUT 2> /dev/null
+$RESIZE2FS_EXE -f -p $TMPFILE >> $OUT 2>&1
+$DUMPE2FS $TMPFILE 2>&1 | grep -A10 '^Group 2:' >> $OUT
+$E2FSCK -fy $TMPFILE >> $OUT 2>&1
+
+sed -f $cmd_dir/filter.sed -e "s;$TMPFILE;test.img;" < $OUT > $LOG
+rm -rf $OUT
+
+cmp -s $LOG $EXP
+RC=$?
+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 $LOG > $test_name.failed
+fi
+
+unset EXP LOG OUT E2FSCK
+
+else #if test -x $RESIZE2FS_EXE -a -x $DEBUGFS_EXE; then
+	echo "$test_name: $test_description: skipped"
+fi


  parent reply	other threads:[~2014-11-07 21:53 UTC|newest]

Thread overview: 104+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-11-07 21:50 [PATCH 00/47] e2fsprogs November 2014 patchbomb Darrick J. Wong
2014-11-07 21:50 ` [PATCH 01/47] tests: fix test scripts that don't work on non-Linux systems Darrick J. Wong
2014-11-08  1:55   ` Theodore Ts'o
2014-11-07 21:50 ` [PATCH 02/47] misc: fix compiler warnings and minor build errors Darrick J. Wong
2014-11-08  2:25   ` Theodore Ts'o
2014-11-07 21:51 ` [PATCH 03/47] dumpe2fs: don't crash when the user provides no block device argument Darrick J. Wong
2014-11-08  2:26   ` Theodore Ts'o
2014-11-07 21:51 ` [PATCH 04/47] libext2fs: fix endian handling error; reduce fragmentation some Darrick J. Wong
2014-11-17 21:26   ` Theodore Ts'o
2014-11-07 21:51 ` [PATCH 05/47] libext2fs: set BLOCK_UNINIT for non-last blockgroups if all blocks are free Darrick J. Wong
2014-11-17 22:47   ` Theodore Ts'o
2014-11-07 21:51 ` [PATCH 06/47] libext2fs: don't allow alloc_stats on bad inode/block numbers Darrick J. Wong
2014-11-17 23:00   ` Theodore Ts'o
2014-11-07 21:51 ` [PATCH 07/47] libext2fs: refactor extent head creation Darrick J. Wong
2014-12-03  3:55   ` Theodore Ts'o
2014-11-07 21:51 ` [PATCH 08/47] libext2fs: file IO routines should handle uninit blocks Darrick J. Wong
2014-12-03  3:57   ` Theodore Ts'o
2014-11-07 21:51 ` [PATCH 09/47] libext2fs: use a dynamically sized (or caller-provided) block zeroing buffer Darrick J. Wong
2014-12-12  2:37   ` Theodore Ts'o
2014-12-12  5:02     ` Darrick J. Wong
2014-12-13 16:24       ` Theodore Ts'o
2014-12-13 16:25         ` Theodore Ts'o
2014-12-15 16:09         ` Andreas Dilger
2014-11-07 21:51 ` [PATCH 10/47] libext2fs: support BLKZEROOUT/FALLOC_FL_ZERO_RANGE in ext2fs_zero_blocks Darrick J. Wong
2014-12-13 16:29   ` Theodore Ts'o
2014-12-14  3:08     ` Darrick J. Wong
2014-11-07 21:51 ` [PATCH 11/47] libext2fs: find inode goal when allocating blocks Darrick J. Wong
2014-12-14  1:13   ` Theodore Ts'o
2014-12-14 21:02     ` Darrick J. Wong
2014-11-07 21:52 ` [PATCH 12/47] libext2fs: set interior tree block goal more intelligently Darrick J. Wong
2014-12-14  1:17   ` Theodore Ts'o
2014-11-07 21:52 ` [PATCH 13/47] libext2fs: add a way to check the theoretical maximum extent tree depth Darrick J. Wong
2014-12-14  2:23   ` Theodore Ts'o
2014-12-14  3:11     ` Darrick J. Wong
2014-12-15  3:48       ` Theodore Ts'o
2014-12-15  6:38         ` Darrick J. Wong
2014-11-07 21:52 ` [PATCH 14/47] libext2fs: ext2fs_new_block2() should call alloc_block hook Darrick J. Wong
2014-11-07 21:52 ` [PATCH 15/47] misc: don't allow mk_hugefiles unless the fs supports extents Darrick J. Wong
2014-12-14  2:51   ` Theodore Ts'o
2014-11-07 21:52 ` [PATCH 16/47] dumpe2fs: 80 column outputs, please Darrick J. Wong
2014-12-14  2:52   ` Theodore Ts'o
2014-11-07 21:52 ` [PATCH 17/47] dumpe2fs: output cleanup Darrick J. Wong
2014-12-14  2:53   ` Theodore Ts'o
2014-11-07 21:52 ` [PATCH 18/47] e2fsck: only complain about no-checksum directory blocks once Darrick J. Wong
2014-12-14  2:55   ` Theodore Ts'o
2014-11-07 21:52 ` [PATCH 19/47] e2fsck: don't complain about root dir csum failures when getting lnf Darrick J. Wong
2014-12-14  2:57   ` Theodore Ts'o
2014-11-07 21:52 ` [PATCH 20/47] tune2fs: warn if extents are not enabled when turning on metadata_csum Darrick J. Wong
2014-12-14  2:58   ` Theodore Ts'o
2014-11-07 21:53 ` [PATCH 21/47] tune2fs: enable uninit_bg when disabling metadata_csum Darrick J. Wong
2014-12-14  2:58   ` Theodore Ts'o
2014-11-07 21:53 ` [PATCH 22/47] tests: testcases for enabling/disabling metadata_csum via tune2fs Darrick J. Wong
2014-12-14  3:00   ` Theodore Ts'o
2014-11-07 21:53 ` [PATCH 23/47] mke2fs: don't zero inode table blocks that are already zeroed Darrick J. Wong
2014-12-14  3:01   ` Theodore Ts'o
2014-11-07 21:53 ` [PATCH 24/47] resize2fs: don't exit if shrinking sparse_super2 fs to one bg Darrick J. Wong
2014-12-14  3:06   ` Theodore Ts'o
2014-11-07 21:53 ` [PATCH 25/47] resize2fs: quickly rewrite extent blocks when moving an inode w/ metadata_csum Darrick J. Wong
2014-12-14  3:09   ` Theodore Ts'o
2014-11-07 21:53 ` [PATCH 26/47] resize2fs: use old_fs to detect per-bg metadata blocks to free Darrick J. Wong
2014-12-15  2:09   ` Theodore Ts'o
2014-11-07 21:53 ` [PATCH 27/47] resize2fs: don't interpret bitmap shift while crossing flexbg as raid stride Darrick J. Wong
2014-12-15  2:11   ` Theodore Ts'o
2014-11-07 21:53 ` Darrick J. Wong [this message]
2014-12-15  2:12   ` [PATCH 28/47] resize2fs: set bg flags and unused inode count when resizing Theodore Ts'o
2014-11-07 21:53 ` [PATCH 29/47] resize2fs: don't mark unallocated bg metadata blocks when fixing bg flags Darrick J. Wong
2014-12-15  2:17   ` Theodore Ts'o
2014-12-15  7:09     ` Darrick J. Wong
2014-12-19 19:15       ` Darrick J. Wong
2014-11-07 21:54 ` [PATCH 30/47] resize2fs: don't play stupid games with the block count Darrick J. Wong
2014-12-15  3:13   ` Theodore Ts'o
2014-11-07 21:54 ` [PATCH 31/47] libext2fs/e2fsck: provide routines to read-ahead metadata Darrick J. Wong
2014-12-15 17:36   ` Theodore Ts'o
2014-12-15 19:19     ` Darrick J. Wong
2014-11-07 21:54 ` [PATCH 32/47] e2fsck: read-ahead metadata during passes 1, 2, and 4 Darrick J. Wong
2014-12-10 20:27   ` Darrick J. Wong
2014-12-10 22:00     ` Theodore Ts'o
2014-11-07 21:54 ` [PATCH 33/47] e2fsck: rebuild sparse extent trees/convert non-extent ext3 files Darrick J. Wong
2014-12-04 23:20   ` Andreas Dilger
2014-12-04 23:45     ` Darrick J. Wong
2014-12-11 22:05   ` [PATCH v2 " Darrick J. Wong
2014-11-07 21:54 ` [PATCH 34/47] tests: verify proper rebuilding of sparse extent trees and block map file conversion Darrick J. Wong
2014-11-07 21:54 ` [PATCH 35/47] resize2fs: convert fs to and from 64bit mode Darrick J. Wong
2014-12-15  3:32   ` Theodore Ts'o
2014-12-15  6:41     ` Darrick J. Wong
2014-12-15 17:46   ` Theodore Ts'o
2014-11-07 21:54 ` [PATCH 36/47] tests: test resize2fs 32->64 and 64->32bit conversion code Darrick J. Wong
2014-12-15 17:46   ` Theodore Ts'o
2014-11-07 21:54 ` [PATCH 37/47] libext2fs: support allocating uninit blocks in bmap2() Darrick J. Wong
2014-11-07 21:54 ` [PATCH 38/47] libext2fs: find/alloc a range of empty blocks Darrick J. Wong
2014-11-07 21:54 ` [PATCH 39/47] libext2fs: add new hooks to support large allocations Darrick J. Wong
2014-11-07 21:55 ` [PATCH 40/47] libext2fs: implement fallocate Darrick J. Wong
2014-11-07 21:55 ` [PATCH 41/47] libext2fs: use fallocate for creating journals and hugefiles Darrick J. Wong
2014-11-07 21:55 ` [PATCH 42/47] debugfs: implement fallocate Darrick J. Wong
2014-11-07 21:55 ` [PATCH 43/47] tests: test debugfs punch command Darrick J. Wong
2014-11-07 21:55 ` [PATCH 45/47] fuse2fs: translate ACL structures Darrick J. Wong
2014-11-07 21:55 ` [PATCH 46/47] fuse2fs: handle 64-bit dates correctly Darrick J. Wong
2014-11-07 21:55 ` [PATCH 47/47] fuse2fs: implement fallocate Darrick J. Wong
2014-11-12 22:43 ` [PATCH 48/47] misc: fix infinite loop when finding the start of the hugefile start range Darrick J. Wong
2014-12-03  3:06   ` Theodore Ts'o
2014-11-27  0:01 ` [PATCH 49/47] libext2fs: don't report garbage inodes with really large inodes Darrick J. Wong
2014-12-03  3:18   ` Theodore Ts'o
2014-12-04 20:39 ` [PATCH 51/47] e2fsck: force-reread of inode from disk when re-checking a checksum error Darrick J. Wong
2014-12-11 22:49   ` Theodore Ts'o

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=20141107215348.883.19810.stgit@birch.djwong.org \
    --to=darrick.wong@oracle.com \
    --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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).