xfsprogs/repair: fix a couple large block size alignment issues
cover xfsprogs/repair: fix a couple large block size alignment issues
Hi all,
This is just a couple fixes for issues I came across while playing with larger block and inode sizes on a ppc64 box...
Brian
Brian Foster (2):
repair: fix v5 sb ino alignment calculation for large blocksizes
repair: check ino alignment value to avoid mod by zero
repair/sb.c | 3 ++- repair/scan.c | 6 ++++-- 2 files changed, 6 insertions(+), 3 deletions(-)
Signature · 6 lines
1.8.3.1 _______________________________________________ xfs mailing list [email protected] http://oss.sgi.com/mailman/listinfo/xfs
PATCH 1/2 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 <dev>
Fix the scaled alignment calculation by scaling the default cluster size appropriately to avoid a multiplication by zero.
--- repair/sb.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
repair/sb.c +2 -1
@@ -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;
Signature · 6 lines
1.8.3.1 _______________________________________________ xfs mailing list [email protected] http://oss.sgi.com/mailman/listinfo/xfs
PATCH 2/2 repair: check ino alignment value to avoid mod by zero
In reply to Brian Fosterxfs_repair checks inode records for valid alignment according to the alignment specified in the superblock. It currently performs the alignment check whenever fs_aligned_inodes is set, which is determined based on whether the fs supports the field.
Support for the field does not guarantee its value is non-zero, however. For example, a large block size fs on a large page size arch (e.g., ppc64):
mkfs.xfs -f -m crc=1,finobt=1 -b size=64k <dev>
... can lead to incorrect badly aligned inode record messages from xfs_repair and other problems.
Update the inobt and finobt checks to verify that alignment is a non-zero value before attempting to use it to divide (mod) by zero.
--- repair/scan.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
repair/scan.c +4 -2
@@ -770,7 +770,8 @@ scan_single_ino_chunk( (inodes_per_block <= XFS_INODES_PER_CHUNK && off != 0) || (inodes_per_block > XFS_INODES_PER_CHUNK && off % XFS_INODES_PER_CHUNK != 0) || - (fs_aligned_inodes && agbno % fs_ino_alignment != 0)) { + (fs_aligned_inodes && fs_ino_alignment && + agbno % fs_ino_alignment != 0)) {do_warn (_ ("badly aligned inode rec (starting inode = %" PRIu64")\n" ), lino);
@@ -929,7 +930,8 @@ scan_single_finobt_chunk( (inodes_per_block <= XFS_INODES_PER_CHUNK && off != 0) || (inodes_per_block > XFS_INODES_PER_CHUNK && off % XFS_INODES_PER_CHUNK != 0) || - (fs_aligned_inodes && agbno % fs_ino_alignment != 0)) { + (fs_aligned_inodes && fs_ino_alignment && + agbno % fs_ino_alignment != 0)) {do_warn (_ ("badly aligned finobt inode rec (starting inode = %" PRIu64")\n" ), lino);
Signature · 6 lines
1.8.3.1 _______________________________________________ xfs mailing list [email protected] http://oss.sgi.com/mailman/listinfo/xfs
Quoted 4 lines · Brian Foster
Hi all,
This is just a couple fixes for issues I came across while playing with larger block and inode sizes on a ppc64 box...
Yup, fixes look sane. I'll test and pull them in.
Cheers,
Dave.
Signature · 7 lines
Dave Chinner [email protected] _______________________________________________ xfs mailing list [email protected] http://oss.sgi.com/mailman/listinfo/xfs