Skip to content

Commit 9a089b2

Browse files
krisman-at-collaborajankara
authored andcommitted
ext4: Send notifications on error
Send a FS_ERROR message via fsnotify to a userspace monitoring tool whenever a ext4 error condition is triggered. This follows the existing error conditions in ext4, so it is hooked to the ext4_error* functions. Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Gabriel Krisman Bertazi <[email protected]> Acked-by: Theodore Ts'o <[email protected]> Reviewed-by: Amir Goldstein <[email protected]> Reviewed-by: Jan Kara <[email protected]> Signed-off-by: Jan Kara <[email protected]>
1 parent 9709bd5 commit 9a089b2

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

fs/ext4/super.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@
4646
#include <linux/part_stat.h>
4747
#include <linux/kthread.h>
4848
#include <linux/freezer.h>
49+
#include <linux/fsnotify.h>
4950

5051
#include "ext4.h"
5152
#include "ext4_extents.h" /* Needed for trace points definition */
@@ -759,6 +760,8 @@ void __ext4_error(struct super_block *sb, const char *function,
759760
sb->s_id, function, line, current->comm, &vaf);
760761
va_end(args);
761762
}
763+
fsnotify_sb_error(sb, NULL, error ? error : EFSCORRUPTED);
764+
762765
ext4_handle_error(sb, force_ro, error, 0, block, function, line);
763766
}
764767

@@ -789,6 +792,8 @@ void __ext4_error_inode(struct inode *inode, const char *function,
789792
current->comm, &vaf);
790793
va_end(args);
791794
}
795+
fsnotify_sb_error(inode->i_sb, inode, error ? error : EFSCORRUPTED);
796+
792797
ext4_handle_error(inode->i_sb, false, error, inode->i_ino, block,
793798
function, line);
794799
}
@@ -827,6 +832,8 @@ void __ext4_error_file(struct file *file, const char *function,
827832
current->comm, path, &vaf);
828833
va_end(args);
829834
}
835+
fsnotify_sb_error(inode->i_sb, inode, EFSCORRUPTED);
836+
830837
ext4_handle_error(inode->i_sb, false, EFSCORRUPTED, inode->i_ino, block,
831838
function, line);
832839
}
@@ -894,6 +901,7 @@ void __ext4_std_error(struct super_block *sb, const char *function,
894901
printk(KERN_CRIT "EXT4-fs error (device %s) in %s:%d: %s\n",
895902
sb->s_id, function, line, errstr);
896903
}
904+
fsnotify_sb_error(sb, NULL, errno ? errno : EFSCORRUPTED);
897905

898906
ext4_handle_error(sb, false, -errno, 0, 0, function, line);
899907
}

0 commit comments

Comments
 (0)