Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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/20211025192746.66445-30-krisman@collabora.com
Signed-off-by: Gabriel Krisman Bertazi <krisman@collabora.com>
Acked-by: Theodore Ts'o <tytso@mit.edu>
Reviewed-by: Amir Goldstein <amir73il@gmail.com>
Reviewed-by: Jan Kara <jack@suse.cz>
Signed-off-by: Jan Kara <jack@suse.cz>

authored by

Gabriel Krisman Bertazi and committed by
Jan Kara
9a089b21 9709bd54

+8
+8
fs/ext4/super.c
··· 46 46 #include <linux/part_stat.h> 47 47 #include <linux/kthread.h> 48 48 #include <linux/freezer.h> 49 + #include <linux/fsnotify.h> 49 50 50 51 #include "ext4.h" 51 52 #include "ext4_extents.h" /* Needed for trace points definition */ ··· 760 759 sb->s_id, function, line, current->comm, &vaf); 761 760 va_end(args); 762 761 } 762 + fsnotify_sb_error(sb, NULL, error ? error : EFSCORRUPTED); 763 + 763 764 ext4_handle_error(sb, force_ro, error, 0, block, function, line); 764 765 } 765 766 ··· 792 789 current->comm, &vaf); 793 790 va_end(args); 794 791 } 792 + fsnotify_sb_error(inode->i_sb, inode, error ? error : EFSCORRUPTED); 793 + 795 794 ext4_handle_error(inode->i_sb, false, error, inode->i_ino, block, 796 795 function, line); 797 796 } ··· 832 827 current->comm, path, &vaf); 833 828 va_end(args); 834 829 } 830 + fsnotify_sb_error(inode->i_sb, inode, EFSCORRUPTED); 831 + 835 832 ext4_handle_error(inode->i_sb, false, EFSCORRUPTED, inode->i_ino, block, 836 833 function, line); 837 834 } ··· 901 894 printk(KERN_CRIT "EXT4-fs error (device %s) in %s:%d: %s\n", 902 895 sb->s_id, function, line, errstr); 903 896 } 897 + fsnotify_sb_error(sb, NULL, errno ? errno : EFSCORRUPTED); 904 898 905 899 ext4_handle_error(sb, false, -errno, 0, 0, function, line); 906 900 }