From: Brian Foster Date: Thu, 5 Feb 2015 23:31:44 +0000 (+1100) Subject: repair: fix v5 sb ino alignment calculation for large blocksizes X-Git-Tag: v3.2.3-rc1~34 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=16e16276896509e05330f7bff988bdfb1130c89b;p=thirdparty%2Fxfsprogs-dev.git repair: fix v5 sb ino alignment calculation for large blocksizes xfs_repair validates the superblock inode alignment field against several possible valid values. On v5 superblocks, the inode alignment can be scaled up based on the inode size in relation to the minimum inode size. If the block size is larger than the default cluster size (consider large page size arches such as ppc64), the initial alignment value calculates to zero. If the inode size is large enough such that sb_inoalignmt is not zero, sb_validate_ino_align() scales the align value by the factor of inode size increase. If align is zero, however, we multiply by zero, the subsequent check incorrectly fails and the overall superblock verification fails as well. To reproduce, format an fs as follows on ppc64 and run xfs_repair: mkfs.xfs -f -m crc=1 -b size=64k -i size=2k Fix the scaled alignment calculation by scaling the default cluster size appropriately to avoid a multiplication by zero. Signed-off-by: Brian Foster Reviewed-by: Dave Chinner Signed-off-by: Dave Chinner --- diff --git a/repair/sb.c b/repair/sb.c index a663728f4..ce20d0d75 100644 --- a/repair/sb.c +++ b/repair/sb.c @@ -196,7 +196,8 @@ sb_validate_ino_align(struct xfs_sb *sb) if (!xfs_sb_version_hascrc(sb)) return false; - align *= sb->sb_inodesize / XFS_DINODE_MIN_SIZE; + align = (XFS_INODE_BIG_CLUSTER_SIZE * + sb->sb_inodesize / XFS_DINODE_MIN_SIZE) >> sb->sb_blocklog; if (align == sb->sb_inoalignmt) return true;