Hi all, This patchset builds off of Kent Overstreet's thread_with_file code to deliver live information about filesystem health events to userspace. This is done by creating a twf file and hooking internal operations so that the event information can be queued to the twf without stalling the kernel if the twf client program is nonresponsive. This is a private ioctl, so events are expressed using simple json objects so that we can enrich the output later on without having to rev a ton of C structs. In userspace, we create a new daemon program that will read the json 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. It is autostarted via some horrible udev rules. If you're going to start using this code, I strongly recommend pulling from my git trees, which are linked below. This has been running on the djcloud for months with no problems. Enjoy! Comments and questions are, as always, welcome. --D kernel git tree: https://git.kernel.org/cgit/linux/kernel/git/djwong/xfs-linux.git/log/?h=health-monitoring xfsprogs git tree: https://git.kernel.org/cgit/linux/kernel/git/djwong/xfsprogs-dev.git/log/?h=health-monitoring fstests git tree: https://git.kernel.org/cgit/linux/kernel/git/djwong/xfstests-dev.git/log/?h=health-monitoring --- Commits in this patchset: * xfs: use thread_with_file to create a monitoring file * xfs: create hooks for monitoring health updates * xfs: create a filesystem shutdown hook * xfs: report shutdown events through healthmon * xfs: report metadata health events through healthmon * xfs: report media errors through healthmon * xfs: allow reconfiguration of the health monitoring device * xfs: send uevents when mounting and unmounting a filesystem --- fs/xfs/Kconfig | 9 fs/xfs/Makefile | 1 fs/xfs/libxfs/xfs_fs.h | 1 fs/xfs/libxfs/xfs_fs_staging.h | 18 + fs/xfs/libxfs/xfs_health.h | 48 ++ fs/xfs/xfs_buf.c | 1 fs/xfs/xfs_fsops.c | 57 ++ fs/xfs/xfs_fsops.h | 14 + fs/xfs/xfs_health.c | 266 ++++++++++ fs/xfs/xfs_healthmon.c | 1108 ++++++++++++++++++++++++++++++++++++++++ fs/xfs/xfs_healthmon.h | 86 +++ fs/xfs/xfs_ioctl.c | 21 + fs/xfs/xfs_linux.h | 3 fs/xfs/xfs_mount.h | 9 fs/xfs/xfs_notify_failure.c | 161 +++++- fs/xfs/xfs_notify_failure.h | 42 ++ fs/xfs/xfs_super.c | 43 ++ fs/xfs/xfs_super.h | 1 fs/xfs/xfs_trace.c | 3 fs/xfs/xfs_trace.h | 240 +++++++++ 20 files changed, 2098 insertions(+), 34 deletions(-) create mode 100644 fs/xfs/xfs_healthmon.c create mode 100644 fs/xfs/xfs_healthmon.h create mode 100644 fs/xfs/xfs_notify_failure.h