Skip to content

Commit 347b704

Browse files
committed
Merge patch series "fs: generic file IO error reporting"
Darrick J. Wong <djwong@kernel.org> says: This patchset adds some generic helpers so that filesystems can report errors to fsnotify in a standard way. Then it adapts iomap to use the generic helpers so that any iomap-enabled filesystem can report I/O errors through this mechanism as well. Finally, it makes XFS report metadata errors through this mechanism in much the same way that ext4 does now. These are a prerequisite for the XFS self-healing series which will come at a later time. * patches from https://patch.msgid.link/176826402528.3490369.2415315475116356277.stgit@frogsfrogsfrogs: ext4: convert to new fserror helpers xfs: translate fsdax media errors into file "data lost" errors when convenient xfs: report fs metadata errors via fsnotify iomap: report file I/O errors to the VFS fs: report filesystem and file I/O errors to fsnotify uapi: promote EFSCORRUPTED and EUCLEAN to errno.h Link: https://patch.msgid.link/176826402528.3490369.2415315475116356277.stgit@frogsfrogsfrogs Signed-off-by: Christian Brauner <brauner@kernel.org>
2 parents 8f0b4cc + 81d2e13 commit 347b704

File tree

31 files changed

+373
-24
lines changed

31 files changed

+373
-24
lines changed

arch/alpha/include/uapi/asm/errno.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@
5555
#define ENOSR 82 /* Out of streams resources */
5656
#define ETIME 83 /* Timer expired */
5757
#define EBADMSG 84 /* Not a data message */
58+
#define EFSBADCRC EBADMSG /* Bad CRC detected */
5859
#define EPROTO 85 /* Protocol error */
5960
#define ENODATA 86 /* No data available */
6061
#define ENOSTR 87 /* Device not a stream */
@@ -96,6 +97,7 @@
9697
#define EREMCHG 115 /* Remote address changed */
9798

9899
#define EUCLEAN 117 /* Structure needs cleaning */
100+
#define EFSCORRUPTED EUCLEAN /* Filesystem is corrupted */
99101
#define ENOTNAM 118 /* Not a XENIX named type file */
100102
#define ENAVAIL 119 /* No XENIX semaphores available */
101103
#define EISNAM 120 /* Is a named type file */

arch/mips/include/uapi/asm/errno.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@
5050
#define EDOTDOT 73 /* RFS specific error */
5151
#define EMULTIHOP 74 /* Multihop attempted */
5252
#define EBADMSG 77 /* Not a data message */
53+
#define EFSBADCRC EBADMSG /* Bad CRC detected */
5354
#define ENAMETOOLONG 78 /* File name too long */
5455
#define EOVERFLOW 79 /* Value too large for defined data type */
5556
#define ENOTUNIQ 80 /* Name not unique on network */
@@ -88,6 +89,7 @@
8889
#define EISCONN 133 /* Transport endpoint is already connected */
8990
#define ENOTCONN 134 /* Transport endpoint is not connected */
9091
#define EUCLEAN 135 /* Structure needs cleaning */
92+
#define EFSCORRUPTED EUCLEAN /* Filesystem is corrupted */
9193
#define ENOTNAM 137 /* Not a XENIX named type file */
9294
#define ENAVAIL 138 /* No XENIX semaphores available */
9395
#define EISNAM 139 /* Is a named type file */

arch/parisc/include/uapi/asm/errno.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636

3737
#define EDOTDOT 66 /* RFS specific error */
3838
#define EBADMSG 67 /* Not a data message */
39+
#define EFSBADCRC EBADMSG /* Bad CRC detected */
3940
#define EUSERS 68 /* Too many users */
4041
#define EDQUOT 69 /* Quota exceeded */
4142
#define ESTALE 70 /* Stale file handle */
@@ -62,6 +63,7 @@
6263
#define ERESTART 175 /* Interrupted system call should be restarted */
6364
#define ESTRPIPE 176 /* Streams pipe error */
6465
#define EUCLEAN 177 /* Structure needs cleaning */
66+
#define EFSCORRUPTED EUCLEAN /* Filesystem is corrupted */
6567
#define ENOTNAM 178 /* Not a XENIX named type file */
6668
#define ENAVAIL 179 /* No XENIX semaphores available */
6769
#define EISNAM 180 /* Is a named type file */

arch/sparc/include/uapi/asm/errno.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@
4848
#define ENOSR 74 /* Out of streams resources */
4949
#define ENOMSG 75 /* No message of desired type */
5050
#define EBADMSG 76 /* Not a data message */
51+
#define EFSBADCRC EBADMSG /* Bad CRC detected */
5152
#define EIDRM 77 /* Identifier removed */
5253
#define EDEADLK 78 /* Resource deadlock would occur */
5354
#define ENOLCK 79 /* No record locks available */
@@ -91,6 +92,7 @@
9192
#define ENOTUNIQ 115 /* Name not unique on network */
9293
#define ERESTART 116 /* Interrupted syscall should be restarted */
9394
#define EUCLEAN 117 /* Structure needs cleaning */
95+
#define EFSCORRUPTED EUCLEAN /* Filesystem is corrupted */
9496
#define ENOTNAM 118 /* Not a XENIX named type file */
9597
#define ENAVAIL 119 /* No XENIX semaphores available */
9698
#define EISNAM 120 /* Is a named type file */

fs/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ obj-y := open.o read_write.o file_table.o super.o \
1616
stack.o fs_struct.o statfs.o fs_pin.o nsfs.o \
1717
fs_dirent.o fs_context.o fs_parser.o fsopen.o init.o \
1818
kernel_read_file.o mnt_idmapping.o remap_range.o pidfs.o \
19-
file_attr.o
19+
file_attr.o fserror.o
2020

2121
obj-$(CONFIG_BUFFER_HEAD) += buffer.o mpage.o
2222
obj-$(CONFIG_PROC_FS) += proc_namespace.o

fs/erofs/internal.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -541,6 +541,4 @@ long erofs_ioctl(struct file *filp, unsigned int cmd, unsigned long arg);
541541
long erofs_compat_ioctl(struct file *filp, unsigned int cmd,
542542
unsigned long arg);
543543

544-
#define EFSCORRUPTED EUCLEAN /* Filesystem is corrupted */
545-
546544
#endif /* __EROFS_INTERNAL_H */

fs/ext2/ext2.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -357,7 +357,6 @@ struct ext2_inode {
357357
*/
358358
#define EXT2_VALID_FS 0x0001 /* Unmounted cleanly */
359359
#define EXT2_ERROR_FS 0x0002 /* Errors detected */
360-
#define EFSCORRUPTED EUCLEAN /* Filesystem is corrupted */
361360

362361
/*
363362
* Mount flags

fs/ext4/ext4.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3938,7 +3938,4 @@ extern int ext4_block_write_begin(handle_t *handle, struct folio *folio,
39383938
get_block_t *get_block);
39393939
#endif /* __KERNEL__ */
39403940

3941-
#define EFSBADCRC EBADMSG /* Bad CRC detected */
3942-
#define EFSCORRUPTED EUCLEAN /* Filesystem is corrupted */
3943-
39443941
#endif /* _EXT4_H */

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)