Skip to contentSkip to conversation

debugfs: add commands to dump and change extent header fields

RFC PATCH New Luís Henriques 1 participant 1 message Sep 26, 2022

lore
Share & tools
lore
#0 lore raw

RFC PATCH 1/1 debugfs: add commands to dump and change extent header fields

This commit adds two new commands to debugfs:

* dump_extent_header - dump an extent header
* set_extent_header_field - modifying an extent header field

These commands take a block number as an argument, and will take the extent header from the beginning of this block. Basic validation of the header data is done, but it is possible to override this validation when modifying the header.

---
 debugfs/debug_cmds.ct |  6 +++
 debugfs/debugfs.8.in  | 24 +++++++++++
 debugfs/debugfs.c     | 50 +++++++++++++++++++++++
 debugfs/debugfs.h     |  2 +
 debugfs/set_fields.c  | 94 +++++++++++++++++++++++++++++++++++++++++++
 5 files changed, 176 insertions(+)
debugfs/debug_cmds.ct +6 -0
index 1ff6c9dcd6b5..4ed613627258 100644
@@ -49,6 +49,12 @@ request do_stat, "Show inode information ",
 request do_dump_extents, "Dump extents information ",
 	dump_extents, extents, ex;
 
+request do_dump_extent_header, "Dump extent header information",
+	dump_extent_header, deh;
+
+request do_set_extent_header_field, "Sets an extent header field",
+	set_extent_header_field, seh;
+
 request do_blocks, "Dump blocks used by an inode ",
 	blocks;
 
debugfs/debugfs.8.in +24 -0
index a3227a80ab24..f50fd6d9e987 100644
@@ -298,6 +298,13 @@ not stored in file system data structures.   Hence, the values displayed
 may not necessarily by accurate and does not indicate a problem or
 corruption in the file system.)
 .TP
+.BI dump_extent_header " block"
+Dump the contents of the extent header at the beginning of block
+.IR block .
+A warning will be emitted if the block doesn't start with a valid extent
+header (for example, if the extent header doesn't start with the '0xf30a'
+magic value).
+.TP
 .B dump_unused
 Dump unused blocks which contain non-null bytes.
 .TP
@@ -739,6 +746,23 @@ can be displayed by using the command:
 Also available as
 .BR ssv .
 .TP
+.BI set_extent_header_field " -l | block field value"
+Change the value of
+.IR field
+to
+.IR value
+in the extent header at the beginning of
+.IR block.
+If
+.IR block
+doesn't start with a valid extent header, a warning will be emitted and field
+isn't changed.  To force the change, the
+.IR -f
+flag can be used.
+The fields that may be changed with this command can be listed by using the
+.IR -l
+flag.
+.TP
 .B show_debugfs_params
 Display
 .B debugfs
debugfs/debugfs.c +50 -0

56 lines not on this page · raw message

debugfs/debugfs.h +2 -0
index 39bc0247f527..f1797c660f55 100644
@@ -144,6 +144,8 @@ extern void do_find_free_block(int argc, char **argv, int sci_idx, void *infop);
 extern void do_find_free_inode(int argc, char **argv, int sci_idx, void *infop);
 extern void do_stat(int argc, char **argv, int sci_idx, void *infop);
 extern void do_dump_extents(int argc, char **argv, int sci_idx, void *infop);
+extern void do_dump_extent_header(int argc, char **argv, int sci_idx, void *infop);
+extern void do_set_extent_header_field(int argc, char **argv, int sci_idx, void *infop);
 extern void do_blocks(int argc, char *argv[], int sci_idx, void *infop);
 
 extern void do_chroot(int argc, char **argv, int sci_idx, void *infop);
debugfs/set_fields.c +94 -0

109 lines not on this page · raw message