aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEric Sandeen <sandeen@redhat.com>2011-05-20 17:52:17 -0400
committerAlex Elder <aelder@sgi.com>2011-07-08 12:32:51 -0400
commitc0e090ced259b85b854636c99dda95b7070a2785 (patch)
treeb87f23061f2bd75ecbf4a1906c4fb4aad27cd2d1
parente163cbde981c5988c3e80ca29589132336f18a72 (diff)
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: Pavol Gono <Pavol.Gono@siemens.com> Signed-off-by: Eric Sandeen <sandeen@redhat.com> Signed-off-by: Alex Elder <aelder@sgi.com>
-rw-r--r--fs/xfs/xfs_fs.h5
-rw-r--r--fs/xfs/xfs_mount.c33
2 files changed, 18 insertions, 20 deletions
diff --git a/fs/xfs/xfs_fs.h b/fs/xfs/xfs_fs.h
index 8f6fc1a96386..c13fed8c394a 100644
--- a/fs/xfs/xfs_fs.h
+++ b/fs/xfs/xfs_fs.h
@@ -249,6 +249,11 @@ typedef struct xfs_fsop_resblks {
249#define XFS_MAX_LOG_BYTES \ 249#define XFS_MAX_LOG_BYTES \
250 ((2 * 1024 * 1024 * 1024ULL) - XFS_MIN_LOG_BYTES) 250 ((2 * 1024 * 1024 * 1024ULL) - XFS_MIN_LOG_BYTES)
251 251
252/* Used for sanity checks on superblock */
253#define XFS_MAX_DBLOCKS(s) ((xfs_drfsbno_t)(s)->sb_agcount * (s)->sb_agblocks)
254#define XFS_MIN_DBLOCKS(s) ((xfs_drfsbno_t)((s)->sb_agcount - 1) * \
255 (s)->sb_agblocks + XFS_MIN_AG_BLOCKS)
256
252/* 257/*
253 * Structures for XFS_IOC_FSGROWFSDATA, XFS_IOC_FSGROWFSLOG & XFS_IOC_FSGROWFSRT 258 * Structures for XFS_IOC_FSGROWFSDATA, XFS_IOC_FSGROWFSLOG & XFS_IOC_FSGROWFSRT
254 */ 259 */
diff --git a/fs/xfs/xfs_mount.c b/fs/xfs/xfs_mount.c
index 77ffe3ce71fe..2be5e5cf897a 100644
--- a/fs/xfs/xfs_mount.c
+++ b/fs/xfs/xfs_mount.c
@@ -348,7 +348,7 @@ xfs_mount_validate_sb(
348 } 348 }
349 349
350 /* 350 /*
351 * More sanity checking. These were stolen directly from 351 * More sanity checking. Most of these were stolen directly from
352 * xfs_repair. 352 * xfs_repair.
353 */ 353 */
354 if (unlikely( 354 if (unlikely(
@@ -371,23 +371,13 @@ xfs_mount_validate_sb(
371 (sbp->sb_blocklog - sbp->sb_inodelog != sbp->sb_inopblog) || 371 (sbp->sb_blocklog - sbp->sb_inodelog != sbp->sb_inopblog) ||
372 (sbp->sb_rextsize * sbp->sb_blocksize > XFS_MAX_RTEXTSIZE) || 372 (sbp->sb_rextsize * sbp->sb_blocksize > XFS_MAX_RTEXTSIZE) ||
373 (sbp->sb_rextsize * sbp->sb_blocksize < XFS_MIN_RTEXTSIZE) || 373 (sbp->sb_rextsize * sbp->sb_blocksize < XFS_MIN_RTEXTSIZE) ||
374 (sbp->sb_imax_pct > 100 /* zero sb_imax_pct is valid */))) { 374 (sbp->sb_imax_pct > 100 /* zero sb_imax_pct is valid */) ||
375 sbp->sb_dblocks == 0 ||
376 sbp->sb_dblocks > XFS_MAX_DBLOCKS(sbp) ||
377 sbp->sb_dblocks < XFS_MIN_DBLOCKS(sbp))) {
375 if (loud) 378 if (loud)
376 xfs_warn(mp, "SB sanity check 1 failed"); 379 XFS_CORRUPTION_ERROR("SB sanity check failed",
377 return XFS_ERROR(EFSCORRUPTED); 380 XFS_ERRLEVEL_LOW, mp, sbp);
378 }
379
380 /*
381 * Sanity check AG count, size fields against data size field
382 */
383 if (unlikely(
384 sbp->sb_dblocks == 0 ||
385 sbp->sb_dblocks >
386 (xfs_drfsbno_t)sbp->sb_agcount * sbp->sb_agblocks ||
387 sbp->sb_dblocks < (xfs_drfsbno_t)(sbp->sb_agcount - 1) *
388 sbp->sb_agblocks + XFS_MIN_AG_BLOCKS)) {
389 if (loud)
390 xfs_warn(mp, "SB sanity check 2 failed");
391 return XFS_ERROR(EFSCORRUPTED); 381 return XFS_ERROR(EFSCORRUPTED);
392 } 382 }
393 383
@@ -864,7 +854,8 @@ xfs_update_alignment(xfs_mount_t *mp)
864 if ((BBTOB(mp->m_dalign) & mp->m_blockmask) || 854 if ((BBTOB(mp->m_dalign) & mp->m_blockmask) ||
865 (BBTOB(mp->m_swidth) & mp->m_blockmask)) { 855 (BBTOB(mp->m_swidth) & mp->m_blockmask)) {
866 if (mp->m_flags & XFS_MOUNT_RETERR) { 856 if (mp->m_flags & XFS_MOUNT_RETERR) {
867 xfs_warn(mp, "alignment check 1 failed"); 857 xfs_warn(mp, "alignment check failed: "
858 "(sunit/swidth vs. blocksize)");
868 return XFS_ERROR(EINVAL); 859 return XFS_ERROR(EINVAL);
869 } 860 }
870 mp->m_dalign = mp->m_swidth = 0; 861 mp->m_dalign = mp->m_swidth = 0;
@@ -875,6 +866,8 @@ xfs_update_alignment(xfs_mount_t *mp)
875 mp->m_dalign = XFS_BB_TO_FSBT(mp, mp->m_dalign); 866 mp->m_dalign = XFS_BB_TO_FSBT(mp, mp->m_dalign);
876 if (mp->m_dalign && (sbp->sb_agblocks % mp->m_dalign)) { 867 if (mp->m_dalign && (sbp->sb_agblocks % mp->m_dalign)) {
877 if (mp->m_flags & XFS_MOUNT_RETERR) { 868 if (mp->m_flags & XFS_MOUNT_RETERR) {
869 xfs_warn(mp, "alignment check failed: "
870 "(sunit/swidth vs. ag size)");
878 return XFS_ERROR(EINVAL); 871 return XFS_ERROR(EINVAL);
879 } 872 }
880 xfs_warn(mp, 873 xfs_warn(mp,
@@ -889,8 +882,8 @@ xfs_update_alignment(xfs_mount_t *mp)
889 mp->m_swidth = XFS_BB_TO_FSBT(mp, mp->m_swidth); 882 mp->m_swidth = XFS_BB_TO_FSBT(mp, mp->m_swidth);
890 } else { 883 } else {
891 if (mp->m_flags & XFS_MOUNT_RETERR) { 884 if (mp->m_flags & XFS_MOUNT_RETERR) {
892 xfs_warn(mp, 885 xfs_warn(mp, "alignment check failed: "
893 "stripe alignment turned off: sunit(%d) less than bsize(%d)", 886 "sunit(%d) less than bsize(%d)",
894 mp->m_dalign, 887 mp->m_dalign,
895 mp->m_blockmask +1); 888 mp->m_blockmask +1);
896 return XFS_ERROR(EINVAL); 889 return XFS_ERROR(EINVAL);