On 5/5/22 11:04 AM, Darrick J. Wong wrote: > From: Darrick J. Wong <djwong@xxxxxxxxxx> > > We warn about suspicious roots and btree heights before metadumping the > inode btree, so do the same for the free inode btree. > > Signed-off-by: Darrick J. Wong <djwong@xxxxxxxxxx> LGTM. I wonder if we could do this without quite so much copied code (like maybe call copy_inodes twice, once for inode tree once for free inode tree?) but that's a patch for another day. Reviewed-by: Eric Sandeen <sandeen@xxxxxxxxxx> === maybe like this? worth it? static int copy_inodes( xfs_agnumber_t agno, xfs_agi_t *agi, int finobt) { xfs_agblock_t root; int levels; int type; if (finobt) { type = TYP_FINOBT; root = be32_to_cpu(agi->agi_root); levels = be32_to_cpu(agi->agi_level); } else { type = TYP_INOBT; root = be32_to_cpu(agi->agi_free_root); levels = be32_to_cpu(agi->agi_free_level); } /* validate root and levels before processing the tree */ if (root == 0 || root > mp->m_sb.sb_agblocks) { if (show_warnings) print_warning("invalid block number (%u) in %s" "root in agi %u", root, finobt ? "finobt" : "inobt", agno); return 1; } if (levels > M_IGEO(mp)->inobt_maxlevels) { if (show_warnings) print_warning("invalid level (%u) in %s root " "in agi %u", levels, finobt ? "finobt" : "inobt", agno); return 1; } if (!scan_btree(agno, root, levels, type, &finobt, scanfunc_ino)) return 0; return 1; }