linux-ext4.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Jose R. Santos" <jrs@us.ibm.com>
To: linux-ext4@vger.kernel.org
Subject: [PATCH 05/14] Add support for creating filesystems using uninit block group.
Date: Sun, 21 Oct 2007 21:03:36 -0500	[thread overview]
Message-ID: <20071022020335.23849.59727.stgit@toolssf2> (raw)
In-Reply-To: <20071022020308.23849.98773.stgit@toolssf2>


Add support for creating filesystems using uninit block group.

Signed-off-by: Jose R. Santos <jrs@us.ibm.com>
Signed-Off-By: Andreas Dilger <adilger@clusterfs.com>
--

 misc/mke2fs.c |   44 ++++++++++++++++++++++++++++++++------------
 1 files changed, 32 insertions(+), 12 deletions(-)

diff --git a/misc/mke2fs.c b/misc/mke2fs.c
index 4a6cace..8360c51 100644
--- a/misc/mke2fs.c
+++ b/misc/mke2fs.c
@@ -432,6 +432,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)
@@ -447,34 +449,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;
@@ -874,7 +891,8 @@ static __u32 ok_features[3] = {
 	EXT2_FEATURE_INCOMPAT_FILETYPE|		/* Incompat */
 		EXT3_FEATURE_INCOMPAT_JOURNAL_DEV|
 		EXT2_FEATURE_INCOMPAT_META_BG,
-	EXT2_FEATURE_RO_COMPAT_SPARSE_SUPER	/* R/O compat */
+	EXT2_FEATURE_RO_COMPAT_SPARSE_SUPER|	/* R/O compat */
+		EXT4_FEATURE_RO_COMPAT_GDT_CSUM
 };
 
 
@@ -1750,6 +1768,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: "));

  parent reply	other threads:[~2007-10-22  2:07 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-10-22  2:03 [PATCH 2 00/14][e2fsprogs] Uninit block group break down Jose R. Santos
2007-10-22  2:03 ` [PATCH 01/14] Reorder some of the $(SRCS) in alphabetical order Jose R. Santos
2007-10-22  2:03 ` [PATCH 02/14] Add initial checksum support Jose R. Santos
2007-10-22  2:03 ` [PATCH 03/14] Add uninit block group support on libe2fs Jose R. Santos
2007-10-22  2:03 ` [PATCH 04/14] Rename feature name from gdt_checksum to uninit_groups Jose R. Santos
2007-10-22  2:03 ` Jose R. Santos [this message]
2007-10-22  2:03 ` [PATCH 06/14] Make tune2fs uninit block group aware Jose R. Santos
2007-10-22  2:03 ` [PATCH 07/14] Make dumpe2fs " Jose R. Santos
2007-10-22  2:03 ` [PATCH 08/14] Make resize2fs " Jose R. Santos
2007-10-22  2:03 ` [PATCH 09/14] Make debugfs " Jose R. Santos
2007-10-22  2:04 ` [PATCH 10/14] Make e2fsck " Jose R. Santos
2007-10-22 16:02   ` Jose R. Santos
2007-10-22 18:21     ` Theodore Tso
2007-10-22  2:04 ` [PATCH 11/14] Update uninit block group documetation for some of the utilities Jose R. Santos
2007-10-22  2:04 ` [PATCH 12/14] Fix test cases Jose R. Santos
2007-10-22  2:04 ` [PATCH 13/14] Add new mm_lazy test case Jose R. Santos
2007-10-22  2:04 ` [PATCH 14/14] Add m_uninit " Jose R. Santos

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=20071022020335.23849.59727.stgit@toolssf2 \
    --to=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).