Skip to content

Commit ccf0f32

Browse files
committed
ext4: add tracepoints for shutdown and file system errors
Signed-off-by: Theodore Ts'o <[email protected]>
1 parent 7928b2c commit ccf0f32

File tree

3 files changed

+48
-0
lines changed

3 files changed

+48
-0
lines changed

fs/ext4/ioctl.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -481,6 +481,7 @@ static int ext4_shutdown(struct super_block *sb, unsigned long arg)
481481
return 0;
482482

483483
ext4_msg(sb, KERN_ALERT, "shut down requested (%d)", flags);
484+
trace_ext4_shutdown(sb, flags);
484485

485486
switch (flags) {
486487
case EXT4_GOING_FLAGS_DEFAULT:

fs/ext4/super.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -448,6 +448,7 @@ void __ext4_error(struct super_block *sb, const char *function,
448448
if (unlikely(ext4_forced_shutdown(EXT4_SB(sb))))
449449
return;
450450

451+
trace_ext4_error(sb, function, line);
451452
if (ext4_error_ratelimit(sb)) {
452453
va_start(args, fmt);
453454
vaf.fmt = fmt;
@@ -472,6 +473,7 @@ void __ext4_error_inode(struct inode *inode, const char *function,
472473
if (unlikely(ext4_forced_shutdown(EXT4_SB(inode->i_sb))))
473474
return;
474475

476+
trace_ext4_error(inode->i_sb, function, line);
475477
es->s_last_error_ino = cpu_to_le32(inode->i_ino);
476478
es->s_last_error_block = cpu_to_le64(block);
477479
if (ext4_error_ratelimit(inode->i_sb)) {
@@ -507,6 +509,7 @@ void __ext4_error_file(struct file *file, const char *function,
507509
if (unlikely(ext4_forced_shutdown(EXT4_SB(inode->i_sb))))
508510
return;
509511

512+
trace_ext4_error(inode->i_sb, function, line);
510513
es = EXT4_SB(inode->i_sb)->s_es;
511514
es->s_last_error_ino = cpu_to_le32(inode->i_ino);
512515
if (ext4_error_ratelimit(inode->i_sb)) {
@@ -719,6 +722,7 @@ __acquires(bitlock)
719722
if (unlikely(ext4_forced_shutdown(EXT4_SB(sb))))
720723
return;
721724

725+
trace_ext4_error(sb, function, line);
722726
es->s_last_error_ino = cpu_to_le32(ino);
723727
es->s_last_error_block = cpu_to_le64(block);
724728
__save_error_info(sb, function, line);

include/trace/events/ext4.h

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2585,6 +2585,49 @@ DEFINE_GETFSMAP_EVENT(ext4_getfsmap_low_key);
25852585
DEFINE_GETFSMAP_EVENT(ext4_getfsmap_high_key);
25862586
DEFINE_GETFSMAP_EVENT(ext4_getfsmap_mapping);
25872587

2588+
TRACE_EVENT(ext4_shutdown,
2589+
TP_PROTO(struct super_block *sb, unsigned long flags),
2590+
2591+
TP_ARGS(sb, flags),
2592+
2593+
TP_STRUCT__entry(
2594+
__field( dev_t, dev )
2595+
__field( unsigned, flags )
2596+
),
2597+
2598+
TP_fast_assign(
2599+
__entry->dev = sb->s_dev;
2600+
__entry->flags = flags;
2601+
),
2602+
2603+
TP_printk("dev %d,%d flags %u",
2604+
MAJOR(__entry->dev), MINOR(__entry->dev),
2605+
__entry->flags)
2606+
);
2607+
2608+
TRACE_EVENT(ext4_error,
2609+
TP_PROTO(struct super_block *sb, const char *function,
2610+
unsigned int line),
2611+
2612+
TP_ARGS(sb, function, line),
2613+
2614+
TP_STRUCT__entry(
2615+
__field( dev_t, dev )
2616+
__field( const char *, function )
2617+
__field( unsigned, line )
2618+
),
2619+
2620+
TP_fast_assign(
2621+
__entry->dev = sb->s_dev;
2622+
__entry->function = function;
2623+
__entry->line = line;
2624+
),
2625+
2626+
TP_printk("dev %d,%d function %s line %u",
2627+
MAJOR(__entry->dev), MINOR(__entry->dev),
2628+
__entry->function, __entry->line)
2629+
);
2630+
25882631
#endif /* _TRACE_EXT4_H */
25892632

25902633
/* This part must be outside protection */

0 commit comments

Comments
 (0)