linux-ext4.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/5 v2] e2fsprogs: allow meta_bg/64-bit file systems to be online resized
@ 2012-09-13 22:49 Theodore Ts'o
  2012-09-13 22:49 ` [PATCH 1/5] resize2fs: enforce the 16TB limit on 32-bit file systems correctly Theodore Ts'o
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: Theodore Ts'o @ 2012-09-13 22:49 UTC (permalink / raw)
  To: Ext4 Developers List; +Cc: Theodore Ts'o

This patch series enhances resize2fs to allow it to support online
resizing of meta_bg and/or 64-bit file systems.   This was mainly be
fixing the sanity checks which previously wouldn't allow the online
resizing ioctl to be invoked since the userspace resize2fs program
thought the kernel would not support file system parameters.

In addition, the last patch in this series significantly speeds up
off-line resizing of ext4 file systems where the uninit_bg feature is
enabled, by skipping the write out of the inode table.

Theodore Ts'o (5):
  resize2fs: enforce the 16TB limit on 32-bit file systems correctly
  resize2fs: fix overhead calculation for meta_bg file systems
  resize2fs: allow meta_bg/64-bit file systems to be online resized
  resize2fs: enforce restrictions if the kernel doesn't do meta_bg
    resizing
  resize2fs: grow uninit_bg file systems more efficiently

 resize/main.c      | 67 ++++++++++++++++++++++---------------
 resize/online.c    | 41 +++++++++++++++--------
 resize/resize2fs.c | 96 ++++++++++++++++++++++++++++++++++--------------------
 resize/resize2fs.h |  5 +++
 4 files changed, 134 insertions(+), 75 deletions(-)

-- 
1.7.12.rc0.22.gcdd159b


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH 1/5] resize2fs: enforce the 16TB limit on 32-bit file systems correctly
  2012-09-13 22:49 [PATCH 0/5 v2] e2fsprogs: allow meta_bg/64-bit file systems to be online resized Theodore Ts'o
@ 2012-09-13 22:49 ` Theodore Ts'o
  2012-09-13 22:49 ` [PATCH 2/5] resize2fs: fix overhead calculation for meta_bg file systems Theodore Ts'o
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: Theodore Ts'o @ 2012-09-13 22:49 UTC (permalink / raw)
  To: Ext4 Developers List; +Cc: Theodore Ts'o

The 16TB limit must be enforced regardless of whether the new size is
specified on the command line or implied by the size of the device,
but only if the file system does not support 64-bit block sizes, or
the kernel does not advertise support of meta_bg resizing.

Previously we were unconditionally enforcing it when it was implied by
the device size, but not if the new size was specified on the command
line.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
---
 resize/main.c      | 26 ++++++++++++++++++--------
 resize/resize2fs.h |  5 +++++
 2 files changed, 23 insertions(+), 8 deletions(-)

diff --git a/resize/main.c b/resize/main.c
index e6604f2..f8bd983 100644
--- a/resize/main.c
+++ b/resize/main.c
@@ -37,6 +37,7 @@ extern int optind;
 #include "../version.h"
 
 char *program_name, *device_name, *io_options;
+int meta_bg_resizing;
 
 static void usage (char *prog)
 {
@@ -187,6 +188,10 @@ int main (int argc, char ** argv)
 	if (argc && *argv)
 		program_name = *argv;
 
+	if ((access("/sys/fs/ext4/features/meta_bg_resize", R_OK) == 0) &&
+	    !getenv("RESIZE2FS_NO_META_BG_RESIZE"))
+		meta_bg_resizing = 1;
+
 	while ((c = getopt (argc, argv, "d:fFhMPpS:")) != EOF) {
 		switch (c) {
 		case 'h':
@@ -385,19 +390,24 @@ int main (int argc, char ** argv)
 			exit(1);
 		}
 	} else {
-		/* Take down devices exactly 16T to 2^32-1 blocks */
-		if (max_size == (1ULL << 32))
-			max_size--;
-		else if (max_size > (1ULL << 32)) {
-			com_err(program_name, 0, _("New size too large to be "
-				"expressed in 32 bits\n"));
-			exit(1);
-		}
 		new_size = max_size;
 		/* Round down to an even multiple of a pagesize */
 		if (sys_page_size > fs->blocksize)
 			new_size &= ~((sys_page_size / fs->blocksize)-1);
 	}
+	if (!EXT2_HAS_INCOMPAT_FEATURE(fs->super,
+				       EXT4_FEATURE_INCOMPAT_64BIT) ||
+	    !meta_bg_resizing) {
+		/* Take 16T down to 2^32-1 blocks */
+		if (new_size == (1ULL << 32))
+			new_size--;
+		else if (new_size > (1ULL << 32)) {
+			com_err(program_name, 0,
+				_("New size too large to be "
+				  "expressed in 32 bits\n"));
+			exit(1);
+		}
+	}
 
 	if (!force && new_size < min_size) {
 		com_err(program_name, 0,
diff --git a/resize/resize2fs.h b/resize/resize2fs.h
index 2184759..31c2b6d 100644
--- a/resize/resize2fs.h
+++ b/resize/resize2fs.h
@@ -81,6 +81,11 @@ typedef struct ext2_sim_progress *ext2_sim_progmeter;
 #define RESIZE_VERBOSE			0x0200
 
 /*
+ * Is meta_bg resizing supported by the kernel?
+ */
+extern int meta_bg_resizing;
+
+/*
  * The core state structure for the ext2 resizer
  */
 typedef struct ext2_resize_struct *ext2_resize_t;
-- 
1.7.12.rc0.22.gcdd159b


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH 2/5] resize2fs: fix overhead calculation for meta_bg file systems
  2012-09-13 22:49 [PATCH 0/5 v2] e2fsprogs: allow meta_bg/64-bit file systems to be online resized Theodore Ts'o
  2012-09-13 22:49 ` [PATCH 1/5] resize2fs: enforce the 16TB limit on 32-bit file systems correctly Theodore Ts'o
@ 2012-09-13 22:49 ` Theodore Ts'o
  2012-09-13 22:49 ` [PATCH 3/5] resize2fs: allow meta_bg/64-bit file systems to be online resized Theodore Ts'o
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: Theodore Ts'o @ 2012-09-13 22:49 UTC (permalink / raw)
  To: Ext4 Developers List; +Cc: Theodore Ts'o

The file system overhead calculation in calculate_minimum_resize_size
was incorrect meta_bg file systems.  This caused the minimum size to
underflow for very large file systems, which threw resize2fs into a
loop generally lasted longer than the user's patience.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
---
 resize/resize2fs.c | 77 +++++++++++++++++++++++++++++++-----------------------
 1 file changed, 45 insertions(+), 32 deletions(-)

diff --git a/resize/resize2fs.c b/resize/resize2fs.c
index dc2805d..85de144 100644
--- a/resize/resize2fs.c
+++ b/resize/resize2fs.c
@@ -62,10 +62,6 @@ static errcode_t fix_sb_journal_backup(ext2_filsys fs);
 				 ((blk) < (ext2fs_inode_table_loc((fs), (i)) + \
 					   (fs)->inode_blocks_per_group)))
 
-#define META_OVERHEAD(fs) (2 + (fs)->inode_blocks_per_group)
-#define SUPER_OVERHEAD(fs) (1 + (fs)->desc_blocks +\
-			    (fs)->super->s_reserved_gdt_blocks)
-
 /*
  * This is the top-level routine which does the dirty deed....
  */
@@ -1880,6 +1876,27 @@ static errcode_t fix_sb_journal_backup(ext2_filsys fs)
 	return 0;
 }
 
+static int calc_group_overhead(ext2_filsys fs, blk64_t grp,
+			       int old_desc_blocks)
+{
+	blk64_t	super_blk, old_desc_blk, new_desc_blk;
+	int overhead;
+
+	/* inode table blocks plus allocation bitmaps */
+	overhead = fs->inode_blocks_per_group + 2;
+
+	ext2fs_super_and_bgd_loc2(fs, grp, &super_blk,
+				  &old_desc_blk, &new_desc_blk, 0);
+	if ((grp == 0) || super_blk)
+		overhead++;
+	if (old_desc_blk)
+		overhead += old_desc_blocks;
+	else if (new_desc_blk)
+		overhead++;
+	return overhead;
+}
+
+
 /*
  * calcluate the minimum number of blocks the given fs can be resized to
  */
@@ -1890,6 +1907,8 @@ blk64_t calculate_minimum_resize_size(ext2_filsys fs)
 	blk64_t grp, data_needed, last_start;
 	blk64_t overhead = 0;
 	int num_of_superblocks = 0;
+	blk64_t super_overhead = 0;
+	int old_desc_blocks;
 	int extra_groups = 0;
 	int flexbg_size = 1 << fs->super->s_log_groups_per_flex;
 
@@ -1906,28 +1925,29 @@ blk64_t calculate_minimum_resize_size(ext2_filsys fs)
 				   EXT2_BLOCKS_PER_GROUP(fs->super));
 
 	/*
-	 * we need to figure out how many backup superblocks we have so we can
-	 * account for that in the metadata
+	 * number of old-style block group descriptor blocks
 	 */
-	for (grp = 0; grp < fs->group_desc_count; grp++) {
-		if (ext2fs_bg_has_super(fs, grp))
-			num_of_superblocks++;
-	}
+	if (fs->super->s_feature_incompat & EXT2_FEATURE_INCOMPAT_META_BG)
+		old_desc_blocks = fs->super->s_first_meta_bg;
+	else
+		old_desc_blocks = fs->desc_blocks +
+			fs->super->s_reserved_gdt_blocks;
 
 	/* calculate how many blocks are needed for data */
 	data_needed = ext2fs_blocks_count(fs->super) -
 		ext2fs_free_blocks_count(fs->super);
-	data_needed -= SUPER_OVERHEAD(fs) * num_of_superblocks;
-	data_needed -= META_OVERHEAD(fs) * fs->group_desc_count;
 
+	for (grp = 0; grp < fs->group_desc_count; grp++)
+		data_needed -= calc_group_overhead(fs, grp, old_desc_blocks);
+
+	/*
+	 * For ext4 we need to allow for up to a flex_bg worth of
+	 * inode tables of slack space so the resize operation can be
+	 * guaranteed to finish.
+	 */
 	if (fs->super->s_feature_incompat & EXT4_FEATURE_INCOMPAT_FLEX_BG) {
-		/*
-		 * For ext4 we need to allow for up to a flex_bg worth
-		 * of inode tables of slack space so the resize
-		 * operation can be guaranteed to finish.
-		 */
 		extra_groups = flexbg_size - (groups & (flexbg_size - 1));
-		data_needed += META_OVERHEAD(fs) * extra_groups;
+		data_needed += fs->inode_blocks_per_group * extra_groups;
 		extra_groups = groups % flexbg_size;
 	}
 
@@ -1938,10 +1958,7 @@ blk64_t calculate_minimum_resize_size(ext2_filsys fs)
 	data_blocks = groups * EXT2_BLOCKS_PER_GROUP(fs->super);
 	last_start = 0;
 	for (grp = 0; grp < groups; grp++) {
-		overhead = META_OVERHEAD(fs);
-
-		if (ext2fs_bg_has_super(fs, grp))
-			overhead += SUPER_OVERHEAD(fs);
+		overhead = calc_group_overhead(fs, grp, old_desc_blocks);
 
 		/*
 		 * we want to keep track of how much data we can store in
@@ -1970,15 +1987,12 @@ blk64_t calculate_minimum_resize_size(ext2_filsys fs)
 		data_blocks += extra_grps * EXT2_BLOCKS_PER_GROUP(fs->super);
 
 		/* ok we have to account for the last group */
-		overhead = META_OVERHEAD(fs);
-		if (ext2fs_bg_has_super(fs, groups-1))
-			overhead += SUPER_OVERHEAD(fs);
+		overhead = calc_group_overhead(fs, groups-1, old_desc_blocks);
 		last_start += EXT2_BLOCKS_PER_GROUP(fs->super) - overhead;
 
 		for (grp = groups; grp < groups+extra_grps; grp++) {
-			overhead = META_OVERHEAD(fs);
-			if (ext2fs_bg_has_super(fs, grp))
-				overhead += SUPER_OVERHEAD(fs);
+			overhead = calc_group_overhead(fs, grp,
+						       old_desc_blocks);
 
 			/*
 			 * again, we need to see how much data we cram into
@@ -2003,13 +2017,14 @@ blk64_t calculate_minimum_resize_size(ext2_filsys fs)
 			 */
 			extra_groups = flexbg_size -
 						(groups & (flexbg_size - 1));
-			data_needed += META_OVERHEAD(fs) * extra_groups;
+			data_needed += (fs->inode_blocks_per_group *
+					extra_groups);
 			extra_groups = groups % flexbg_size;
 		}
 	}
 
 	/* now for the fun voodoo */
-	overhead = META_OVERHEAD(fs);
+	overhead = calc_group_overhead(fs, groups-1, old_desc_blocks);
 
 	/*
 	 * if this is the case then the last group is going to have data in it
@@ -2031,8 +2046,6 @@ blk64_t calculate_minimum_resize_size(ext2_filsys fs)
 	} else
 		overhead += 50;
 
-	if (ext2fs_bg_has_super(fs, groups-1))
-		overhead += SUPER_OVERHEAD(fs);
 	overhead += fs->super->s_first_data_block;
 
 	/*
-- 
1.7.12.rc0.22.gcdd159b


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH 3/5] resize2fs: allow meta_bg/64-bit file systems to be online resized
  2012-09-13 22:49 [PATCH 0/5 v2] e2fsprogs: allow meta_bg/64-bit file systems to be online resized Theodore Ts'o
  2012-09-13 22:49 ` [PATCH 1/5] resize2fs: enforce the 16TB limit on 32-bit file systems correctly Theodore Ts'o
  2012-09-13 22:49 ` [PATCH 2/5] resize2fs: fix overhead calculation for meta_bg file systems Theodore Ts'o
@ 2012-09-13 22:49 ` Theodore Ts'o
  2012-09-13 22:49 ` [PATCH 4/5] resize2fs: enforce restrictions if the kernel doesn't do meta_bg resizing Theodore Ts'o
  2012-09-13 22:49 ` [PATCH 5/5] resize2fs: grow uninit_bg file systems more efficiently Theodore Ts'o
  4 siblings, 0 replies; 6+ messages in thread
From: Theodore Ts'o @ 2012-09-13 22:49 UTC (permalink / raw)
  To: Ext4 Developers List; +Cc: Theodore Ts'o

Resize2fs can't handle resizing flex_bg file systems that do not have
the resize inode, but when the kernel adds support for resizing using
the meta_bg layout, we should allow it be able to resize the file
system.

So move the flex_bg/resize_inode check to the just before we start
doing the off-line resize, instead of doing it earlier where it would
prohibit these file systems for both on-line and off-line resizes.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
---
 resize/main.c | 41 ++++++++++++++++++++++-------------------
 1 file changed, 22 insertions(+), 19 deletions(-)

diff --git a/resize/main.c b/resize/main.c
index f8bd983..67418ea 100644
--- a/resize/main.c
+++ b/resize/main.c
@@ -321,25 +321,6 @@ int main (int argc, char ** argv)
 		exit(1);
 	}
 
-	/*
-	 * XXXX   The combination of flex_bg and !resize_inode causes
-	 * major problems for resize2fs, since when the group descriptors
-	 * grow in size this can potentially require multiple inode
-	 * tables to be moved aside to make room, and resize2fs chokes
-	 * rather badly in this scenario.  It's a rare combination,
-	 * except when a filesystem is expanded more than a certain
-	 * size, so for now, we'll just prohibit that combination.
-	 * This is something we should fix eventually, though.
-	 */
-	if ((fs->super->s_feature_incompat & EXT4_FEATURE_INCOMPAT_FLEX_BG) &&
-	    !(fs->super->s_feature_compat & EXT2_FEATURE_COMPAT_RESIZE_INODE)) {
-		com_err(program_name, 0, _("%s: The combination of flex_bg "
-					   "and\n\t!resize_inode features "
-					   "is not supported by resize2fs.\n"),
-			device_name);
-		exit(1);
-	}
-
 	min_size = calculate_minimum_resize_size(fs);
 
 	if (print_min_size) {
@@ -463,6 +444,28 @@ int main (int argc, char ** argv)
 				device_name);
 			exit(1);
 		}
+		/*
+		 * XXXX The combination of flex_bg and !resize_inode
+		 * causes major problems for resize2fs, since when the
+		 * group descriptors grow in size this can potentially
+		 * require multiple inode tables to be moved aside to
+		 * make room, and resize2fs chokes rather badly in
+		 * this scenario.  It's a rare combination, except
+		 * when a filesystem is expanded more than a certain
+		 * size, so for now, we'll just prohibit that
+		 * combination.  This is something we should fix
+		 * eventually, though.
+		 */
+		if ((fs->super->s_feature_incompat &
+		     EXT4_FEATURE_INCOMPAT_FLEX_BG) &&
+		    !(fs->super->s_feature_compat &
+		      EXT2_FEATURE_COMPAT_RESIZE_INODE)) {
+			com_err(program_name, 0, _("%s: The combination of "
+				"flex_bg and\n\t!resize_inode features "
+				"is not supported by resize2fs.\n"),
+				device_name);
+			exit(1);
+		}
 		printf(_("Resizing the filesystem on "
 			 "%s to %llu (%dk) blocks.\n"),
 		       device_name, new_size, fs->blocksize / 1024);
-- 
1.7.12.rc0.22.gcdd159b


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH 4/5] resize2fs: enforce restrictions if the kernel doesn't do meta_bg resizing
  2012-09-13 22:49 [PATCH 0/5 v2] e2fsprogs: allow meta_bg/64-bit file systems to be online resized Theodore Ts'o
                   ` (2 preceding siblings ...)
  2012-09-13 22:49 ` [PATCH 3/5] resize2fs: allow meta_bg/64-bit file systems to be online resized Theodore Ts'o
@ 2012-09-13 22:49 ` Theodore Ts'o
  2012-09-13 22:49 ` [PATCH 5/5] resize2fs: grow uninit_bg file systems more efficiently Theodore Ts'o
  4 siblings, 0 replies; 6+ messages in thread
From: Theodore Ts'o @ 2012-09-13 22:49 UTC (permalink / raw)
  To: Ext4 Developers List; +Cc: Theodore Ts'o

Enhance the online resizing code to be more nuanced about resizing
restrictions.  If the kernel supports meta_bg resizing, then we can
skip all of the restrictions.  If the kernel does not support meta_bg
resizing, check more carefully to make sure there are enough reserved
gdt blocks, so that the user gets a clearer error message.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
---
 resize/online.c | 41 ++++++++++++++++++++++++++++-------------
 1 file changed, 28 insertions(+), 13 deletions(-)

diff --git a/resize/online.c b/resize/online.c
index 966ea1e..98190cb 100644
--- a/resize/online.c
+++ b/resize/online.c
@@ -56,12 +56,34 @@ errcode_t online_resize_fs(ext2_filsys fs, const char *mtpt,
 		EXT2_DESC_PER_BLOCK(fs->super));
 	printf("old_desc_blocks = %lu, new_desc_blocks = %lu\n",
 	       fs->desc_blocks, new_desc_blocks);
-	if (!(fs->super->s_feature_compat &
-	      EXT2_FEATURE_COMPAT_RESIZE_INODE) &&
-	    new_desc_blocks != fs->desc_blocks) {
-		com_err(program_name, 0,
-			_("Filesystem does not support online resizing"));
-		exit(1);
+
+	/*
+	 * Do error checking to make sure the resize will be successful.
+	 */
+	if (!meta_bg_resizing) {
+		if (!EXT2_HAS_COMPAT_FEATURE(fs->super,
+					EXT2_FEATURE_COMPAT_RESIZE_INODE) &&
+		    (new_desc_blocks != fs->desc_blocks)) {
+			com_err(program_name, 0,
+				_("Filesystem does not support online resizing"));
+			exit(1);
+		}
+
+		if (EXT2_HAS_COMPAT_FEATURE(fs->super,
+					EXT2_FEATURE_COMPAT_RESIZE_INODE) &&
+		    new_desc_blocks > (fs->desc_blocks +
+				       fs->super->s_reserved_gdt_blocks)) {
+			com_err(program_name, 0,
+				_("Not enough reserved gdt blocks for resizing"));
+			exit(1);
+		}
+
+		if ((ext2fs_blocks_count(sb) > MAX_32_NUM) ||
+		    (*new_size > MAX_32_NUM)) {
+			com_err(program_name, 0,
+				_("Kernel does not support resizing a file system this large"));
+			exit(1);
+		}
 	}
 
 	fd = open(mtpt, O_RDONLY);
@@ -101,13 +123,6 @@ errcode_t online_resize_fs(ext2_filsys fs, const char *mtpt,
 		return 0;
 	}
 
-	if ((ext2fs_blocks_count(sb) > MAX_32_NUM) ||
-	    (*new_size > MAX_32_NUM)) {
-		com_err(program_name, 0,
-			_("Kernel does not support resizing a file system "
-			  "this large"));
-		exit(1);
-	}
 	size = ext2fs_blocks_count(sb);
 
 	if (ioctl(fd, EXT2_IOC_GROUP_EXTEND, &size)) {
-- 
1.7.12.rc0.22.gcdd159b


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH 5/5] resize2fs: grow uninit_bg file systems more efficiently
  2012-09-13 22:49 [PATCH 0/5 v2] e2fsprogs: allow meta_bg/64-bit file systems to be online resized Theodore Ts'o
                   ` (3 preceding siblings ...)
  2012-09-13 22:49 ` [PATCH 4/5] resize2fs: enforce restrictions if the kernel doesn't do meta_bg resizing Theodore Ts'o
@ 2012-09-13 22:49 ` Theodore Ts'o
  4 siblings, 0 replies; 6+ messages in thread
From: Theodore Ts'o @ 2012-09-13 22:49 UTC (permalink / raw)
  To: Ext4 Developers List; +Cc: Theodore Ts'o

If the uninit_bg feature is enabled and the kernel supports
lazy_itable_init, skip zeroing the inode table so that the resize
operation can go much more quickly.  Also set the itable_unused fields
so that the first e2fsck after the resize will run faster.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
---
 resize/resize2fs.c | 28 +++++++++++++++++++++++++---
 1 file changed, 25 insertions(+), 3 deletions(-)

diff --git a/resize/resize2fs.c b/resize/resize2fs.c
index 85de144..861acff 100644
--- a/resize/resize2fs.c
+++ b/resize/resize2fs.c
@@ -62,6 +62,8 @@ static errcode_t fix_sb_journal_backup(ext2_filsys fs);
 				 ((blk) < (ext2fs_inode_table_loc((fs), (i)) + \
 					   (fs)->inode_blocks_per_group)))
 
+int lazy_itable_init;
+
 /*
  * This is the top-level routine which does the dirty deed....
  */
@@ -480,6 +482,8 @@ retry:
 
 	csum_flag = EXT2_HAS_RO_COMPAT_FEATURE(fs->super,
 					       EXT4_FEATURE_RO_COMPAT_GDT_CSUM);
+	if (access("/sys/fs/ext4/features/lazy_itable_init", F_OK) == 0)
+		lazy_itable_init = 1;
 	adj = old_fs->group_desc_count;
 	max_group = fs->group_desc_count - adj;
 	if (fs->super->s_feature_incompat & EXT2_FEATURE_INCOMPAT_META_BG)
@@ -494,8 +498,14 @@ retry:
 		adjblocks = 0;
 
 		ext2fs_bg_flags_zap(fs, i);
-		if (csum_flag)
-			ext2fs_bg_flags_set(fs, i, EXT2_BG_INODE_UNINIT | EXT2_BG_INODE_ZEROED);
+		if (csum_flag) {
+			ext2fs_bg_flags_set(fs, i, EXT2_BG_INODE_UNINIT);
+			if (!lazy_itable_init)
+				ext2fs_bg_flags_set(fs, i,
+						    EXT2_BG_INODE_ZEROED);
+			ext2fs_bg_itable_unused_set(fs, i,
+					fs->super->s_inodes_per_group);
+		}
 
 		numblocks = ext2fs_group_blocks_count(fs, i);
 		if ((i < fs->group_desc_count - 1) && csum_flag)
@@ -608,7 +618,19 @@ static errcode_t adjust_superblock(ext2_resize_t rfs, blk64_t new_size)
 	}
 
 	/*
-	 * Initialize the new block group descriptors
+	 * If we are using uninit_bg (aka GDT_CSUM) and the kernel
+	 * supports lazy inode initialization, we can skip
+	 * initializing the inode table.
+	 */
+	if (lazy_itable_init &&
+	    EXT2_HAS_RO_COMPAT_FEATURE(fs->super,
+				       EXT4_FEATURE_RO_COMPAT_GDT_CSUM)) {
+		retval = 0;
+		goto errout;
+	}
+
+	/*
+	 * Initialize the inode table
 	 */
 	retval = ext2fs_get_array(fs->blocksize, fs->inode_blocks_per_group,
 				&rfs->itable_buf);
-- 
1.7.12.rc0.22.gcdd159b


^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2012-09-13 23:26 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-09-13 22:49 [PATCH 0/5 v2] e2fsprogs: allow meta_bg/64-bit file systems to be online resized Theodore Ts'o
2012-09-13 22:49 ` [PATCH 1/5] resize2fs: enforce the 16TB limit on 32-bit file systems correctly Theodore Ts'o
2012-09-13 22:49 ` [PATCH 2/5] resize2fs: fix overhead calculation for meta_bg file systems Theodore Ts'o
2012-09-13 22:49 ` [PATCH 3/5] resize2fs: allow meta_bg/64-bit file systems to be online resized Theodore Ts'o
2012-09-13 22:49 ` [PATCH 4/5] resize2fs: enforce restrictions if the kernel doesn't do meta_bg resizing Theodore Ts'o
2012-09-13 22:49 ` [PATCH 5/5] resize2fs: grow uninit_bg file systems more efficiently Theodore Ts'o

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).