Skip to content

Commit f7cea94

Browse files
author
Chandan Babu R
committed
Merge tag 'scrub-directory-tree-6.10_2024-04-23' of https://git.kernel.org/pub/scm/linux/kernel/git/djwong/xfs-linux into xfs-6.10-mergeC
xfs: detect and correct directory tree problems Historically, checking the tree-ness of the directory tree structure has not been complete. Cycles of subdirectories break the tree properties, as do subdirectories with multiple parents. It's easy enough for DFS to detect problems as long as one of the participants is reachable from the root, but this technique cannot find unconnected cycles. Directory parent pointers change that, because we can discover all of these problems from a simple walk from a subdirectory towards the root. For each child we start with, if the walk terminates without reaching the root, we know the path is disconnected and ought to be attached to the lost and found. If we find ourselves, we know this is a cycle and can delete an incoming edge. If we find multiple paths to the root, we know to delete an incoming edge. Even better, once we've finished walking paths, we've identified the good ones and know which other path(s) to remove. Signed-off-by: Darrick J. Wong <[email protected]> Signed-off-by: Chandan Babu R <[email protected]> * tag 'scrub-directory-tree-6.10_2024-04-23' of https://git.kernel.org/pub/scm/linux/kernel/git/djwong/xfs-linux: xfs: fix corruptions in the directory tree xfs: report directory tree corruption in the health information xfs: invalidate dirloop scrub path data when concurrent updates happen xfs: teach online scrub to find directory tree structure problems
2 parents 1da824b + 3f31406 commit f7cea94

21 files changed

+2337
-4
lines changed

fs/xfs/Makefile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,7 @@ xfs-y += $(addprefix scrub/, \
163163
common.o \
164164
dabtree.o \
165165
dir.o \
166+
dirtree.o \
166167
fscounters.o \
167168
health.o \
168169
ialloc.o \
@@ -203,6 +204,7 @@ xfs-y += $(addprefix scrub/, \
203204
bmap_repair.o \
204205
cow_repair.o \
205206
dir_repair.o \
207+
dirtree_repair.o \
206208
findparent.o \
207209
fscounters_repair.o \
208210
ialloc_repair.o \

fs/xfs/libxfs/xfs_fs.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -411,6 +411,7 @@ struct xfs_bulkstat {
411411
#define XFS_BS_SICK_XATTR (1 << 5) /* extended attributes */
412412
#define XFS_BS_SICK_SYMLINK (1 << 6) /* symbolic link remote target */
413413
#define XFS_BS_SICK_PARENT (1 << 7) /* parent pointers */
414+
#define XFS_BS_SICK_DIRTREE (1 << 8) /* directory tree structure */
414415

415416
/*
416417
* Project quota id helpers (previously projid was 16bit only
@@ -719,9 +720,10 @@ struct xfs_scrub_metadata {
719720
#define XFS_SCRUB_TYPE_QUOTACHECK 25 /* quota counters */
720721
#define XFS_SCRUB_TYPE_NLINKS 26 /* inode link counts */
721722
#define XFS_SCRUB_TYPE_HEALTHY 27 /* everything checked out ok */
723+
#define XFS_SCRUB_TYPE_DIRTREE 28 /* directory tree structure */
722724

723725
/* Number of scrub subcommands. */
724-
#define XFS_SCRUB_TYPE_NR 28
726+
#define XFS_SCRUB_TYPE_NR 29
725727

726728
/* i: Repair this metadata. */
727729
#define XFS_SCRUB_IFLAG_REPAIR (1u << 0)

fs/xfs/libxfs/xfs_health.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@ struct xfs_da_args;
9595

9696
/* Don't propagate sick status to ag health summary during inactivation */
9797
#define XFS_SICK_INO_FORGET (1 << 12)
98+
#define XFS_SICK_INO_DIRTREE (1 << 13) /* directory tree structure */
9899

99100
/* Primary evidence of health problems in a given group. */
100101
#define XFS_SICK_FS_PRIMARY (XFS_SICK_FS_COUNTERS | \
@@ -125,7 +126,8 @@ struct xfs_da_args;
125126
XFS_SICK_INO_DIR | \
126127
XFS_SICK_INO_XATTR | \
127128
XFS_SICK_INO_SYMLINK | \
128-
XFS_SICK_INO_PARENT)
129+
XFS_SICK_INO_PARENT | \
130+
XFS_SICK_INO_DIRTREE)
129131

130132
#define XFS_SICK_INO_ZAPPED (XFS_SICK_INO_BMBTD_ZAPPED | \
131133
XFS_SICK_INO_BMBTA_ZAPPED | \

fs/xfs/scrub/common.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ int xchk_setup_directory(struct xfs_scrub *sc);
9292
int xchk_setup_xattr(struct xfs_scrub *sc);
9393
int xchk_setup_symlink(struct xfs_scrub *sc);
9494
int xchk_setup_parent(struct xfs_scrub *sc);
95+
int xchk_setup_dirtree(struct xfs_scrub *sc);
9596
#ifdef CONFIG_XFS_RT
9697
int xchk_setup_rtbitmap(struct xfs_scrub *sc);
9798
int xchk_setup_rtsummary(struct xfs_scrub *sc);

0 commit comments

Comments
 (0)