ext4: convert to new fserror helpers

Use the new fserror functions to report metadata errors to fsnotify.
Note that ext4 inconsistently passes around negative and positive error
numbers all over the codebase, so we force them all to negative for
consistency in what we report to fserror, and fserror ensures that only
positive error numbers are passed to fanotify, per the fanotify(7)
manpage.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Link: https://patch.msgid.link/176826402693.3490369.5875002879192895558.stgit@frogsfrogsfrogs
Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Jan Kara <jack@suse.cz>
Signed-off-by: Christian Brauner <brauner@kernel.org>
This commit is contained in:
Darrick J. Wong
2026-01-12 16:32:27 -08:00
committed by Christian Brauner
parent 94503211d2
commit 81d2e13a57
2 changed files with 11 additions and 4 deletions

View File

@@ -48,6 +48,7 @@
#include <linux/fsnotify.h>
#include <linux/fs_context.h>
#include <linux/fs_parser.h>
#include <linux/fserror.h>
#include "ext4.h"
#include "ext4_extents.h" /* Needed for trace points definition */
@@ -824,7 +825,8 @@ void __ext4_error(struct super_block *sb, const char *function,
sb->s_id, function, line, current->comm, &vaf);
va_end(args);
}
fsnotify_sb_error(sb, NULL, error ? error : EFSCORRUPTED);
fserror_report_metadata(sb, error ? -abs(error) : -EFSCORRUPTED,
GFP_ATOMIC);
ext4_handle_error(sb, force_ro, error, 0, block, function, line);
}
@@ -856,7 +858,9 @@ void __ext4_error_inode(struct inode *inode, const char *function,
current->comm, &vaf);
va_end(args);
}
fsnotify_sb_error(inode->i_sb, inode, error ? error : EFSCORRUPTED);
fserror_report_file_metadata(inode,
error ? -abs(error) : -EFSCORRUPTED,
GFP_ATOMIC);
ext4_handle_error(inode->i_sb, false, error, inode->i_ino, block,
function, line);
@@ -896,7 +900,7 @@ void __ext4_error_file(struct file *file, const char *function,
current->comm, path, &vaf);
va_end(args);
}
fsnotify_sb_error(inode->i_sb, inode, EFSCORRUPTED);
fserror_report_file_metadata(inode, -EFSCORRUPTED, GFP_ATOMIC);
ext4_handle_error(inode->i_sb, false, EFSCORRUPTED, inode->i_ino, block,
function, line);
@@ -965,7 +969,8 @@ void __ext4_std_error(struct super_block *sb, const char *function,
printk(KERN_CRIT "EXT4-fs error (device %s) in %s:%d: %s\n",
sb->s_id, function, line, errstr);
}
fsnotify_sb_error(sb, NULL, errno ? errno : EFSCORRUPTED);
fserror_report_metadata(sb, errno ? -abs(errno) : -EFSCORRUPTED,
GFP_ATOMIC);
ext4_handle_error(sb, false, -errno, 0, 0, function, line);
}