From 7ddb50f899b2624c39cbe5b563e7889972b3f4ea Mon Sep 17 00:00:00 2001 From: "Darrick J. Wong" Date: Fri, 19 Aug 2016 09:57:04 +1000 Subject: [PATCH] xfs_repair: fix fino_bno calculation when rmapbt is enabled In xfs_repair, we calculate where we think mkfs put the root inode block. However, the rmapbt component doesn't account for the fact that mkfs reserved 2 AGFL blocks for the rmapbt, so its calculation is off by a bit. This leads to it complaining (incorrectly) about the root inode block being in the wrong place and blowing up. [dchinner: small comment update to indicate AGFL block accounting] Signed-off-by: Darrick J. Wong Reviewed-by: Dave Chinner Signed-off-by: Dave Chinner --- repair/xfs_repair.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/repair/xfs_repair.c b/repair/xfs_repair.c index 94baf5d85..a635ea891 100644 --- a/repair/xfs_repair.c +++ b/repair/xfs_repair.c @@ -409,7 +409,7 @@ calc_mkfs(xfs_mount_t *mp) * Because the current shape of the btrees may differ from the current * shape, we open code the mkfs freelist block count here. mkfs creates * single level trees, so the calculation is pertty straight forward for - * the two trees that use the AGFL. + * the trees that use the AGFL. */ bnobt_root = howmany(4 * mp->m_sb.sb_sectsize, mp->m_sb.sb_blocksize); bcntbt_root = bnobt_root + 1; @@ -417,8 +417,10 @@ calc_mkfs(xfs_mount_t *mp) fino_bno = inobt_root + (2 * min(2, mp->m_ag_maxlevels)) + 1; if (xfs_sb_version_hasfinobt(&mp->m_sb)) fino_bno++; - if (xfs_sb_version_hasrmapbt(&mp->m_sb)) + if (xfs_sb_version_hasrmapbt(&mp->m_sb)) { + fino_bno += min(2, mp->m_rmap_maxlevels); /* agfl blocks */ fino_bno++; + } /* * If the log is allocated in the first allocation group we need to -- 2.47.2