All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/2] dumpe2fs: dump blocks count used by super and GDT
@ 2011-11-16  1:02 Yongqiang Yang
  2011-11-16  1:02 ` [PATCH 2/2] libext2fs: remove useless code in ext2fs_super_and_bgd_loc2 Yongqiang Yang
  2011-11-20  4:43 ` [PATCH 1/2] dumpe2fs: dump blocks count used by super and GDT Ted Ts'o
  0 siblings, 2 replies; 5+ messages in thread
From: Yongqiang Yang @ 2011-11-16  1:02 UTC (permalink / raw)
  To: tytso; +Cc: linux-ext4, Yongqiang Yang

Blocks count used by super and GDT is dumped so that users
can know how many blocks are taken up by super and GDT.

Signed-off-by: Yongqiang Yang <xiaoqiangnk@gmail.com>
---
 misc/dumpe2fs.c |   32 ++++++++++++++++++++++++++++++++
 1 files changed, 32 insertions(+), 0 deletions(-)

diff --git a/misc/dumpe2fs.c b/misc/dumpe2fs.c
index 5b114e9..2f9e87b 100644
--- a/misc/dumpe2fs.c
+++ b/misc/dumpe2fs.c
@@ -489,6 +489,32 @@ static void parse_extended_opts(const char *opts, blk64_t *superblock,
 	free(buf);
 }
 
+void print_super_gdt_blocks_count (ext2_filsys fs) {
+	blk64_t gdt_blks = 0, super_blks = 0;
+	blk64_t	super_blk, old_desc_blk, new_desc_blk;
+	blk64_t old_desc_blocks;
+	unsigned int grp;
+
+	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;
+
+	for (grp = 0; grp < fs->group_desc_count; grp++) {
+		ext2fs_super_and_bgd_loc2(fs, grp, &super_blk,
+					  &old_desc_blk, &new_desc_blk, 0);
+		if (old_desc_blk)
+			gdt_blks += old_desc_blocks + 
+				    fs->super->s_reserved_gdt_blocks;
+		else if (new_desc_blk)
+			gdt_blks++;
+		super_blks += ((grp == 0) || super_blk);
+	}
+	printf("\nSuper blocks:             %llu\n", super_blks);
+	printf("GDT   blocks:             %llu\n", gdt_blks);
+}
+
+
 int main (int argc, char ** argv)
 {
 	errcode_t	retval;
@@ -588,6 +614,12 @@ int main (int argc, char ** argv)
 		     EXT3_FEATURE_COMPAT_HAS_JOURNAL) &&
 		    (fs->super->s_journal_inum != 0))
 			print_inline_journal_information(fs);
+
+		/*
+		 * Print block used by super and group descriptors.
+		 */
+		print_super_gdt_blocks_count(fs);
+
 		list_bad_blocks(fs, 0);
 		if (header_only) {
 			ext2fs_close (fs);
-- 
1.7.5.1


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

* [PATCH 2/2] libext2fs: remove useless code in ext2fs_super_and_bgd_loc2
  2011-11-16  1:02 [PATCH 1/2] dumpe2fs: dump blocks count used by super and GDT Yongqiang Yang
@ 2011-11-16  1:02 ` Yongqiang Yang
  2011-11-20  4:43 ` [PATCH 1/2] dumpe2fs: dump blocks count used by super and GDT Ted Ts'o
  1 sibling, 0 replies; 5+ messages in thread
From: Yongqiang Yang @ 2011-11-16  1:02 UTC (permalink / raw)
  To: tytso; +Cc: linux-ext4, Yongqiang Yang

Code below is useless because has_super is either 0 or 1.

if (has_super)
	has_super = 1;

Signed-off-by: Yongqiang Yang <xiaoqiangnk@gmail.com>
---
 lib/ext2fs/closefs.c |    2 --
 1 files changed, 0 insertions(+), 2 deletions(-)

diff --git a/lib/ext2fs/closefs.c b/lib/ext2fs/closefs.c
index 973c2a2..54a24f8 100644
--- a/lib/ext2fs/closefs.c
+++ b/lib/ext2fs/closefs.c
@@ -102,8 +102,6 @@ errcode_t ext2fs_super_and_bgd_loc2(ext2_filsys fs,
 		if (((group % meta_bg_size) == 0) ||
 		    ((group % meta_bg_size) == 1) ||
 		    ((group % meta_bg_size) == (meta_bg_size-1))) {
-			if (has_super)
-				has_super = 1;
 			new_desc_blk = group_block + has_super;
 			numblocks++;
 		}
-- 
1.7.5.1


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

* Re: [PATCH 1/2] dumpe2fs: dump blocks count used by super and GDT
  2011-11-16  1:02 [PATCH 1/2] dumpe2fs: dump blocks count used by super and GDT Yongqiang Yang
  2011-11-16  1:02 ` [PATCH 2/2] libext2fs: remove useless code in ext2fs_super_and_bgd_loc2 Yongqiang Yang
@ 2011-11-20  4:43 ` Ted Ts'o
  2011-11-20  7:08   ` Yongqiang Yang
  1 sibling, 1 reply; 5+ messages in thread
From: Ted Ts'o @ 2011-11-20  4:43 UTC (permalink / raw)
  To: Yongqiang Yang; +Cc: linux-ext4

On Wed, Nov 16, 2011 at 09:02:07AM +0800, Yongqiang Yang wrote:
> Blocks count used by super and GDT is dumped so that users
> can know how many blocks are taken up by super and GDT.
> 
> Signed-off-by: Yongqiang Yang <xiaoqiangnk@gmail.com>

I'm not convinced this is sufficiently useful to be worth adding to
dumpe2fs.  How many users really need to know this?

	       	    	  	      - Ted

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

* Re: [PATCH 1/2] dumpe2fs: dump blocks count used by super and GDT
  2011-11-20  4:43 ` [PATCH 1/2] dumpe2fs: dump blocks count used by super and GDT Ted Ts'o
@ 2011-11-20  7:08   ` Yongqiang Yang
  2011-11-20 18:28     ` Ted Ts'o
  0 siblings, 1 reply; 5+ messages in thread
From: Yongqiang Yang @ 2011-11-20  7:08 UTC (permalink / raw)
  To: Ted Ts'o; +Cc: linux-ext4

On Sun, Nov 20, 2011 at 12:43 PM, Ted Ts'o <tytso@mit.edu> wrote:
> On Wed, Nov 16, 2011 at 09:02:07AM +0800, Yongqiang Yang wrote:
>> Blocks count used by super and GDT is dumped so that users
>> can know how many blocks are taken up by super and GDT.
>>
>> Signed-off-by: Yongqiang Yang <xiaoqiangnk@gmail.com>
>
> I'm not convinced this is sufficiently useful to be worth adding to
> dumpe2fs.  How many users really need to know this?
Some users are confused by static metadata blocks allocated by extN
file systems.   Blocks used as inode tables and bitmaps can be
calculated by data from dumpe2fs.  However, blocks taken up by super
blocks and GDT can not be calculated.   So this patch prints the
number of blocks used by super blocks and GDT.   IMHO, it is useful
for some users who know little about extN.   I met several users who
ask why a fresh ext4 has used so many blocks compared to others.    I
know most of them are used as inode tables.   Without this patch, we
can explain the problem.   I just think we can explain the problem
with explicit numbers with the patch.


Yongqiang.
>
>                                      - Ted
>



-- 
Best Wishes
Yongqiang Yang
--
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

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

* Re: [PATCH 1/2] dumpe2fs: dump blocks count used by super and GDT
  2011-11-20  7:08   ` Yongqiang Yang
@ 2011-11-20 18:28     ` Ted Ts'o
  0 siblings, 0 replies; 5+ messages in thread
From: Ted Ts'o @ 2011-11-20 18:28 UTC (permalink / raw)
  To: Yongqiang Yang; +Cc: linux-ext4

On Sun, Nov 20, 2011 at 03:08:23PM +0800, Yongqiang Yang wrote:
> Some users are confused by static metadata blocks allocated by extN
> file systems.   Blocks used as inode tables and bitmaps can be
> calculated by data from dumpe2fs.  However, blocks taken up by super
> blocks and GDT can not be calculated.   So this patch prints the
> number of blocks used by super blocks and GDT.   IMHO, it is useful
> for some users who know little about extN.   I met several users who
> ask why a fresh ext4 has used so many blocks compared to others.    I
> know most of them are used as inode tables.   Without this patch, we
> can explain the problem.   I just think we can explain the problem
> with explicit numbers with the patch.

The reason most of the users are complaining is not because of
superblocks and the GDT blocks, however.  It's really the inode table
blocks (somewhat), and especially, the 5% reserved blocks for root.
This is the sort of thing that's better explained in a FAQ entry,
since most users are also not likely to use dumpe2fs.

And if they are going to use dumpe2fs, I'd much rather the FAQ entry
explain it and they can then look at the details of the block layout
in the dumpe2fs output (i."e. dumpe2fs /dev/hdXX | grep superblock")
if they really need to count the number of superblocks.

   	       	       	     	 	   - Ted

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

end of thread, other threads:[~2011-11-20 18:28 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-11-16  1:02 [PATCH 1/2] dumpe2fs: dump blocks count used by super and GDT Yongqiang Yang
2011-11-16  1:02 ` [PATCH 2/2] libext2fs: remove useless code in ext2fs_super_and_bgd_loc2 Yongqiang Yang
2011-11-20  4:43 ` [PATCH 1/2] dumpe2fs: dump blocks count used by super and GDT Ted Ts'o
2011-11-20  7:08   ` Yongqiang Yang
2011-11-20 18:28     ` Ted Ts'o

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.