Skip to contentSkip to conversation

e2fsprogs: Dump extent/sindices using debugfs

PATCH In review Girish Shilamkar 4 participants 4 messages Jun 11, 2008 – Jun 12, 2008

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 e2fsprogs: Dump extent/sindices using debugfs

Hi Ted,
The attached patch adds a command to debugfs to display all the
extents/indices contained in an inode or the block specified.
The options to the command includes tranversing and dumping the entire
extent tree (if inode specified) or the branch (in case of block) and can display only the headers if required.

Would you please let me know your comments/suggestions ?

Thanks,
Girish

debugfs/debug_cmds.ct +3 -0
Index: e2fsprogs-1.40.7/debugfs/debug_cmds.ct
===================================================================
@@ -157,5 +157,8 @@ request do_set_current_time, "Set curren
 request do_supported_features, "Print features supported by this version of e2fsprogs",
 	supported_features;
 
+request do_dump_extent_map, "Dump extent map",
+	dump_extent_map, ext_map;
+
 end;
 
debugfs/debugfs.c +174 -0

186 lines not on this page · raw message

debugfs/debugfs.8.in +16 -0
Index: e2fsprogs-1.40.7/debugfs/debugfs.8.in
===================================================================
@@ -191,6 +191,22 @@ to match 
 Expand the directory
 .IR filespec .
 .TP
+.I ext_map [-h] [-t] [-i <filespec>] [-b block]
+Dump the extent map contained in inode/block.
+.IR -h
+option can be used to display only the extent headers.
+.IR -t
+option can be used to dump entire extent tree, in case inode
+is specified, or branch if block is specified.
+If
+.IR -i
+option is set, dump the extent map contained in the inode
+.IR filespec .
+If
+.IR -b
+option is set, dump the extent map contained in block
+.IR block .
+.TP
 .I feature [fs_feature] [-fs_feature] ...
 Set or clear various filesystem features in the superblock.  After setting
 or clearing any filesystem features that were requested, print the current
#1 lore raw
Quoted 8 lines · Girish Shilamkar

Hi Ted,
The attached patch adds a command to debugfs to display all the
extents/indices contained in an inode or the block specified.
The options to the command includes tranversing and dumping the entire
extent tree (if inode specified) or the branch (in case of block) and can display only the headers if required.

Would you please let me know your comments/suggestions ?

lib/ext2fs/tst_extents (I don't know why we don't install this by default) have inode, root and ns/n command which help to iterate the extent format inode

-aneesh

#2 lore raw
Quoted 7 lines · Aneesh Kumar K.V
Quoted 6 lines · Girish Shilamkar

The attached patch adds a command to debugfs to display all the
extents/indices contained in an inode or the block specified.
The options to the command includes tranversing and dumping the entire
extent tree (if inode specified) or the branch (in case of block) and can display only the headers if required.

Quoted 5 lines
Quoted 1 line

Would you please let me know your comments/suggestions ?

lib/ext2fs/tst_extents (I don't know why we don't install this by default) have inode, root and ns/n command which help to iterate the extent format inode

The "tst_*" programs are purely for regression testing. Having this functionality built into a proper tool like debugfs is needed.

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

#3 lore raw
Quoted 4 lines · Andreas Dilger
Quoted 4 lines

lib/ext2fs/tst_extents (I don't know why we don't install this by default) have inode, root and ns/n command which help to iterate the extent format inode

Some of the reasons why tst_extents was created to extend debugfs, instead of simply adding these commands to debugfs are:

1) To demonstrate the technique for creating programs for doing per-module testing various new bits of the libext2 library, without having to replicate a lot of infrastructure already provided by debugfs. (Code reuse is good; lots of testing of *any* code before you submit it, in either e2fsprogs or the ext4 kernel code is a very good thing; one of the thing that disturbs me a little is when I trip over bugs that indicate that obviously the code was obviously NOT tested before submission, such as the on-line resizing code or patches to the on-line resizing code, when online resizing was clearly and obviously busted.)

2) The command names, "inode", "root", "next_sibling", etc. are clearly inappropriate for debugfs.

Quoted 2 lines

The "tst_*" programs are purely for regression testing. Having this functionality built into a proper tool like debugfs is needed.

Agreed. That being siad, Girish's patch doesn't apply against the latest e2fsprogs git repository. It uses ext2fs_read_ext_block(), and one of the reasons why I objected to Clusterfs's extent support in e2fsprogs is that it exposed the low-level extent format to userspace (and meant that the swapfs.c also needed extreme intimate knowledge of the extent tree format), and that's a bad idea if we ever want to change the extent format in the future. So the extents abstraction in the latest e2fsprogs git tree does not have ext2fs_read_ext_block().

So to properly add the desired features to debugfs would require taking some of the code from tst_extents (really, lib/ext2fs/extents.c in the #ifdef DEBUG section), and moving it into debugfs.

I doubt we would want to move all of the tst_extents functionality into debugfs, though. Probably just enough to dump the extent tree and the set_bmap functionality --- and the latter should be done by extending debugfs.c:do_bmap() so that it can take an optional 3rd argument which utilizes ext2fs_bmap() to set a logical block mapping; that way do_bmap() will work with normal and extent-based files, since ext2fs_bmap/ext2fs_bmap2 have been wired to use Eric's ext2fs_extent_set_bmap() function automatically for extents-based files.

Regards,

- Ted