diff mbox

[RFC,09/17] Add progress bar for allocating block tables - takes forever on large

Message ID 1226461390-5502-10-git-send-email-vaurora@redhat.com
State Superseded, archived
Delegated to: Theodore Ts'o
Headers show

Commit Message

Valerie Aurora Henson Nov. 12, 2008, 3:43 a.m. UTC
Signed-off-by: Valerie Aurora Henson <vaurora@redhat.com>
---
 misc/mke2fs.c               |   25 ++++++++++++++++++++++++-
 tests/f_resize_inode/expect |    1 +
 tests/m_dasd_bs/expect.1    |    1 +
 tests/m_large_file/expect.1 |    1 +
 tests/m_meta_bg/expect.1    |    1 +
 tests/m_no_opt/expect.1     |    1 +
 tests/m_raid_opt/expect.1   |    1 +
 tests/m_std/expect.1        |    1 +
 tests/m_uninit/expect.1     |    1 +
 9 files changed, 32 insertions(+), 1 deletions(-)

Comments

Andreas Dilger Nov. 13, 2008, 7:54 p.m. UTC | #1
On Nov 11, 2008  19:43 -0800, Valerie Aurora Henson wrote:
> +static errcode_t ext2fs_allocate_tables_with_progress(ext2_filsys fs)
> +{
> +	for (i = 0; i < fs->group_desc_count; i++) {
> +		progress_update(&progress, i);
> +		retval = ext2fs_allocate_group_table(fs, i, (ext2fs_block_bitmap64) fs->block_map);
> +		if (retval)
> +			return retval;
> +	}

Does it make sense to only update the progress periodically instead of for
every group?  Since this is a memory operation, I suspect the console
output slows it down noticably, and would spew a ton of garbage into
console logs and such.  Something like:

	for (i = 0; i < fs->group_desc_count; i++) {
		if (i & 256 == 255)
			progress_update(&progress, i);
		retval = ext2fs_allocate_group_table(fs, i, (ext2fs_block_bitmap64) fs->block_map);
		if (retval)
			return retval;
	}
	progress_close(&progress);


Cheers, Andreas
--
Andreas Dilger
Sr. Staff Engineer, Lustre Group
Sun Microsystems of Canada, Inc.

--
To unsubscribe from this list: send the line "unsubscribe linux-ext4" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Valerie Aurora Henson Nov. 14, 2008, 2:45 a.m. UTC | #2
On Thu, Nov 13, 2008 at 12:54:50PM -0700, Andreas Dilger wrote:
> On Nov 11, 2008  19:43 -0800, Valerie Aurora Henson wrote:
> > +static errcode_t ext2fs_allocate_tables_with_progress(ext2_filsys fs)
> > +{
> > +	for (i = 0; i < fs->group_desc_count; i++) {
> > +		progress_update(&progress, i);
> > +		retval = ext2fs_allocate_group_table(fs, i, (ext2fs_block_bitmap64) fs->block_map);
> > +		if (retval)
> > +			return retval;
> > +	}
> 
> Does it make sense to only update the progress periodically instead of for
> every group?  Since this is a memory operation, I suspect the console
> output slows it down noticably, and would spew a ton of garbage into
> console logs and such.  Something like:
> 
> 	for (i = 0; i < fs->group_desc_count; i++) {
> 		if (i & 256 == 255)
> 			progress_update(&progress, i);
> 		retval = ext2fs_allocate_group_table(fs, i, (ext2fs_block_bitmap64) fs->block_map);
> 		if (retval)
> 			return retval;
> 	}
> 	progress_close(&progress);

Heh, I just assumed progress already did that.  How about making the
unit of progress proportional to the total number of tables?  Say,
update progress every thousandth.

Also, this is kind of obnoxious - I just cut and paste
ext2fs_allocate_tables() from its original home because the progress
routines aren't exported.  It may be smarter to export them (for
internal use only) and put the progress into ext2fs_allocate_tables().

-VAL
--
To unsubscribe from this list: send the line "unsubscribe linux-ext4" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/misc/mke2fs.c b/misc/mke2fs.c
index 4509c1a..a3388f6 100644
--- a/misc/mke2fs.c
+++ b/misc/mke2fs.c
@@ -1833,6 +1833,29 @@  static int mke2fs_setup_tdb(const char *name, io_manager *io_ptr)
 	return retval;
 }
 
+static errcode_t ext2fs_allocate_tables_with_progress(ext2_filsys fs)
+{
+	errcode_t	retval;
+	dgrp_t		i;
+	struct progress_struct progress;
+
+	if (quiet)
+		memset(&progress, 0, sizeof(progress));
+	else
+		progress_init(&progress, _("Allocating group tables: "),
+			      fs->group_desc_count);
+
+	for (i = 0; i < fs->group_desc_count; i++) {
+		progress_update(&progress, i);
+		retval = ext2fs_allocate_group_table(fs, i, (ext2fs_block_bitmap64) fs->block_map);
+		if (retval)
+			return retval;
+	}
+	progress_close(&progress);
+
+	return 0;
+}
+
 int main (int argc, char *argv[])
 {
 	errcode_t	retval = 0;
@@ -1963,7 +1986,7 @@  int main (int argc, char *argv[])
 
 	handle_bad_blocks(fs, bb_list);
 	fs->stride = fs_stride = fs->super->s_raid_stride;
-	retval = ext2fs_allocate_tables(fs);
+	retval = ext2fs_allocate_tables_with_progress(fs);
 	if (retval) {
 		com_err(program_name, retval,
 			_("while trying to allocate filesystem tables"));
diff --git a/tests/f_resize_inode/expect b/tests/f_resize_inode/expect
index bd45575..c40deea 100644
--- a/tests/f_resize_inode/expect
+++ b/tests/f_resize_inode/expect
@@ -13,6 +13,7 @@  Maximum filesystem blocks=8421376
 Superblock backups stored on blocks: 
 	1025, 3073, 5121, 7169, 9217
 
+Allocating group tables:  0/16 1/16 2/16 3/16 4/16 5/16 6/16 7/16 8/16 9/1610/1611/1612/1613/1614/1615/16done                            
 Writing inode tables:  0/16 1/16 2/16 3/16 4/16 5/16 6/16 7/16 8/16 9/1610/1611/1612/1613/1614/1615/16done                            
 Writing superblocks and filesystem accounting information: done
 
diff --git a/tests/m_dasd_bs/expect.1 b/tests/m_dasd_bs/expect.1
index 59fc457..5cd3813 100644
--- a/tests/m_dasd_bs/expect.1
+++ b/tests/m_dasd_bs/expect.1
@@ -12,6 +12,7 @@  Maximum filesystem blocks=33554432
 Superblock backups stored on blocks: 
 	16384
 
+Allocating group tables: done                            
 Writing inode tables: done                            
 Writing superblocks and filesystem accounting information: done
 
diff --git a/tests/m_large_file/expect.1 b/tests/m_large_file/expect.1
index ae27f02..90a0940 100644
--- a/tests/m_large_file/expect.1
+++ b/tests/m_large_file/expect.1
@@ -10,6 +10,7 @@  Maximum filesystem blocks=16777216
 32768 blocks per group, 32768 fragments per group
 64 inodes per group
 
+Allocating group tables: done                            
 Writing inode tables: done                            
 Writing superblocks and filesystem accounting information: done
 
diff --git a/tests/m_meta_bg/expect.1 b/tests/m_meta_bg/expect.1
index 7401fd9..95021e2 100644
--- a/tests/m_meta_bg/expect.1
+++ b/tests/m_meta_bg/expect.1
@@ -11,6 +11,7 @@  First data block=1
 Superblock backups stored on blocks: 
 	1025, 3073, 5121, 7169, 9217, 25601, 27649, 50177, 82945, 128001
 
+Allocating group tables: done                            
 Writing inode tables: done                            
 Writing superblocks and filesystem accounting information: done
 
diff --git a/tests/m_no_opt/expect.1 b/tests/m_no_opt/expect.1
index a63358b..c268b63 100644
--- a/tests/m_no_opt/expect.1
+++ b/tests/m_no_opt/expect.1
@@ -11,6 +11,7 @@  First data block=1
 Superblock backups stored on blocks: 
 	8193, 16385, 24577, 32769, 40961, 49153, 57345
 
+Allocating group tables: done                            
 Writing inode tables: done                            
 Writing superblocks and filesystem accounting information: done
 
diff --git a/tests/m_raid_opt/expect.1 b/tests/m_raid_opt/expect.1
index f3c14b6..c99116b 100644
--- a/tests/m_raid_opt/expect.1
+++ b/tests/m_raid_opt/expect.1
@@ -12,6 +12,7 @@  Maximum filesystem blocks=8519680
 Superblock backups stored on blocks: 
 	1025, 3073, 5121, 7169, 9217, 25601, 27649, 50177, 82945, 128001
 
+Allocating group tables: done                            
 Writing inode tables: done                            
 Writing superblocks and filesystem accounting information: done
 
diff --git a/tests/m_std/expect.1 b/tests/m_std/expect.1
index 9f5e66e..c9ff315 100644
--- a/tests/m_std/expect.1
+++ b/tests/m_std/expect.1
@@ -12,6 +12,7 @@  Maximum filesystem blocks=67108864
 Superblock backups stored on blocks: 
 	8193, 24577, 40961, 57345
 
+Allocating group tables: done                            
 Writing inode tables: done                            
 Writing superblocks and filesystem accounting information: done
 
diff --git a/tests/m_uninit/expect.1 b/tests/m_uninit/expect.1
index 02649d8..7419ecf 100644
--- a/tests/m_uninit/expect.1
+++ b/tests/m_uninit/expect.1
@@ -12,6 +12,7 @@  Maximum filesystem blocks=67371008
 Superblock backups stored on blocks: 
 	8193, 24577, 40961, 57345, 73729
 
+Allocating group tables: done                            
 Writing inode tables: done                            
 Writing superblocks and filesystem accounting information: done