[GIT PULL 1/18] xfs: repair inode mode by scanning dirs

Darrick J. Wong
2024-02-24T01:29:13Z

The following changes since commit 4b2f459d86252619448455013f581836c8b1b7da:

xfs: fix SEEK_HOLE/DATA for regions with active COW extents (2024-02-21 12:31:12 +0530)

are available in the Git repository at:

https://git.kernel.org/pub/scm/linux/kernel/git/djwong/xfs-linux.git tags/repair-inode-mode-6.9_2024-02-23

for you to fetch changes up to 5385f1a60d4e5b73e8ecd2757865352b68f54fb9:

xfs: repair file modes by scanning for a dirent pointing to us (2024-02-22 12:30:51 -0800)

----------------------------------------------------------------
xfs: repair inode mode by scanning dirs [v29.3 01/18]

One missing piece of functionality in the inode record repair code is
figuring out what to do with a file whose mode is so corrupt that we
cannot tell us the type of the file. Originally this was done by
guessing the mode from the ondisk inode contents, but Christoph didn't
like that because it read from data fork block 0, which could be user
controlled data.

Therefore, I've replaced all that with a directory scanner that looks
for any dirents that point to the file with the garbage mode. If so,
the ftype in the dirent will tell us exactly what mode to set on the
file. Since users cannot directly write to the ftype field of a dirent,
this should be safe.

This has been running on the djcloud for months with no problems. Enjoy!

Signed-off-by: Darrick J. Wong <djwong@kernel.org>

----------------------------------------------------------------
Darrick J. Wong (10):
xfs: speed up xfs_iwalk_adjust_start a little bit
xfs: implement live inode scan for scrub
xfs: allow scrub to hook metadata updates in other writers
xfs: stagger the starting AG of scrub iscans to reduce contention
xfs: cache a bunch of inodes for repair scans
xfs: iscan batching should handle unallocated inodes too
xfs: create a static name for the dot entry too
xfs: create a predicate to determine if two xfs_names are the same
xfs: create a macro for decoding ftypes in tracepoints
xfs: repair file modes by scanning for a dirent pointing to us

fs/xfs/Kconfig | 5 +
fs/xfs/Makefile | 2 +
fs/xfs/libxfs/xfs_da_format.h | 11 +
fs/xfs/libxfs/xfs_dir2.c | 6 +
fs/xfs/libxfs/xfs_dir2.h | 13 +
fs/xfs/scrub/dir.c | 4 +-
fs/xfs/scrub/inode_repair.c | 236 ++++++++++++-
fs/xfs/scrub/iscan.c | 767 ++++++++++++++++++++++++++++++++++++++++++
fs/xfs/scrub/iscan.h | 84 +++++
fs/xfs/scrub/trace.c | 2 +
fs/xfs/scrub/trace.h | 194 +++++++++++
fs/xfs/xfs_hooks.c | 52 +++
fs/xfs/xfs_hooks.h | 65 ++++
fs/xfs/xfs_iwalk.c | 13 +-
fs/xfs/xfs_linux.h | 1 +
15 files changed, 1436 insertions(+), 19 deletions(-)
create mode 100644 fs/xfs/scrub/iscan.c
create mode 100644 fs/xfs/scrub/iscan.h
create mode 100644 fs/xfs/xfs_hooks.c
create mode 100644 fs/xfs/xfs_hooks.h