summaryrefslogtreecommitdiff
path: root/fs/xfs/scrub/parent_repair.c
diff options
context:
space:
mode:
authorDarrick J. Wong <djwong@kernel.org>2022-07-14 11:15:14 -0700
committerDarrick J. Wong <djwong@kernel.org>2022-10-14 14:17:02 -0700
commit982026b2f6fe7b1a2cd7c5c5e9680894b8557347 (patch)
tree3dc9722ce5fce2de0e7f4f94637a323e67c64865 /fs/xfs/scrub/parent_repair.c
parent4c10b40c8fd5f5e5285f769dbd3897a192fb0b7e (diff)
xfs: scrub metadata directories
Teach online scrub about the metadata directory tree. Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Diffstat (limited to 'fs/xfs/scrub/parent_repair.c')
-rw-r--r--fs/xfs/scrub/parent_repair.c35
1 files changed, 30 insertions, 5 deletions
diff --git a/fs/xfs/scrub/parent_repair.c b/fs/xfs/scrub/parent_repair.c
index a3508d3fcc0e..45342783746d 100644
--- a/fs/xfs/scrub/parent_repair.c
+++ b/fs/xfs/scrub/parent_repair.c
@@ -135,6 +135,10 @@ xrep_findparent_walk_directory(
if (xrep_is_tempfile(dp))
return 0;
+ /* Don't mix metadata and regular directory trees. */
+ if (xfs_is_metadata_inode(dp) ^ xfs_is_metadata_inode(sc->ip))
+ return 0;
+
/* Try to lock dp; if we can, we're ready to scan! */
if (!xfs_ilock_nowait(dp, XFS_IOLOCK_SHARED)) {
xfs_ino_t orig_parent, new_parent;
@@ -219,12 +223,27 @@ xrep_parent_confirm(
};
int error;
+ /* The root directory always points to itself. */
+ if (sc->ip == sc->mp->m_rootip) {
+ *parent_ino = sc->mp->m_sb.sb_rootino;
+ return 0;
+ }
+
+ /* The metadata root directory always points to itself. */
+ if (sc->ip == sc->mp->m_metadirip) {
+ *parent_ino = sc->mp->m_sb.sb_metadirino;
+ return 0;
+ }
+
/*
- * The root directory always points to itself. Unlinked dirs can point
- * anywhere, so we point them at the root dir too.
+ * Unlinked dirs can point anywhere, so we point them at the root dir
+ * of whichever tree is appropriate.
*/
- if (sc->ip == sc->mp->m_rootip || VFS_I(sc->ip)->i_nlink == 0) {
- *parent_ino = sc->mp->m_sb.sb_rootino;
+ if (VFS_I(sc->ip)->i_nlink == 0) {
+ if (xfs_is_metadata_inode(sc->ip))
+ *parent_ino = sc->mp->m_sb.sb_metadirino;
+ else
+ *parent_ino = sc->mp->m_sb.sb_rootino;
return 0;
}
@@ -381,8 +400,14 @@ xrep_parent_self_reference(
if (sc->ip->i_ino == sc->mp->m_sb.sb_rootino)
return sc->mp->m_sb.sb_rootino;
- if (VFS_I(sc->ip)->i_nlink == 0)
+ if (sc->ip->i_ino == sc->mp->m_sb.sb_metadirino)
+ return sc->mp->m_sb.sb_metadirino;
+
+ if (VFS_I(sc->ip)->i_nlink == 0) {
+ if (xfs_is_metadata_inode(sc->ip))
+ return sc->mp->m_sb.sb_metadirino;
return sc->mp->m_sb.sb_rootino;
+ }
return NULLFSINO;
}