[PATCH 30/38] xfs_repair: adjust keep_fsinos to handle metadata directories

Darrick J. Wong
2024-10-11T01:21:58Z

In keep_fsinos, mark the root of the metadata directory tree as inuse.
The realtime bitmap and summary files still come after the root
directories, so this is a fairly simple change to the loop test.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
---
repair/phase5.c | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/repair/phase5.c b/repair/phase5.c
index 86b1f681a72bb8..a5e19998b97061 100644
--- a/repair/phase5.c
+++ b/repair/phase5.c
@@ -419,13 +419,18 @@ static void
keep_fsinos(xfs_mount_t *mp)
{
ino_tree_node_t *irec;
- int i;
+ unsigned int inuse = xfs_rootrec_inodes_inuse(mp), i;

irec = find_inode_rec(mp, XFS_INO_TO_AGNO(mp, mp->m_sb.sb_rootino),
XFS_INO_TO_AGINO(mp, mp->m_sb.sb_rootino));

- for (i = 0; i < 3; i++)
+ for (i = 0; i < inuse; i++) {
set_inode_used(irec, i);
+
+ /* Everything after the root dir is metadata */
+ if (i)
+ set_inode_is_meta(irec, i);
+ }
}

static void