From: Dave Chinner <dchinner@xxxxxxxxxx> To allow the kernel to use larger inode clusters than the standard 8192 bytes, we need to set the inode alignment fields appropriately so that the kernel is consistent in it's inode to buffer mappings. We set the alignment to allow a constant 32 inodes per cluster, instead of a fixed 8k cluster size. Signed-off-by: Dave Chinner <dchinner@xxxxxxxxxx> --- include/libxfs.h | 2 +- mkfs/xfs_mkfs.c | 5 ++++- repair/sb.c | 41 ++++++++++++++++++++++++++++------------- 3 files changed, 33 insertions(+), 15 deletions(-) diff --git a/include/libxfs.h b/include/libxfs.h index 049b217..9d7c579 100644 --- a/include/libxfs.h +++ b/include/libxfs.h @@ -182,7 +182,7 @@ typedef struct xfs_mount { __uint8_t m_sectbb_log; /* sectorlog - BBSHIFT */ __uint8_t m_agno_log; /* log #ag's */ __uint8_t m_agino_log; /* #bits for agino in inum */ - __uint16_t m_inode_cluster_size;/* min inode buf size */ + uint m_inode_cluster_size;/* min inode buf size */ uint m_blockmask; /* sb_blocksize-1 */ uint m_blockwsize; /* sb_blocksize in words */ uint m_blockwmask; /* blockwsize-1 */ diff --git a/mkfs/xfs_mkfs.c b/mkfs/xfs_mkfs.c index 60e4d88..feb5bd0 100644 --- a/mkfs/xfs_mkfs.c +++ b/mkfs/xfs_mkfs.c @@ -2501,7 +2501,10 @@ _("size %s specified for log subvolume is too large, maximum is %lld blocks\n"), } else sbp->sb_logsunit = 0; if (iaflag) { - sbp->sb_inoalignmt = XFS_INODE_BIG_CLUSTER_SIZE >> blocklog; + int cluster_size = XFS_INODE_BIG_CLUSTER_SIZE; + if (crcs_enabled) + cluster_size *= isize / XFS_DINODE_MIN_SIZE; + sbp->sb_inoalignmt = cluster_size >> blocklog; iaflag = sbp->sb_inoalignmt != 0; } else sbp->sb_inoalignmt = 0; diff --git a/repair/sb.c b/repair/sb.c index e2f5933..86404ce 100644 --- a/repair/sb.c +++ b/repair/sb.c @@ -169,17 +169,37 @@ find_secondary_sb(xfs_sb_t *rsb) } /* - * calculate what inode alignment field ought to be - * based on internal superblock info + * Calculate what inode alignment field ought to be + * based on internal superblock info and determine if it is valid. + * + * For v5 superblocks, the inode alignment will either match that of the + * standard XFS_INODE_BIG_CLUSTER_SIZE, or it will be scaled based on the inode + * size. Either value is valid in this case. + * + * Return true if the alignment is valid, false otherwise. */ -static int -calc_ino_align(xfs_sb_t *sb) +static bool +sb_validate_ino_align(struct xfs_sb *sb) { - xfs_extlen_t align; + xfs_extlen_t align; + if (!xfs_sb_version_hasalign(sb)) + return true; + + /* standard cluster size alignment is always valid */ align = XFS_INODE_BIG_CLUSTER_SIZE >> sb->sb_blocklog; + if (align == sb->sb_inoalignmt) + return true; + + /* alignment scaled by inode size is v5 only for now */ + if (!xfs_sb_version_hascrc(sb)) + return false; - return(align); + align *= sb->sb_inodesize / XFS_DINODE_MIN_SIZE; + if (align == sb->sb_inoalignmt) + return true; + + return false; } /* @@ -228,7 +248,6 @@ int verify_sb(xfs_sb_t *sb, int is_primary_sb) { __uint32_t bsize; - xfs_extlen_t align; int i; /* check magic number and version number */ @@ -364,12 +383,8 @@ verify_sb(xfs_sb_t *sb, int is_primary_sb) /* * verify correctness of inode alignment if it's there */ - if (xfs_sb_version_hasalign(sb)) { - align = calc_ino_align(sb); - - if (align != sb->sb_inoalignmt) - return(XR_BAD_INO_ALIGN); - } + if (!sb_validate_ino_align(sb)) + return(XR_BAD_INO_ALIGN); /* * verify max. % of inodes (sb_imax_pct) -- 1.8.3.2 _______________________________________________ xfs mailing list xfs@xxxxxxxxxxx http://oss.sgi.com/mailman/listinfo/xfs