xfs: online repair of file link counts [v29.3 03/18]

Now that we've created the infrastructure to perform live scans of every
 file in the filesystem and the necessary hook infrastructure to observe
 live updates, use it to scan directories to compute the correct link
 counts for files in the filesystem, and reset those link counts.
 
 This patchset creates a tailored readdir implementation for scrub
 because the regular version has to cycle ILOCKs to copy information to
 userspace.  We can't cycle the ILOCK during the nlink scan and we don't
 need all the other VFS support code (maintaining a readdir cursor and
 translating XFS structures to VFS structures and back) so it was easier
 to duplicate the code.
 
 This has been running on the djcloud for months with no problems.  Enjoy!
 
 Signed-off-by: Darrick J. Wong <djwong@kernel.org>
 -----BEGIN PGP SIGNATURE-----
 
 iHUEABYKAB0WIQQ2qTKExjcn+O1o2YRKO3ySh0YRpgUCZdlBYAAKCRBKO3ySh0YR
 pjJwAP49J6UgZUDQMX4rQ5q2TbyHLnyvUzeiQ/Cc8IqXau5VxwD/U3QNPii5uUMw
 jNid2AMba4AkXkskU6fr4do8UwmPSQ4=
 =Dva/
 -----END PGP SIGNATURE-----

Merge tag 'scrub-nlinks-6.9_2024-02-23' of https://git.kernel.org/pub/scm/linux/kernel/git/djwong/xfs-linux into xfs-6.9-mergeC

xfs: online repair of file link counts

Now that we've created the infrastructure to perform live scans of every
file in the filesystem and the necessary hook infrastructure to observe
live updates, use it to scan directories to compute the correct link
counts for files in the filesystem, and reset those link counts.

This patchset creates a tailored readdir implementation for scrub
because the regular version has to cycle ILOCKs to copy information to
userspace.  We can't cycle the ILOCK during the nlink scan and we don't
need all the other VFS support code (maintaining a readdir cursor and
translating XFS structures to VFS structures and back) so it was easier
to duplicate the code.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Signed-off-by: Chandan Babu R <chandanbabu@kernel.org>

* tag 'scrub-nlinks-6.9_2024-02-23' of https://git.kernel.org/pub/scm/linux/kernel/git/djwong/xfs-linux:
  xfs: teach repair to fix file nlinks
  xfs: track directory entry updates during live nlinks fsck
  xfs: teach scrub to check file nlinks
  xfs: report health of inode link counts
This commit is contained in:
Chandan Babu R 2024-02-24 09:47:39 +05:30
commit 128d0fd1ab
21 changed files with 1623 additions and 4 deletions