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: create hooks for monitoring health updates * xfs: create a special file to pass filesystem health to userspace * xfs: create event queuing, formatting, and discovery infrastructure * xfs: report metadata health events through healthmon * xfs: report shutdown events through healthmon * xfs: report media errors through healthmon * xfs: report file io errors through healthmon * xfs: add media error reporting ioctl * xfs_io: monitor filesystem health events * xfs_io: add a media error reporting command * xfs_scrubbed: create daemon to listen for health events * xfs_scrubbed: check events against schema * xfs_scrubbed: enable repairing filesystems * xfs_scrubbed: check for fs features needed for effective repairs * xfs_scrubbed: use getparents to look up file names * builddefs: refactor udev directory specification * xfs_scrubbed: create a background monitoring service * xfs_scrubbed: don't start service if kernel support unavailable * xfs_scrubbed: use the autofsck fsproperty to select mode * xfs_scrub: report media scrub failures to the kernel * debian: enable xfs_scrubbed on the root filesystem by default --- configure.ac | 2 debian/control | 2 debian/postinst | 8 debian/prerm | 13 include/builddefs.in | 3 io/Makefile | 1 io/healthmon.c | 183 ++++++ io/init.c | 1 io/io.h | 1 io/shutdown.c | 113 ++++ libxfs/Makefile | 10 libxfs/xfs_fs.h | 31 + libxfs/xfs_health.h | 47 ++ libxfs/xfs_healthmon.schema.json | 595 ++++++++++++++++++++ m4/package_services.m4 | 30 + man/man8/xfs_io.8 | 46 ++ scrub/Makefile | 34 + scrub/phase6.c | 25 + scrub/xfs_scrubbed.in | 1106 ++++++++++++++++++++++++++++++++++++++ scrub/xfs_scrubbed.rules | 7 scrub/xfs_scrubbed@xxxxxxxxxxx | 104 ++++ scrub/xfs_scrubbed_start | 17 + 22 files changed, 2354 insertions(+), 25 deletions(-) create mode 100644 debian/prerm create mode 100644 io/healthmon.c create mode 100644 libxfs/xfs_healthmon.schema.json create mode 100644 scrub/xfs_scrubbed.in create mode 100644 scrub/xfs_scrubbed.rules create mode 100644 scrub/xfs_scrubbed@xxxxxxxxxxx create mode 100755 scrub/xfs_scrubbed_start