Commit c0e090ce authored by Eric Sandeen's avatar Eric Sandeen Committed by Alex Elder

xfs: consolidate & clarify mount sanity checks

Pavol pointed out that there is one silent error case in the mount
path, and that others are rather uninformative.

I've taken Pavol's suggested patch and extended it a bit to also:

* fix a message which says "turned off" but actually errors out
* consolidate the vaguely differentiated "SB sanity check [12]"
  messages, and hexdump the superblock for analysis
Original-patch-by: default avatarPavol Gono <Pavol.Gono@siemens.com>
Signed-off-by: default avatarEric Sandeen <sandeen@redhat.com>
Signed-off-by: default avatarAlex Elder <aelder@sgi.com>
parent e163cbde
...@@ -249,6 +249,11 @@ typedef struct xfs_fsop_resblks { ...@@ -249,6 +249,11 @@ typedef struct xfs_fsop_resblks {
#define XFS_MAX_LOG_BYTES \ #define XFS_MAX_LOG_BYTES \
((2 * 1024 * 1024 * 1024ULL) - XFS_MIN_LOG_BYTES) ((2 * 1024 * 1024 * 1024ULL) - XFS_MIN_LOG_BYTES)
/* Used for sanity checks on superblock */
#define XFS_MAX_DBLOCKS(s) ((xfs_drfsbno_t)(s)->sb_agcount * (s)->sb_agblocks)
#define XFS_MIN_DBLOCKS(s) ((xfs_drfsbno_t)((s)->sb_agcount - 1) * \
(s)->sb_agblocks + XFS_MIN_AG_BLOCKS)
/* /*
* Structures for XFS_IOC_FSGROWFSDATA, XFS_IOC_FSGROWFSLOG & XFS_IOC_FSGROWFSRT * Structures for XFS_IOC_FSGROWFSDATA, XFS_IOC_FSGROWFSLOG & XFS_IOC_FSGROWFSRT
*/ */
......
...@@ -348,7 +348,7 @@ xfs_mount_validate_sb( ...@@ -348,7 +348,7 @@ xfs_mount_validate_sb(
} }
/* /*
* More sanity checking. These were stolen directly from * More sanity checking. Most of these were stolen directly from
* xfs_repair. * xfs_repair.
*/ */
if (unlikely( if (unlikely(
...@@ -371,23 +371,13 @@ xfs_mount_validate_sb( ...@@ -371,23 +371,13 @@ xfs_mount_validate_sb(
(sbp->sb_blocklog - sbp->sb_inodelog != sbp->sb_inopblog) || (sbp->sb_blocklog - sbp->sb_inodelog != sbp->sb_inopblog) ||
(sbp->sb_rextsize * sbp->sb_blocksize > XFS_MAX_RTEXTSIZE) || (sbp->sb_rextsize * sbp->sb_blocksize > XFS_MAX_RTEXTSIZE) ||
(sbp->sb_rextsize * sbp->sb_blocksize < XFS_MIN_RTEXTSIZE) || (sbp->sb_rextsize * sbp->sb_blocksize < XFS_MIN_RTEXTSIZE) ||
(sbp->sb_imax_pct > 100 /* zero sb_imax_pct is valid */))) { (sbp->sb_imax_pct > 100 /* zero sb_imax_pct is valid */) ||
sbp->sb_dblocks == 0 ||
sbp->sb_dblocks > XFS_MAX_DBLOCKS(sbp) ||
sbp->sb_dblocks < XFS_MIN_DBLOCKS(sbp))) {
if (loud) if (loud)
xfs_warn(mp, "SB sanity check 1 failed"); XFS_CORRUPTION_ERROR("SB sanity check failed",
return XFS_ERROR(EFSCORRUPTED); XFS_ERRLEVEL_LOW, mp, sbp);
}
/*
* Sanity check AG count, size fields against data size field
*/
if (unlikely(
sbp->sb_dblocks == 0 ||
sbp->sb_dblocks >
(xfs_drfsbno_t)sbp->sb_agcount * sbp->sb_agblocks ||
sbp->sb_dblocks < (xfs_drfsbno_t)(sbp->sb_agcount - 1) *
sbp->sb_agblocks + XFS_MIN_AG_BLOCKS)) {
if (loud)
xfs_warn(mp, "SB sanity check 2 failed");
return XFS_ERROR(EFSCORRUPTED); return XFS_ERROR(EFSCORRUPTED);
} }
...@@ -864,7 +854,8 @@ xfs_update_alignment(xfs_mount_t *mp) ...@@ -864,7 +854,8 @@ xfs_update_alignment(xfs_mount_t *mp)
if ((BBTOB(mp->m_dalign) & mp->m_blockmask) || if ((BBTOB(mp->m_dalign) & mp->m_blockmask) ||
(BBTOB(mp->m_swidth) & mp->m_blockmask)) { (BBTOB(mp->m_swidth) & mp->m_blockmask)) {
if (mp->m_flags & XFS_MOUNT_RETERR) { if (mp->m_flags & XFS_MOUNT_RETERR) {
xfs_warn(mp, "alignment check 1 failed"); xfs_warn(mp, "alignment check failed: "
"(sunit/swidth vs. blocksize)");
return XFS_ERROR(EINVAL); return XFS_ERROR(EINVAL);
} }
mp->m_dalign = mp->m_swidth = 0; mp->m_dalign = mp->m_swidth = 0;
...@@ -875,6 +866,8 @@ xfs_update_alignment(xfs_mount_t *mp) ...@@ -875,6 +866,8 @@ xfs_update_alignment(xfs_mount_t *mp)
mp->m_dalign = XFS_BB_TO_FSBT(mp, mp->m_dalign); mp->m_dalign = XFS_BB_TO_FSBT(mp, mp->m_dalign);
if (mp->m_dalign && (sbp->sb_agblocks % mp->m_dalign)) { if (mp->m_dalign && (sbp->sb_agblocks % mp->m_dalign)) {
if (mp->m_flags & XFS_MOUNT_RETERR) { if (mp->m_flags & XFS_MOUNT_RETERR) {
xfs_warn(mp, "alignment check failed: "
"(sunit/swidth vs. ag size)");
return XFS_ERROR(EINVAL); return XFS_ERROR(EINVAL);
} }
xfs_warn(mp, xfs_warn(mp,
...@@ -889,8 +882,8 @@ xfs_update_alignment(xfs_mount_t *mp) ...@@ -889,8 +882,8 @@ xfs_update_alignment(xfs_mount_t *mp)
mp->m_swidth = XFS_BB_TO_FSBT(mp, mp->m_swidth); mp->m_swidth = XFS_BB_TO_FSBT(mp, mp->m_swidth);
} else { } else {
if (mp->m_flags & XFS_MOUNT_RETERR) { if (mp->m_flags & XFS_MOUNT_RETERR) {
xfs_warn(mp, xfs_warn(mp, "alignment check failed: "
"stripe alignment turned off: sunit(%d) less than bsize(%d)", "sunit(%d) less than bsize(%d)",
mp->m_dalign, mp->m_dalign,
mp->m_blockmask +1); mp->m_blockmask +1);
return XFS_ERROR(EINVAL); return XFS_ERROR(EINVAL);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment