From: Darrick J. Wong <djwong@xxxxxxxxxx> Amend the directory and parent pointer repair code to handle the root of the metadata directory tree correctly. Signed-off-by: Darrick J. Wong <djwong@xxxxxxxxxx> --- fs/xfs/scrub/dir_repair.c | 2 +- fs/xfs/scrub/inode_repair.c | 8 ++++---- fs/xfs/scrub/orphanage.c | 2 ++ fs/xfs/scrub/parent_repair.c | 2 +- 4 files changed, 8 insertions(+), 6 deletions(-) diff --git a/fs/xfs/scrub/dir_repair.c b/fs/xfs/scrub/dir_repair.c index 304eb042df7c9..a6e2219941be7 100644 --- a/fs/xfs/scrub/dir_repair.c +++ b/fs/xfs/scrub/dir_repair.c @@ -1324,7 +1324,7 @@ xrep_dir_scan_dirtree( int error; /* Roots of directory trees are their own parents. */ - if (sc->ip == sc->mp->m_rootip) + if (sc->ip == sc->mp->m_rootip || sc->ip == sc->mp->m_metadirip) xrep_findparent_scan_found(&rd->pscan, sc->ip->i_ino); /* diff --git a/fs/xfs/scrub/inode_repair.c b/fs/xfs/scrub/inode_repair.c index e2dde5834051c..2c4209054f41b 100644 --- a/fs/xfs/scrub/inode_repair.c +++ b/fs/xfs/scrub/inode_repair.c @@ -1718,14 +1718,14 @@ xrep_inode_pptr( return 0; /* The root directory doesn't have a parent pointer. */ - if (ip == mp->m_rootip) + if (ip == mp->m_rootip || ip == mp->m_metadirip) return 0; /* - * Metadata inodes are rooted in the superblock and do not have any - * parents. + * Prior to metadata directories, all metadata inodes are rooted in the + * superblock and do not have any parents. */ - if (xfs_is_metadata_inode(ip)) + if (!xfs_has_metadir(mp) && xfs_is_metadata_inode(ip)) return 0; /* Inode already has an attr fork; no further work possible here. */ diff --git a/fs/xfs/scrub/orphanage.c b/fs/xfs/scrub/orphanage.c index f1711d6031613..1c8f854aaf552 100644 --- a/fs/xfs/scrub/orphanage.c +++ b/fs/xfs/scrub/orphanage.c @@ -297,6 +297,8 @@ xrep_orphanage_can_adopt( return false; if (xfs_internal_inum(sc->mp, sc->ip->i_ino)) return false; + if (xfs_is_metadata_inode(sc->ip)) + return false; return true; } diff --git a/fs/xfs/scrub/parent_repair.c b/fs/xfs/scrub/parent_repair.c index 04ea0b05ed088..65158dff840bb 100644 --- a/fs/xfs/scrub/parent_repair.c +++ b/fs/xfs/scrub/parent_repair.c @@ -1345,7 +1345,7 @@ xrep_parent_rebuild_pptrs( * so that we can decide if we're moving this file to the orphanage. * For this purpose, root directories are their own parents. */ - if (sc->ip == sc->mp->m_rootip) { + if (sc->ip == sc->mp->m_rootip || sc->ip == sc->mp->m_metadirip) { xrep_findparent_scan_found(&rp->pscan, sc->ip->i_ino); } else { error = xrep_parent_lookup_pptrs(sc, &parent_ino);