* [PATCH] fix debugfs output for flex_bg bitmap offsets @ 2010-11-25 9:57 Andreas Dilger 2010-11-25 19:09 ` Andreas Dilger 0 siblings, 1 reply; 4+ messages in thread From: Andreas Dilger @ 2010-11-25 9:57 UTC (permalink / raw) To: Theodore Tso; +Cc: Ext4 Developers List When running debugfs on a filesystem formatted with flex_bg, it prints out the relative offsets for the bitmaps and inode table badly on 64-bit systems, because the offset is computed as a large positive number instead of being a negative numer (which will not be printed at all): Group 1: (Blocks 0x8000-0xffff) [INODE_UNINIT, ITABLE_ZEROED] Block bitmap at 0x0102 (+4294934786), Inode bitmap at 0x0202 (+4294935042) Inode table at 0x037e-0x03fa (+4294935422) The attached patch prints out the relative offsets for flex_bg groups as the offset within the reported group. This makes it more clear where the metadata is located, rather than simply printing some large negative number. Group 1: (Blocks 0x8000-0xffff) [INODE_UNINIT, ITABLE_ZEROED] Block bitmap at 0x0102 (group 0 +258), Inode bitmap at 0x0202 (group 0 +514) Inode table at 0x037e-0x03fa (group 0 +894) Signed-off-by: Andreas Dilger <adilger@dilger.ca> -- Cheers, Andreas ^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] fix debugfs output for flex_bg bitmap offsets 2010-11-25 9:57 [PATCH] fix debugfs output for flex_bg bitmap offsets Andreas Dilger @ 2010-11-25 19:09 ` Andreas Dilger 2010-11-27 0:33 ` Andreas Dilger 0 siblings, 1 reply; 4+ messages in thread From: Andreas Dilger @ 2010-11-25 19:09 UTC (permalink / raw) To: Theodore Tso; +Cc: Ext4 Developers List [-- Attachment #1: Type: text/plain, Size: 1074 bytes --] ...with patch this time... On 2010-11-25, at 02:57, Andreas Dilger wrote: > When running debugfs on a filesystem formatted with flex_bg, it prints out the relative offsets for the bitmaps and inode table badly on 64-bit systems, because the offset is computed as a large positive number instead of being a negative numer (which will not be printed at all): > > Group 1: (Blocks 0x8000-0xffff) [INODE_UNINIT, ITABLE_ZEROED] > Block bitmap at 0x0102 (+4294934786), Inode bitmap at 0x0202 (+4294935042) > Inode table at 0x037e-0x03fa (+4294935422) > > The attached patch prints out the relative offsets for flex_bg groups as the offset within the reported group. This makes it more clear where the metadata is located, rather than simply printing some large negative number. > > Group 1: (Blocks 0x8000-0xffff) [INODE_UNINIT, ITABLE_ZEROED] > Block bitmap at 0x0102 (group 0 +258), Inode bitmap at 0x0202 (group 0 +514) > Inode table at 0x037e-0x03fa (group 0 +894) > > Signed-off-by: Andreas Dilger <adilger@dilger.ca> > -- Cheers, Andreas [-- Attachment #2: e2fsprogs-debugfs_flexbg.patch --] [-- Type: application/octet-stream, Size: 2082 bytes --] diff --git a/misc/dumpe2fs.c b/misc/dumpe2fs.c index a70cc4e..a9ae299 100644 --- a/misc/dumpe2fs.c +++ b/misc/dumpe2fs.c @@ -126,10 +126,22 @@ static void print_bg_opts(ext2_filsys fs, dgrp_t i) fputc('\n', stdout); } +static void print_bg_rel_offset(ext2_filsys fs, blk64_t block, + blk64_t first_block, blk64_t last_block) +{ + if (block >= first_block && block <= last_block) { + printf(" (+%u)", (unsigned)(block - first_block)); + } else if (fs->super->s_feature_incompat & + EXT4_FEATURE_INCOMPAT_FLEX_BG) { + dgrp_t flex_grp = ext2fs_group_of_blk(fs, block); + printf(" (group %u +%u)", flex_grp, + (unsigned)(block-ext2fs_group_first_block(fs,flex_grp))); + } +} + static void list_desc (ext2_filsys fs) { unsigned long i; - long diff; blk_t first_block, last_block; blk_t super_blk, old_desc_blk, new_desc_blk; char *block_bitmap=NULL, *inode_bitmap=NULL; @@ -199,21 +211,21 @@ static void list_desc (ext2_filsys fs) fputc('\n', stdout); fputs(_(" Block bitmap at "), stdout); print_number(fs->group_desc[i].bg_block_bitmap); - diff = fs->group_desc[i].bg_block_bitmap - first_block; - if (diff >= 0) - printf(" (+%ld)", diff); + print_bg_rel_offset(fs, fs->group_desc[i].bg_block_bitmap, + first_block, last_block); + fputs(_(", Inode bitmap at "), stdout); print_number(fs->group_desc[i].bg_inode_bitmap); - diff = fs->group_desc[i].bg_inode_bitmap - first_block; - if (diff >= 0) - printf(" (+%ld)", diff); + print_bg_rel_offset(fs, fs->group_desc[i].bg_inode_bitmap, + first_block, last_block); + fputs(_("\n Inode table at "), stdout); print_range(fs->group_desc[i].bg_inode_table, fs->group_desc[i].bg_inode_table + inode_blocks_per_group - 1); - diff = fs->group_desc[i].bg_inode_table - first_block; - if (diff > 0) - printf(" (+%ld)", diff); + print_bg_rel_offset(fs, fs->group_desc[i].bg_inode_table, + first_block, last_block); + printf (_("\n %u free blocks, %u free inodes, " "%u directories%s"), fs->group_desc[i].bg_free_blocks_count, ^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] fix debugfs output for flex_bg bitmap offsets 2010-11-25 19:09 ` Andreas Dilger @ 2010-11-27 0:33 ` Andreas Dilger 2010-12-06 3:16 ` Ted Ts'o 0 siblings, 1 reply; 4+ messages in thread From: Andreas Dilger @ 2010-11-27 0:33 UTC (permalink / raw) To: Andreas Dilger; +Cc: Theodore Tso, Ext4 Developers List [-- Attachment #1: Type: text/plain, Size: 1407 bytes --] On 2010-11-25, at 12:09, Andreas Dilger wrote: > ...with patch this time... Attached is an updated patch that makes the output a bit more verbose (to avoid line wraps) and doesn't fail the m_raid_opts test (which complains when "(+0)" is printed for each inode table). > On 2010-11-25, at 02:57, Andreas Dilger wrote: >> When running debugfs on a filesystem formatted with flex_bg, it prints out the relative offsets for the bitmaps and inode table badly on 64-bit systems, because the offset is computed as a large positive number instead of being a negative numer (which will not be printed at all): >> >> Group 1: (Blocks 0x8000-0xffff) [INODE_UNINIT, ITABLE_ZEROED] >> Block bitmap at 0x0102 (+4294934786), Inode bitmap at 0x0202 (+4294935042) >> Inode table at 0x037e-0x03fa (+4294935422) >> >> The attached patch prints out the relative offsets for flex_bg groups as the offset within the reported group. This makes it more clear where the metadata is located, rather than simply printing some large negative number. >> >> Group 1: (Blocks 0x8000-0xffff) [INODE_UNINIT, ITABLE_ZEROED] >> Block bitmap at 0x0102 (group 0 +258), Inode bitmap at 0x0202 (group 0 +514) >> Inode table at 0x037e-0x03fa (group 0 +894) >> >> Signed-off-by: Andreas Dilger <adilger@dilger.ca> >> -- > Cheers, Andreas -- Andreas Dilger Lustre Technical Lead Oracle Corporation Canada Inc. [-- Attachment #2: e2fsprogs-dumpe2fs_flex.patch --] [-- Type: application/octet-stream, Size: 2113 bytes --] diff --git a/misc/dumpe2fs.c b/misc/dumpe2fs.c index a70cc4e..c39c713 100644 --- a/misc/dumpe2fs.c +++ b/misc/dumpe2fs.c @@ -126,10 +126,22 @@ static void print_bg_opts(ext2_filsys fs, dgrp_t i) fputc('\n', stdout); } +static void print_bg_rel_offset(ext2_filsys fs, blk64_t block, int itable, + blk64_t first_block, blk64_t last_block) +{ + if (block >= (first_block + !!itable) && block <= last_block) { + printf(" (+%u)", (unsigned)(block - first_block)); + } else if (fs->super->s_feature_incompat & + EXT4_FEATURE_INCOMPAT_FLEX_BG) { + dgrp_t flex_grp = ext2fs_group_of_blk(fs, block); + printf(" (grp %u+%u)", flex_grp, + (unsigned)(block-ext2fs_group_first_block(fs,flex_grp))); + } +} + static void list_desc (ext2_filsys fs) { unsigned long i; - long diff; blk_t first_block, last_block; blk_t super_blk, old_desc_blk, new_desc_blk; char *block_bitmap=NULL, *inode_bitmap=NULL; @@ -199,21 +211,21 @@ static void list_desc (ext2_filsys fs) fputc('\n', stdout); fputs(_(" Block bitmap at "), stdout); print_number(fs->group_desc[i].bg_block_bitmap); - diff = fs->group_desc[i].bg_block_bitmap - first_block; - if (diff >= 0) - printf(" (+%ld)", diff); + print_bg_rel_offset(fs, fs->group_desc[i].bg_block_bitmap, 0, + first_block, last_block); + fputs(_(", Inode bitmap at "), stdout); print_number(fs->group_desc[i].bg_inode_bitmap); - diff = fs->group_desc[i].bg_inode_bitmap - first_block; - if (diff >= 0) - printf(" (+%ld)", diff); + print_bg_rel_offset(fs, fs->group_desc[i].bg_inode_bitmap, 0, + first_block, last_block); + fputs(_("\n Inode table at "), stdout); print_range(fs->group_desc[i].bg_inode_table, fs->group_desc[i].bg_inode_table + inode_blocks_per_group - 1); - diff = fs->group_desc[i].bg_inode_table - first_block; - if (diff > 0) - printf(" (+%ld)", diff); + print_bg_rel_offset(fs, fs->group_desc[i].bg_inode_table, 1, + first_block, last_block); + printf (_("\n %u free blocks, %u free inodes, " "%u directories%s"), fs->group_desc[i].bg_free_blocks_count, ^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] fix debugfs output for flex_bg bitmap offsets 2010-11-27 0:33 ` Andreas Dilger @ 2010-12-06 3:16 ` Ted Ts'o 0 siblings, 0 replies; 4+ messages in thread From: Ted Ts'o @ 2010-12-06 3:16 UTC (permalink / raw) To: Andreas Dilger; +Cc: Andreas Dilger, Ext4 Developers List On Fri, Nov 26, 2010 at 05:33:27PM -0700, Andreas Dilger wrote: > On 2010-11-25, at 12:09, Andreas Dilger wrote: > > ...with patch this time... > > Attached is an updated patch that makes the output a bit more > verbose (to avoid line wraps) and doesn't fail the m_raid_opts test > (which complains when "(+0)" is printed for each inode table). Every time you write code of the form: if (block >= first_block + !!itable && ...) Gcc kills a kitten. Please, think of the kittens.... I rewrote that code as follows: if ((block >= first_block) && (block <= last_block)) { if (itable && block == first_block) return; printf(" (+%u)", (unsigned)(block - first_block)); } else if ... I also changed the output to use "(bg #16 + 4)" since I think it's a bit easier to understand than "(grp 16+4)". Otherwise, I've added it to the e2fsprogs maint branch, thanks. - Ted ^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2010-12-06 3:17 UTC | newest] Thread overview: 4+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2010-11-25 9:57 [PATCH] fix debugfs output for flex_bg bitmap offsets Andreas Dilger 2010-11-25 19:09 ` Andreas Dilger 2010-11-27 0:33 ` Andreas Dilger 2010-12-06 3:16 ` Ted 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).