[PATCHSET v29.0 05/28] xfs: report corruption to the health trackers

Darrick J. Wong
2023-12-31T19:26:39Z

Hi all,

Any time that the runtime code thinks it has found corrupt metadata, it
should tell the health tracking subsystem that the corresponding part of
the filesystem is sick. These reports come primarily from two places --
code that is reading a buffer that fails validation, and higher level
pieces that observe a conflict involving multiple buffers. This
patchset uses automated scanning to update all such callsites with a
mark_sick call.

Doing this enables the health system to record problem observed at
runtime, which (for now) can prompt the sysadmin to run xfs_scrub, and
(later) may enable more targetted fixing of the filesystem.

Note: Earlier reviewers of this patchset suggested that the verifier
functions themselves should be responsible for calling _mark_sick. In a
higher level language this would be easily accomplished with lambda
functions and closures. For the kernel, however, we'd have to create
the necessary closures by hand, pass them to the buf_read calls, and
then implement necessary state tracking to detach the xfs_buf from the
closure at the necessary time. This is far too much work and complexity
and will not be pursued further.

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=corruption-health-reports

xfsprogs git tree:
https://git.kernel.org/cgit/linux/kernel/git/djwong/xfsprogs-dev.git/log/?h=corruption-health-reports

fstests git tree:
https://git.kernel.org/cgit/linux/kernel/git/djwong/xfstests-dev.git/log/?h=corruption-health-reports
---
fs/xfs/libxfs/xfs_ag.c | 5 +
fs/xfs/libxfs/xfs_alloc.c | 105 ++++++++++++++++++++----
fs/xfs/libxfs/xfs_attr_leaf.c | 4 +
fs/xfs/libxfs/xfs_attr_remote.c | 35 +++++---
fs/xfs/libxfs/xfs_bmap.c | 135 +++++++++++++++++++++++++++----
fs/xfs/libxfs/xfs_btree.c | 39 ++++++++-
fs/xfs/libxfs/xfs_da_btree.c | 37 +++++++-
fs/xfs/libxfs/xfs_dir2.c | 5 +
fs/xfs/libxfs/xfs_dir2_block.c | 2
fs/xfs/libxfs/xfs_dir2_data.c | 3 +
fs/xfs/libxfs/xfs_dir2_leaf.c | 3 +
fs/xfs/libxfs/xfs_dir2_node.c | 7 ++
fs/xfs/libxfs/xfs_health.h | 35 +++++++-
fs/xfs/libxfs/xfs_ialloc.c | 57 +++++++++++--
fs/xfs/libxfs/xfs_inode_buf.c | 12 ++-
fs/xfs/libxfs/xfs_inode_fork.c | 8 ++
fs/xfs/libxfs/xfs_refcount.c | 43 +++++++++-
fs/xfs/libxfs/xfs_rmap.c | 83 ++++++++++++++++++-
fs/xfs/libxfs/xfs_rtbitmap.c | 9 ++
fs/xfs/libxfs/xfs_sb.c | 2
fs/xfs/scrub/health.c | 20 +++--
fs/xfs/scrub/refcount_repair.c | 9 ++
fs/xfs/xfs_attr_inactive.c | 4 +
fs/xfs/xfs_attr_list.c | 18 +++-
fs/xfs/xfs_dir2_readdir.c | 6 +
fs/xfs/xfs_discard.c | 2
fs/xfs/xfs_dquot.c | 30 +++++++
fs/xfs/xfs_health.c | 172 +++++++++++++++++++++++++++++++++++++++
fs/xfs/xfs_icache.c | 9 ++
fs/xfs/xfs_inode.c | 16 +++-
fs/xfs/xfs_iomap.c | 15 +++
fs/xfs/xfs_iwalk.c | 5 +
fs/xfs/xfs_mount.c | 5 +
fs/xfs/xfs_qm.c | 8 +-
fs/xfs/xfs_reflink.c | 6 +
fs/xfs/xfs_rtalloc.c | 6 +
fs/xfs/xfs_symlink.c | 17 +++-
37 files changed, 867 insertions(+), 110 deletions(-)