Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 1f31c98d authored by Darrick J. Wong's avatar Darrick J. Wong
Browse files

xfs: only validate summary counts on primary superblock



Skip the summary counter checks for secondary superblocks and inprogress
primary superblocks because mkfs has always written those out with
zeroed summary counters.

Signed-off-by: default avatarDarrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: default avatarCarlos Maiolino <cmaiolino@redhat.com>
parent c2b6e159
Loading
Loading
Loading
Loading
+10 −4
Original line number Original line Diff line number Diff line
@@ -148,6 +148,7 @@ xfs_validate_sb_read(
STATIC int
STATIC int
xfs_validate_sb_write(
xfs_validate_sb_write(
	struct xfs_mount	*mp,
	struct xfs_mount	*mp,
	struct xfs_buf		*bp,
	struct xfs_sb		*sbp)
	struct xfs_sb		*sbp)
{
{
	/*
	/*
@@ -155,10 +156,15 @@ xfs_validate_sb_write(
	 * the superblock.  We skip this in the read validator because there
	 * the superblock.  We skip this in the read validator because there
	 * could be newer superblocks in the log and if the values are garbage
	 * could be newer superblocks in the log and if the values are garbage
	 * even after replay we'll recalculate them at the end of log mount.
	 * even after replay we'll recalculate them at the end of log mount.
	 *
	 * mkfs has traditionally written zeroed counters to inprogress and
	 * secondary superblocks, so allow this usage to continue because
	 * we never read counters from such superblocks.
	 */
	 */
	if (sbp->sb_fdblocks > sbp->sb_dblocks ||
	if (XFS_BUF_ADDR(bp) == XFS_SB_DADDR && !sbp->sb_inprogress &&
	    (sbp->sb_fdblocks > sbp->sb_dblocks ||
	     !xfs_verify_icount(mp, sbp->sb_icount) ||
	     !xfs_verify_icount(mp, sbp->sb_icount) ||
	    sbp->sb_ifree > sbp->sb_icount) {
	     sbp->sb_ifree > sbp->sb_icount)) {
		xfs_warn(mp, "SB summary counter sanity check failed");
		xfs_warn(mp, "SB summary counter sanity check failed");
		return -EFSCORRUPTED;
		return -EFSCORRUPTED;
	}
	}
@@ -756,7 +762,7 @@ xfs_sb_write_verify(
	error = xfs_validate_sb_common(mp, bp, &sb);
	error = xfs_validate_sb_common(mp, bp, &sb);
	if (error)
	if (error)
		goto out_error;
		goto out_error;
	error = xfs_validate_sb_write(mp, &sb);
	error = xfs_validate_sb_write(mp, bp, &sb);
	if (error)
	if (error)
		goto out_error;
		goto out_error;