Commit 128d0fd1 authored by Chandan Babu R's avatar Chandan Babu R
Browse files

Merge tag 'scrub-nlinks-6.9_2024-02-23' of...

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: default avatarDarrick J. Wong <djwong@kernel.org>
Signed-off-by: default avatarChandan 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
parents aa03f524 6b631c60
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -160,6 +160,7 @@ xfs-y += $(addprefix scrub/, \
				   ialloc.o \
				   inode.o \
				   iscan.o \
				   nlinks.o \
				   parent.o \
				   readdir.o \
				   refcount.o \
@@ -193,6 +194,7 @@ xfs-y += $(addprefix scrub/, \
				   ialloc_repair.o \
				   inode_repair.o \
				   newbt.o \
				   nlinks_repair.o \
				   reap.o \
				   refcount_repair.o \
				   repair.o \
+3 −1
Original line number Diff line number Diff line
@@ -196,6 +196,7 @@ struct xfs_fsop_geom {
#define XFS_FSOP_GEOM_SICK_RT_BITMAP	(1 << 4)  /* realtime bitmap */
#define XFS_FSOP_GEOM_SICK_RT_SUMMARY	(1 << 5)  /* realtime summary */
#define XFS_FSOP_GEOM_SICK_QUOTACHECK	(1 << 6)  /* quota counts */
#define XFS_FSOP_GEOM_SICK_NLINKS	(1 << 7)  /* inode link counts */

/* Output for XFS_FS_COUNTS */
typedef struct xfs_fsop_counts {
@@ -711,9 +712,10 @@ struct xfs_scrub_metadata {
#define XFS_SCRUB_TYPE_PQUOTA	23	/* project quotas */
#define XFS_SCRUB_TYPE_FSCOUNTERS 24	/* fs summary counters */
#define XFS_SCRUB_TYPE_QUOTACHECK 25	/* quota counters */
#define XFS_SCRUB_TYPE_NLINKS	26	/* inode link counts */

/* Number of scrub subcommands. */
#define XFS_SCRUB_TYPE_NR	26
#define XFS_SCRUB_TYPE_NR	27

/* i: Repair this metadata. */
#define XFS_SCRUB_IFLAG_REPAIR		(1u << 0)
+3 −1
Original line number Diff line number Diff line
@@ -42,6 +42,7 @@ struct xfs_fsop_geom;
#define XFS_SICK_FS_GQUOTA	(1 << 2)  /* group quota */
#define XFS_SICK_FS_PQUOTA	(1 << 3)  /* project quota */
#define XFS_SICK_FS_QUOTACHECK	(1 << 4)  /* quota counts */
#define XFS_SICK_FS_NLINKS	(1 << 5)  /* inode link counts */

/* Observable health issues for realtime volume metadata. */
#define XFS_SICK_RT_BITMAP	(1 << 0)  /* realtime bitmap */
@@ -79,7 +80,8 @@ struct xfs_fsop_geom;
				 XFS_SICK_FS_UQUOTA | \
				 XFS_SICK_FS_GQUOTA | \
				 XFS_SICK_FS_PQUOTA | \
				 XFS_SICK_FS_QUOTACHECK)
				 XFS_SICK_FS_QUOTACHECK | \
				 XFS_SICK_FS_NLINKS)

#define XFS_SICK_RT_PRIMARY	(XFS_SICK_RT_BITMAP | \
				 XFS_SICK_RT_SUMMARY)
+3 −0
Original line number Diff line number Diff line
@@ -1302,6 +1302,9 @@ xchk_fsgates_enable(
	if (scrub_fsgates & XCHK_FSGATES_QUOTA)
		xfs_dqtrx_hook_enable();

	if (scrub_fsgates & XCHK_FSGATES_DIRENTS)
		xfs_dir_hook_enable();

	sc->flags |= scrub_fsgates;
}

+1 −0
Original line number Diff line number Diff line
@@ -129,6 +129,7 @@ xchk_setup_quotacheck(struct xfs_scrub *sc)
}
#endif
int xchk_setup_fscounters(struct xfs_scrub *sc);
int xchk_setup_nlinks(struct xfs_scrub *sc);

void xchk_ag_free(struct xfs_scrub *sc, struct xchk_ag *sa);
int xchk_ag_init(struct xfs_scrub *sc, xfs_agnumber_t agno,
Loading