linux-ext4.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Theodore Ts'o <tytso@mit.edu>
To: linux-ext4@vger.kernel.org
Cc: "Jose R. Santos" <jrs@us.ibm.com>,
	Andreas Dilger <adilger@clusterfs.com>,
	"Theodore Ts'o" <tytso@mit.edu>
Subject: [PATCH, REWORKED 04/11] Add support for creating filesystems using uninit block group
Date: Mon, 17 Mar 2008 09:28:40 -0400	[thread overview]
Message-ID: <1205760527-14858-5-git-send-email-tytso@mit.edu> (raw)
In-Reply-To: <1205760527-14858-4-git-send-email-tytso@mit.edu>

From: Jose R. Santos <jrs@us.ibm.com>

Signed-off-by: Jose R. Santos <jrs@us.ibm.com>
Signed-off-by: Andreas Dilger <adilger@clusterfs.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
---
 misc/mke2fs.8.in |    7 +++++++
 misc/mke2fs.c    |   44 ++++++++++++++++++++++++++++++++------------
 2 files changed, 39 insertions(+), 12 deletions(-)

diff --git a/misc/mke2fs.8.in b/misc/mke2fs.8.in
index 14c3ca5..a32c34a 100644
--- a/misc/mke2fs.8.in
+++ b/misc/mke2fs.8.in
@@ -427,6 +427,13 @@ Store file type information in directory entries.
 .TP
 .B has_journal
 Create an ext3 journal (as if using the
+.TP
+.B uninit_groups
+Create a filesystem without initializing all of the groups.  This speeds
+up filesystem creation time noticably, and can also reduce
+.BR e2fsck time
+dramatically.  This feature causes the filesystem to be read-only in
+older kernels is not supported in most Linux kernels, use with caution.
 .B \-j
 option).
 @JDEV@.TP
diff --git a/misc/mke2fs.c b/misc/mke2fs.c
index 072a3a8..acff08b 100644
--- a/misc/mke2fs.c
+++ b/misc/mke2fs.c
@@ -433,6 +433,8 @@ static void write_inode_tables(ext2_filsys fs)
 					num, blk, error_message(retval));
 				exit(1);
 			}
+			/* The kernel doesn't need to zero the itable blocks */
+			fs->group_desc[i].bg_flags |= EXT2_BG_INODE_ZEROED;
 		}
 		if (sync_kludge) {
 			if (sync_kludge == 1)
@@ -448,34 +450,49 @@ static void write_inode_tables(ext2_filsys fs)
 static void setup_lazy_bg(ext2_filsys fs)
 {
 	dgrp_t i;
-	int blks;
+	int blks, csum_flag;
 	struct ext2_super_block *sb = fs->super;
 	struct ext2_group_desc *bg = fs->group_desc;
 
-	if (EXT2_HAS_COMPAT_FEATURE(fs->super, 
-				    EXT2_FEATURE_COMPAT_LAZY_BG)) {
+	csum_flag = EXT2_HAS_RO_COMPAT_FEATURE(fs->super,
+					       EXT4_FEATURE_RO_COMPAT_GDT_CSUM);
+	if (EXT2_HAS_COMPAT_FEATURE(fs->super, EXT2_FEATURE_COMPAT_LAZY_BG) ||
+	    csum_flag) {
 		for (i = 0; i < fs->group_desc_count; i++, bg++) {
 			if ((i == 0) ||
-			    (i == fs->group_desc_count-1))
+			    (i == fs->group_desc_count - 1 && !csum_flag))
 				continue;
 			if (bg->bg_free_inodes_count ==
 			    sb->s_inodes_per_group) {
-				bg->bg_free_inodes_count = 0;
 				bg->bg_flags |= EXT2_BG_INODE_UNINIT;
-				sb->s_free_inodes_count -= 
-					sb->s_inodes_per_group;
+				if (!csum_flag) {
+					bg->bg_free_inodes_count = 0;
+					sb->s_free_inodes_count -=
+						sb->s_inodes_per_group;
+				}
 			}
+
+			/* Skip groups with GDT backups because the resize
+			 * inode has blocks allocated in them, and the last
+			 * group because it needs block bitmap padding. */
+			if ((ext2fs_bg_has_super(fs, i) &&
+			     sb->s_reserved_gdt_blocks) ||
+			    i == fs->group_desc_count - 1)
+				continue;
+
 			blks = ext2fs_super_and_bgd_loc(fs, i, 0, 0, 0, 0);
-			if (bg->bg_free_blocks_count == blks) {
-				bg->bg_free_blocks_count = 0;
+			if (bg->bg_free_blocks_count == blks &&
+			    bg->bg_flags & EXT2_BG_INODE_UNINIT) {
 				bg->bg_flags |= EXT2_BG_BLOCK_UNINIT;
-				sb->s_free_blocks_count -= blks;
+				if (!csum_flag) {
+					bg->bg_free_blocks_count = 0;
+					sb->s_free_blocks_count -= blks;
+				}
 			}
 		}
 	}
 }
 
-
 static void create_root_dir(ext2_filsys fs)
 {
 	errcode_t		retval;
@@ -912,7 +929,8 @@ static __u32 ok_features[3] = {
 		EXT4_FEATURE_INCOMPAT_FLEX_BG,
 	/* R/O compat */
 	EXT2_FEATURE_RO_COMPAT_LARGE_FILE|
-		EXT2_FEATURE_RO_COMPAT_SPARSE_SUPER
+		EXT2_FEATURE_RO_COMPAT_SPARSE_SUPER|
+		EXT4_FEATURE_RO_COMPAT_GDT_CSUM
 };
 
 
@@ -1774,6 +1792,8 @@ int main (int argc, char *argv[])
 	}
 no_journal:
 
+	if (!super_only)
+		ext2fs_set_gdt_csum(fs);
 	if (!quiet)
 		printf(_("Writing superblocks and "
 		       "filesystem accounting information: "));
-- 
1.5.4.1.144.gdfee-dirty


  reply	other threads:[~2008-03-17 13:29 UTC|newest]

Thread overview: 34+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-03-17 13:28 Respin of the uninit_group patches Theodore Ts'o
2008-03-17 13:28 ` [PATCH, REWORKED 01/11] Add initial checksum support for the gdt_checksum/uninit_group feature Theodore Ts'o
2008-03-17 13:28   ` [PATCH, REWORKED 02/11] Add uninit block group support to various libext2fs functions Theodore Ts'o
2008-03-17 13:28     ` [PATCH, REWORKED 03/11] Rename feature name from gdt_checksum to uninit_groups Theodore Ts'o
2008-03-17 13:28       ` Theodore Ts'o [this message]
2008-03-17 13:28         ` [PATCH, REWORKED 05/11] Make tune2fs uninit block group aware Theodore Ts'o
2008-03-17 13:28           ` [PATCH, REWORKED 06/11] Make dumpe2fs " Theodore Ts'o
2008-03-17 13:28             ` [PATCH, REWORKED 07/11] Make resize2fs " Theodore Ts'o
2008-03-17 13:28               ` [PATCH, REWORKED 08/11] Make debugfs " Theodore Ts'o
2008-03-17 13:28                 ` [PATCH, REWORKED 09/11] Make e2fsck " Theodore Ts'o
2008-03-17 13:28                   ` [PATCH, REWORKED 10/11] Add new m_lazy test case Theodore Ts'o
2008-03-17 13:28                     ` [PATCH, REWORKED 11/11] Add m_uninit " Theodore Ts'o
2008-03-17 17:22   ` [PATCH, REWORKED 01/11] Add initial checksum support for the gdt_checksum/uninit_group feature Andreas Dilger
2008-03-17 18:05     ` Theodore Tso
2008-03-18  0:26       ` Andreas Dilger
2008-03-18 23:33 ` Respin of the uninit_group patches Andreas Dilger
2008-03-25  8:40 ` Andreas Dilger
2008-03-31 23:36   ` [PATCH, E2FSPROGS] Improve ext4 feature descriptions in mke2fs and tune2fs man pages Theodore Ts'o
2008-03-31 23:36     ` [PATCH, E2FSPROGS] Fix the copyright notice in lib/ext2fs/tst_csum.c to be GPLv2 only Theodore Ts'o
2008-03-31 23:36       ` [PATCH, E2FSPROGS] debugfs: Add support for "set_block_group <bg_num> checksum calc" Theodore Ts'o
2008-03-31 23:36         ` [PATCH, E2FSPROGS] ext2fs_set_gdt_csum(): Clean up superblock dirty flag handling Theodore Ts'o
2008-03-31 23:36           ` [PATCH, E2FSPROGS] ext2fs_set_gdt_csum(): Force the last block group to have a valid block bitmap Theodore Ts'o
2008-03-31 23:36             ` [PATCH, E2FSPROGS] ext2fs_set_gdt_csum(): Return an error code on errors instead of void Theodore Ts'o
2008-03-31 23:36               ` [PATCH, E2FSPROGS] libext2fs: Micro-optimization in inode scan code Theodore Ts'o
2008-03-31 23:36                 ` [PATCH, E2FSPROGS] Split the m_lazy test case into two cases: m_lazy and m_lazy_resize Theodore Ts'o
2008-03-31 23:36                   ` [PATCH, E2FSPROGS] e2fsck: Add check to enforce a valid block bitmap in last block group Theodore Ts'o
2008-03-31 23:36                     ` [PATCH, E2FSPROGS] Fix trailing whitespace in e2fsck/problem.[ch] Theodore Ts'o
2008-03-31 23:36                       ` [PATCH, E2FSPROGS] Add new regression test: f_uninit_last_uninit Theodore Ts'o
2008-04-01  0:00                       ` [PATCH, E2FSPROGS] Fix trailing whitespace in e2fsck/problem.[ch] Theodore Tso
2008-03-31 23:53               ` [PATCH, E2FSPROGS] ext2fs_set_gdt_csum(): Return an error code on errors instead of void Theodore Tso
2008-03-31 23:52             ` [PATCH, E2FSPROGS] ext2fs_set_gdt_csum(): Force the last block group to have a valid block bitmap Theodore Tso
2008-03-31 23:47           ` [PATCH, E2FSPROGS] ext2fs_set_gdt_csum(): Clean up superblock dirty flag handling Theodore Tso
2008-03-31 23:46         ` [PATCH, E2FSPROGS] debugfs: Add support for "set_block_group <bg_num> checksum calc" Theodore Tso
2008-03-25  9:15 ` Respin of the uninit_group patches Andreas Dilger

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=1205760527-14858-5-git-send-email-tytso@mit.edu \
    --to=tytso@mit.edu \
    --cc=adilger@clusterfs.com \
    --cc=jrs@us.ibm.com \
    --cc=linux-ext4@vger.kernel.org \
    /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).