Skip to content

Commit 81d2e13

Browse files
Darrick J. Wongbrauner
authored andcommitted
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>
1 parent 9450321 commit 81d2e13

File tree

2 files changed

+11
-4
lines changed

2 files changed

+11
-4
lines changed

fs/ext4/ioctl.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
#include <linux/fsmap.h>
2727
#include "fsmap.h"
2828
#include <trace/events/ext4.h>
29+
#include <linux/fserror.h>
2930

3031
typedef void ext4_update_sb_callback(struct ext4_sb_info *sbi,
3132
struct ext4_super_block *es,
@@ -844,6 +845,7 @@ int ext4_force_shutdown(struct super_block *sb, u32 flags)
844845
return -EINVAL;
845846
}
846847
clear_opt(sb, DISCARD);
848+
fserror_report_shutdown(sb, GFP_KERNEL);
847849
return 0;
848850
}
849851

fs/ext4/super.c

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@
4848
#include <linux/fsnotify.h>
4949
#include <linux/fs_context.h>
5050
#include <linux/fs_parser.h>
51+
#include <linux/fserror.h>
5152

5253
#include "ext4.h"
5354
#include "ext4_extents.h" /* Needed for trace points definition */
@@ -824,7 +825,8 @@ void __ext4_error(struct super_block *sb, const char *function,
824825
sb->s_id, function, line, current->comm, &vaf);
825826
va_end(args);
826827
}
827-
fsnotify_sb_error(sb, NULL, error ? error : EFSCORRUPTED);
828+
fserror_report_metadata(sb, error ? -abs(error) : -EFSCORRUPTED,
829+
GFP_ATOMIC);
828830

829831
ext4_handle_error(sb, force_ro, error, 0, block, function, line);
830832
}
@@ -856,7 +858,9 @@ void __ext4_error_inode(struct inode *inode, const char *function,
856858
current->comm, &vaf);
857859
va_end(args);
858860
}
859-
fsnotify_sb_error(inode->i_sb, inode, error ? error : EFSCORRUPTED);
861+
fserror_report_file_metadata(inode,
862+
error ? -abs(error) : -EFSCORRUPTED,
863+
GFP_ATOMIC);
860864

861865
ext4_handle_error(inode->i_sb, false, error, inode->i_ino, block,
862866
function, line);
@@ -896,7 +900,7 @@ void __ext4_error_file(struct file *file, const char *function,
896900
current->comm, path, &vaf);
897901
va_end(args);
898902
}
899-
fsnotify_sb_error(inode->i_sb, inode, EFSCORRUPTED);
903+
fserror_report_file_metadata(inode, -EFSCORRUPTED, GFP_ATOMIC);
900904

901905
ext4_handle_error(inode->i_sb, false, EFSCORRUPTED, inode->i_ino, block,
902906
function, line);
@@ -965,7 +969,8 @@ void __ext4_std_error(struct super_block *sb, const char *function,
965969
printk(KERN_CRIT "EXT4-fs error (device %s) in %s:%d: %s\n",
966970
sb->s_id, function, line, errstr);
967971
}
968-
fsnotify_sb_error(sb, NULL, errno ? errno : EFSCORRUPTED);
972+
fserror_report_metadata(sb, errno ? -abs(errno) : -EFSCORRUPTED,
973+
GFP_ATOMIC);
969974

970975
ext4_handle_error(sb, false, -errno, 0, 0, function, line);
971976
}

0 commit comments

Comments
 (0)