Skip to content

Commit 04a6566

Browse files
committed
Merge tag 'health-monitoring-7.0_2026-01-20' of https://git.kernel.org/pub/scm/linux/kernel/git/djwong/xfs-linux into xfs-7.0-merge
xfs: autonomous self healing of filesystems [v7] This patchset builds new functionality to deliver live information about filesystem health events to userspace. This is done by creating an anonymous file that can be read() for events by userspace programs. Events are captured by hooking various parts of XFS and iomap so that metadata health failures, file I/O errors, and major changes in filesystem state (unmounts, shutdowns, etc.) can be observed by programs. When an event occurs, the hook functions queue an event object to each event anonfd for later processing. Programs must have CAP_SYS_ADMIN to open the anonfd and there's a maximum event lag to prevent resource overconsumption. The events themselves can be read() from the anonfd as C structs for the xfs_healer daemon. In userspace, we create a new daemon program that will read the event objects and initiate repairs automatically. This daemon is managed entirely by systemd and will not block unmounting of the filesystem unless repairs are ongoing. They are auto-started by a starter service that uses fanotify. This patchset depends on the new fserror code that Christian Brauner has tentatively accepted for Linux 7.0: https://git.kernel.org/pub/scm/linux/kernel/git/vfs/vfs.git/log/?h=vfs-7.0.fserror v7: more cleanups of the media verification ioctl, improve comments, and reuse the bio v6: fix pi-breaking bugs, make verify failures trigger health reports and filter bio status flags better v5: add verify-media ioctl, collapse small helper funcs with only one caller v4: drop multiple client support so we can make direct calls into healthmon instead of chasing pointers and doing indirect calls v3: drag out of rfc status With a bit of luck, this should all go splendidly. Conflicts: This merge required an update on files: - fs/xfs/xfs_healthmon.c - fs/xfs/xfs_verify_media.c Such change was required because a parallel developement changed XFS header file xfs.h naming to xfs_platform.h, so the merge required to update those includes in both files above Signed-off-by: "Darrick J. Wong" <djwong@kernel.org> Signed-off-by: Carlos Maiolino <cem@kernel.org>
2 parents a1ca658 + b8accfd commit 04a6566

44 files changed

Lines changed: 3146 additions & 29 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

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)