From: Darrick J. Wong <djwong@xxxxxxxxxx> Refactor the mechanics of marking a metadata inode into a helper function so that we don't have to open-code that for every single metadata inode. Signed-off-by: "Darrick J. Wong" <djwong@xxxxxxxxxx> --- repair/phase6.c | 76 ++++++++++++++++++++----------------------------------- 1 file changed, 28 insertions(+), 48 deletions(-) diff --git a/repair/phase6.c b/repair/phase6.c index 0f13d996fe726a..0c80c4aa36af4a 100644 --- a/repair/phase6.c +++ b/repair/phase6.c @@ -2891,6 +2891,22 @@ _("error %d fixing shortform directory %llu\n"), libxfs_irele(ip); } +static void +mark_inode( + struct xfs_mount *mp, + xfs_ino_t ino) +{ + struct ino_tree_node *irec; + int offset; + + irec = find_inode_rec(mp, XFS_INO_TO_AGNO(mp, ino), + XFS_INO_TO_AGINO(mp, ino)); + + offset = XFS_INO_TO_AGINO(mp, ino) - irec->ino_startnum; + + add_inode_reached(irec, offset); +} + /* * mark realtime bitmap and summary inodes as reached. * quota inode will be marked here as well @@ -2898,54 +2914,18 @@ _("error %d fixing shortform directory %llu\n"), static void mark_standalone_inodes(xfs_mount_t *mp) { - ino_tree_node_t *irec; - int offset; - - irec = find_inode_rec(mp, XFS_INO_TO_AGNO(mp, mp->m_sb.sb_rbmino), - XFS_INO_TO_AGINO(mp, mp->m_sb.sb_rbmino)); - - offset = XFS_INO_TO_AGINO(mp, mp->m_sb.sb_rbmino) - - irec->ino_startnum; - - add_inode_reached(irec, offset); - - irec = find_inode_rec(mp, XFS_INO_TO_AGNO(mp, mp->m_sb.sb_rsumino), - XFS_INO_TO_AGINO(mp, mp->m_sb.sb_rsumino)); - - offset = XFS_INO_TO_AGINO(mp, mp->m_sb.sb_rsumino) - - irec->ino_startnum; - - add_inode_reached(irec, offset); - - if (fs_quotas) { - if (mp->m_sb.sb_uquotino - && mp->m_sb.sb_uquotino != NULLFSINO) { - irec = find_inode_rec(mp, XFS_INO_TO_AGNO(mp, - mp->m_sb.sb_uquotino), - XFS_INO_TO_AGINO(mp, mp->m_sb.sb_uquotino)); - offset = XFS_INO_TO_AGINO(mp, mp->m_sb.sb_uquotino) - - irec->ino_startnum; - add_inode_reached(irec, offset); - } - if (mp->m_sb.sb_gquotino - && mp->m_sb.sb_gquotino != NULLFSINO) { - irec = find_inode_rec(mp, XFS_INO_TO_AGNO(mp, - mp->m_sb.sb_gquotino), - XFS_INO_TO_AGINO(mp, mp->m_sb.sb_gquotino)); - offset = XFS_INO_TO_AGINO(mp, mp->m_sb.sb_gquotino) - - irec->ino_startnum; - add_inode_reached(irec, offset); - } - if (mp->m_sb.sb_pquotino - && mp->m_sb.sb_pquotino != NULLFSINO) { - irec = find_inode_rec(mp, XFS_INO_TO_AGNO(mp, - mp->m_sb.sb_pquotino), - XFS_INO_TO_AGINO(mp, mp->m_sb.sb_pquotino)); - offset = XFS_INO_TO_AGINO(mp, mp->m_sb.sb_pquotino) - - irec->ino_startnum; - add_inode_reached(irec, offset); - } - } + mark_inode(mp, mp->m_sb.sb_rbmino); + mark_inode(mp, mp->m_sb.sb_rsumino); + + if (!fs_quotas) + return; + + if (mp->m_sb.sb_uquotino && mp->m_sb.sb_uquotino != NULLFSINO) + mark_inode(mp, mp->m_sb.sb_uquotino); + if (mp->m_sb.sb_gquotino && mp->m_sb.sb_gquotino != NULLFSINO) + mark_inode(mp, mp->m_sb.sb_gquotino); + if (mp->m_sb.sb_pquotino && mp->m_sb.sb_pquotino != NULLFSINO) + mark_inode(mp, mp->m_sb.sb_pquotino); } static void