aboutsummaryrefslogtreecommitdiffstats
path: root/fs/xfs
diff options
context:
space:
mode:
authorDave Chinner <dchinner@redhat.com>2013-04-03 01:11:31 -0400
committerBen Myers <bpm@sgi.com>2013-04-27 14:03:12 -0400
commit04a1e6c5b222b089c6960dfc5352002002a4355f (patch)
tree8d6fd5760be10aad7e11e50a8fd12a678a288908 /fs/xfs
parent61fe135c1dde112f483bba01d645debd881b5428 (diff)
xfs: add CRC checks to the superblock
With the addition of CRCs, there is such a wide and varied change to the on disk format that it makes sense to bump the superblock version number rather than try to use feature bits for all the new functionality. This commit introduces all the new superblock fields needed for all the new functionality: feature masks similar to ext4, separate project quota inodes, a LSN field for recovery and the CRC field. This commit does not bump the superblock version number, however. That will be done as a separate commit at the end of the series after all the new functionality is present so we switch it all on in one commit. This means that we can slowly introduce the changes without them being active and hence maintain bisectability of the tree. This patch is based on a patch originally written by myself back from SGI days, which was subsequently modified by Christoph Hellwig. There is relatively little of that patch remaining, but the history of the patch still should be acknowledged here. Signed-off-by: Dave Chinner <dchinner@redhat.com> Reviewed-by: Ben Myers <bpm@sgi.com> Signed-off-by: Ben Myers <bpm@sgi.com>
Diffstat (limited to 'fs/xfs')
-rw-r--r--fs/xfs/xfs_log_recover.c8
-rw-r--r--fs/xfs/xfs_mount.c108
-rw-r--r--fs/xfs/xfs_mount.h1
-rw-r--r--fs/xfs/xfs_sb.h100
4 files changed, 172 insertions, 45 deletions
diff --git a/fs/xfs/xfs_log_recover.c b/fs/xfs/xfs_log_recover.c
index 86285071700b..5303b3db3c98 100644
--- a/fs/xfs/xfs_log_recover.c
+++ b/fs/xfs/xfs_log_recover.c
@@ -2040,6 +2040,14 @@ xlog_recovery_validate_buf_type(
2040 } 2040 }
2041 bp->b_ops = &xfs_attr3_rmt_buf_ops; 2041 bp->b_ops = &xfs_attr3_rmt_buf_ops;
2042 break; 2042 break;
2043 case XFS_BLFT_SB_BUF:
2044 if (magic32 != XFS_SB_MAGIC) {
2045 xfs_warn(mp, "Bad SB block magic!");
2046 ASSERT(0);
2047 break;
2048 }
2049 bp->b_ops = &xfs_sb_buf_ops;
2050 break;
2043 default: 2051 default:
2044 xfs_warn(mp, "Unknown buffer type %d!", 2052 xfs_warn(mp, "Unknown buffer type %d!",
2045 xfs_blft_from_flags(buf_f)); 2053 xfs_blft_from_flags(buf_f));
diff --git a/fs/xfs/xfs_mount.c b/fs/xfs/xfs_mount.c
index 3806088a8f77..140136cf2dc0 100644
--- a/fs/xfs/xfs_mount.c
+++ b/fs/xfs/xfs_mount.c
@@ -43,6 +43,8 @@
43#include "xfs_utils.h" 43#include "xfs_utils.h"
44#include "xfs_trace.h" 44#include "xfs_trace.h"
45#include "xfs_icache.h" 45#include "xfs_icache.h"
46#include "xfs_cksum.h"
47#include "xfs_buf_item.h"
46 48
47 49
48#ifdef HAVE_PERCPU_SB 50#ifdef HAVE_PERCPU_SB
@@ -109,6 +111,12 @@ static const struct {
109 { offsetof(xfs_sb_t, sb_logsunit), 0 }, 111 { offsetof(xfs_sb_t, sb_logsunit), 0 },
110 { offsetof(xfs_sb_t, sb_features2), 0 }, 112 { offsetof(xfs_sb_t, sb_features2), 0 },
111 { offsetof(xfs_sb_t, sb_bad_features2), 0 }, 113 { offsetof(xfs_sb_t, sb_bad_features2), 0 },
114 { offsetof(xfs_sb_t, sb_features_compat), 0 },
115 { offsetof(xfs_sb_t, sb_features_ro_compat), 0 },
116 { offsetof(xfs_sb_t, sb_features_incompat), 0 },
117 { offsetof(xfs_sb_t, sb_crc), 0 },
118 { offsetof(xfs_sb_t, sb_pquotino), 0 },
119 { offsetof(xfs_sb_t, sb_lsn), 0 },
112 { sizeof(xfs_sb_t), 0 } 120 { sizeof(xfs_sb_t), 0 }
113}; 121};
114 122
@@ -319,11 +327,23 @@ xfs_mount_validate_sb(
319 return XFS_ERROR(EWRONGFS); 327 return XFS_ERROR(EWRONGFS);
320 } 328 }
321 329
330
322 if (!xfs_sb_good_version(sbp)) { 331 if (!xfs_sb_good_version(sbp)) {
323 xfs_warn(mp, "bad version"); 332 xfs_warn(mp, "bad version");
324 return XFS_ERROR(EWRONGFS); 333 return XFS_ERROR(EWRONGFS);
325 } 334 }
326 335
336 /*
337 * Do not allow Version 5 superblocks to mount right now, even though
338 * support is in place. We need to implement the proper feature masks
339 * first.
340 */
341 if (XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_5) {
342 xfs_alert(mp,
343 "Version 5 superblock detected. Experimental support not yet enabled!");
344 return XFS_ERROR(EINVAL);
345 }
346
327 if (unlikely( 347 if (unlikely(
328 sbp->sb_logstart == 0 && mp->m_logdev_targp == mp->m_ddev_targp)) { 348 sbp->sb_logstart == 0 && mp->m_logdev_targp == mp->m_ddev_targp)) {
329 xfs_warn(mp, 349 xfs_warn(mp,
@@ -557,6 +577,11 @@ xfs_sb_from_disk(
557 to->sb_logsunit = be32_to_cpu(from->sb_logsunit); 577 to->sb_logsunit = be32_to_cpu(from->sb_logsunit);
558 to->sb_features2 = be32_to_cpu(from->sb_features2); 578 to->sb_features2 = be32_to_cpu(from->sb_features2);
559 to->sb_bad_features2 = be32_to_cpu(from->sb_bad_features2); 579 to->sb_bad_features2 = be32_to_cpu(from->sb_bad_features2);
580 to->sb_features_compat = be32_to_cpu(from->sb_features_compat);
581 to->sb_features_ro_compat = be32_to_cpu(from->sb_features_ro_compat);
582 to->sb_features_incompat = be32_to_cpu(from->sb_features_incompat);
583 to->sb_pquotino = be64_to_cpu(from->sb_pquotino);
584 to->sb_lsn = be64_to_cpu(from->sb_lsn);
560} 585}
561 586
562/* 587/*
@@ -612,13 +637,12 @@ xfs_sb_to_disk(
612 } 637 }
613} 638}
614 639
615static void 640static int
616xfs_sb_verify( 641xfs_sb_verify(
617 struct xfs_buf *bp) 642 struct xfs_buf *bp)
618{ 643{
619 struct xfs_mount *mp = bp->b_target->bt_mount; 644 struct xfs_mount *mp = bp->b_target->bt_mount;
620 struct xfs_sb sb; 645 struct xfs_sb sb;
621 int error;
622 646
623 xfs_sb_from_disk(&sb, XFS_BUF_TO_SBP(bp)); 647 xfs_sb_from_disk(&sb, XFS_BUF_TO_SBP(bp));
624 648
@@ -626,16 +650,46 @@ xfs_sb_verify(
626 * Only check the in progress field for the primary superblock as 650 * Only check the in progress field for the primary superblock as
627 * mkfs.xfs doesn't clear it from secondary superblocks. 651 * mkfs.xfs doesn't clear it from secondary superblocks.
628 */ 652 */
629 error = xfs_mount_validate_sb(mp, &sb, bp->b_bn == XFS_SB_DADDR); 653 return xfs_mount_validate_sb(mp, &sb, bp->b_bn == XFS_SB_DADDR);
630 if (error)
631 xfs_buf_ioerror(bp, error);
632} 654}
633 655
656/*
657 * If the superblock has the CRC feature bit set or the CRC field is non-null,
658 * check that the CRC is valid. We check the CRC field is non-null because a
659 * single bit error could clear the feature bit and unused parts of the
660 * superblock are supposed to be zero. Hence a non-null crc field indicates that
661 * we've potentially lost a feature bit and we should check it anyway.
662 */
634static void 663static void
635xfs_sb_read_verify( 664xfs_sb_read_verify(
636 struct xfs_buf *bp) 665 struct xfs_buf *bp)
637{ 666{
638 xfs_sb_verify(bp); 667 struct xfs_mount *mp = bp->b_target->bt_mount;
668 struct xfs_dsb *dsb = XFS_BUF_TO_SBP(bp);
669 int error;
670
671 /*
672 * open code the version check to avoid needing to convert the entire
673 * superblock from disk order just to check the version number
674 */
675 if (dsb->sb_magicnum == cpu_to_be32(XFS_SB_MAGIC) &&
676 (((be16_to_cpu(dsb->sb_versionnum) & XFS_SB_VERSION_NUMBITS) ==
677 XFS_SB_VERSION_5) ||
678 dsb->sb_crc != 0)) {
679
680 if (!xfs_verify_cksum(bp->b_addr, be16_to_cpu(dsb->sb_sectsize),
681 offsetof(struct xfs_sb, sb_crc))) {
682 error = EFSCORRUPTED;
683 goto out_error;
684 }
685 }
686 error = xfs_sb_verify(bp);
687
688out_error:
689 if (error) {
690 XFS_CORRUPTION_ERROR(__func__, XFS_ERRLEVEL_LOW, mp, bp->b_addr);
691 xfs_buf_ioerror(bp, error);
692 }
639} 693}
640 694
641/* 695/*
@@ -648,11 +702,10 @@ static void
648xfs_sb_quiet_read_verify( 702xfs_sb_quiet_read_verify(
649 struct xfs_buf *bp) 703 struct xfs_buf *bp)
650{ 704{
651 struct xfs_sb sb; 705 struct xfs_dsb *dsb = XFS_BUF_TO_SBP(bp);
652 706
653 xfs_sb_from_disk(&sb, XFS_BUF_TO_SBP(bp));
654 707
655 if (sb.sb_magicnum == XFS_SB_MAGIC) { 708 if (dsb->sb_magicnum == cpu_to_be32(XFS_SB_MAGIC)) {
656 /* XFS filesystem, verify noisily! */ 709 /* XFS filesystem, verify noisily! */
657 xfs_sb_read_verify(bp); 710 xfs_sb_read_verify(bp);
658 return; 711 return;
@@ -663,9 +716,27 @@ xfs_sb_quiet_read_verify(
663 716
664static void 717static void
665xfs_sb_write_verify( 718xfs_sb_write_verify(
666 struct xfs_buf *bp) 719 struct xfs_buf *bp)
667{ 720{
668 xfs_sb_verify(bp); 721 struct xfs_mount *mp = bp->b_target->bt_mount;
722 struct xfs_buf_log_item *bip = bp->b_fspriv;
723 int error;
724
725 error = xfs_sb_verify(bp);
726 if (error) {
727 XFS_CORRUPTION_ERROR(__func__, XFS_ERRLEVEL_LOW, mp, bp->b_addr);
728 xfs_buf_ioerror(bp, error);
729 return;
730 }
731
732 if (!xfs_sb_version_hascrc(&mp->m_sb))
733 return;
734
735 if (bip)
736 XFS_BUF_TO_SBP(bp)->sb_lsn = cpu_to_be64(bip->bli_item.li_lsn);
737
738 xfs_update_cksum(bp->b_addr, BBTOB(bp->b_length),
739 offsetof(struct xfs_sb, sb_crc));
669} 740}
670 741
671const struct xfs_buf_ops xfs_sb_buf_ops = { 742const struct xfs_buf_ops xfs_sb_buf_ops = {
@@ -687,7 +758,8 @@ int
687xfs_readsb(xfs_mount_t *mp, int flags) 758xfs_readsb(xfs_mount_t *mp, int flags)
688{ 759{
689 unsigned int sector_size; 760 unsigned int sector_size;
690 xfs_buf_t *bp; 761 struct xfs_buf *bp;
762 struct xfs_sb *sbp = &mp->m_sb;
691 int error; 763 int error;
692 int loud = !(flags & XFS_MFSI_QUIET); 764 int loud = !(flags & XFS_MFSI_QUIET);
693 765
@@ -726,10 +798,10 @@ reread:
726 /* 798 /*
727 * We must be able to do sector-sized and sector-aligned IO. 799 * We must be able to do sector-sized and sector-aligned IO.
728 */ 800 */
729 if (sector_size > mp->m_sb.sb_sectsize) { 801 if (sector_size > sbp->sb_sectsize) {
730 if (loud) 802 if (loud)
731 xfs_warn(mp, "device supports %u byte sectors (not %u)", 803 xfs_warn(mp, "device supports %u byte sectors (not %u)",
732 sector_size, mp->m_sb.sb_sectsize); 804 sector_size, sbp->sb_sectsize);
733 error = ENOSYS; 805 error = ENOSYS;
734 goto release_buf; 806 goto release_buf;
735 } 807 }
@@ -738,15 +810,18 @@ reread:
738 * If device sector size is smaller than the superblock size, 810 * If device sector size is smaller than the superblock size,
739 * re-read the superblock so the buffer is correctly sized. 811 * re-read the superblock so the buffer is correctly sized.
740 */ 812 */
741 if (sector_size < mp->m_sb.sb_sectsize) { 813 if (sector_size < sbp->sb_sectsize) {
742 xfs_buf_relse(bp); 814 xfs_buf_relse(bp);
743 sector_size = mp->m_sb.sb_sectsize; 815 sector_size = sbp->sb_sectsize;
744 goto reread; 816 goto reread;
745 } 817 }
746 818
747 /* Initialize per-cpu counters */ 819 /* Initialize per-cpu counters */
748 xfs_icsb_reinit_counters(mp); 820 xfs_icsb_reinit_counters(mp);
749 821
822 /* no need to be quiet anymore, so reset the buf ops */
823 bp->b_ops = &xfs_sb_buf_ops;
824
750 mp->m_sb_bp = bp; 825 mp->m_sb_bp = bp;
751 xfs_buf_unlock(bp); 826 xfs_buf_unlock(bp);
752 return 0; 827 return 0;
@@ -1633,6 +1708,7 @@ xfs_mod_sb(xfs_trans_t *tp, __int64_t fields)
1633 ASSERT((1LL << f) & XFS_SB_MOD_BITS); 1708 ASSERT((1LL << f) & XFS_SB_MOD_BITS);
1634 first = xfs_sb_info[f].offset; 1709 first = xfs_sb_info[f].offset;
1635 1710
1711 xfs_trans_buf_set_type(tp, bp, XFS_BLFT_SB_BUF);
1636 xfs_trans_log_buf(tp, bp, first, last); 1712 xfs_trans_log_buf(tp, bp, first, last);
1637} 1713}
1638 1714
diff --git a/fs/xfs/xfs_mount.h b/fs/xfs/xfs_mount.h
index 687c1711b6eb..b004cecdfb04 100644
--- a/fs/xfs/xfs_mount.h
+++ b/fs/xfs/xfs_mount.h
@@ -391,6 +391,7 @@ extern void xfs_set_low_space_thresholds(struct xfs_mount *);
391 391
392#endif /* __KERNEL__ */ 392#endif /* __KERNEL__ */
393 393
394extern void xfs_sb_calc_crc(struct xfs_buf *);
394extern void xfs_mod_sb(struct xfs_trans *, __int64_t); 395extern void xfs_mod_sb(struct xfs_trans *, __int64_t);
395extern int xfs_initialize_perag(struct xfs_mount *, xfs_agnumber_t, 396extern int xfs_initialize_perag(struct xfs_mount *, xfs_agnumber_t,
396 xfs_agnumber_t *); 397 xfs_agnumber_t *);
diff --git a/fs/xfs/xfs_sb.h b/fs/xfs/xfs_sb.h
index a05b45175fb0..457fefae5683 100644
--- a/fs/xfs/xfs_sb.h
+++ b/fs/xfs/xfs_sb.h
@@ -32,6 +32,7 @@ struct xfs_mount;
32#define XFS_SB_VERSION_2 2 /* 6.2 - attributes */ 32#define XFS_SB_VERSION_2 2 /* 6.2 - attributes */
33#define XFS_SB_VERSION_3 3 /* 6.2 - new inode version */ 33#define XFS_SB_VERSION_3 3 /* 6.2 - new inode version */
34#define XFS_SB_VERSION_4 4 /* 6.2+ - bitmask version */ 34#define XFS_SB_VERSION_4 4 /* 6.2+ - bitmask version */
35#define XFS_SB_VERSION_5 5 /* CRC enabled filesystem */
35#define XFS_SB_VERSION_NUMBITS 0x000f 36#define XFS_SB_VERSION_NUMBITS 0x000f
36#define XFS_SB_VERSION_ALLFBITS 0xfff0 37#define XFS_SB_VERSION_ALLFBITS 0xfff0
37#define XFS_SB_VERSION_SASHFBITS 0xf000 38#define XFS_SB_VERSION_SASHFBITS 0xf000
@@ -161,6 +162,18 @@ typedef struct xfs_sb {
161 */ 162 */
162 __uint32_t sb_bad_features2; 163 __uint32_t sb_bad_features2;
163 164
165 /* version 5 superblock fields start here */
166
167 /* feature masks */
168 __uint32_t sb_features_compat;
169 __uint32_t sb_features_ro_compat;
170 __uint32_t sb_features_incompat;
171
172 __uint32_t sb_crc; /* superblock crc */
173
174 xfs_ino_t sb_pquotino; /* project quota inode */
175 xfs_lsn_t sb_lsn; /* last write sequence */
176
164 /* must be padded to 64 bit alignment */ 177 /* must be padded to 64 bit alignment */
165} xfs_sb_t; 178} xfs_sb_t;
166 179
@@ -229,7 +242,19 @@ typedef struct xfs_dsb {
229 * for features2 bits. Easiest just to mark it bad and not use 242 * for features2 bits. Easiest just to mark it bad and not use
230 * it for anything else. 243 * it for anything else.
231 */ 244 */
232 __be32 sb_bad_features2; 245 __be32 sb_bad_features2;
246
247 /* version 5 superblock fields start here */
248
249 /* feature masks */
250 __be32 sb_features_compat;
251 __be32 sb_features_ro_compat;
252 __be32 sb_features_incompat;
253
254 __le32 sb_crc; /* superblock crc */
255
256 __be64 sb_pquotino; /* project quota inode */
257 __be64 sb_lsn; /* last write sequence */
233 258
234 /* must be padded to 64 bit alignment */ 259 /* must be padded to 64 bit alignment */
235} xfs_dsb_t; 260} xfs_dsb_t;
@@ -250,7 +275,9 @@ typedef enum {
250 XFS_SBS_GQUOTINO, XFS_SBS_QFLAGS, XFS_SBS_FLAGS, XFS_SBS_SHARED_VN, 275 XFS_SBS_GQUOTINO, XFS_SBS_QFLAGS, XFS_SBS_FLAGS, XFS_SBS_SHARED_VN,
251 XFS_SBS_INOALIGNMT, XFS_SBS_UNIT, XFS_SBS_WIDTH, XFS_SBS_DIRBLKLOG, 276 XFS_SBS_INOALIGNMT, XFS_SBS_UNIT, XFS_SBS_WIDTH, XFS_SBS_DIRBLKLOG,
252 XFS_SBS_LOGSECTLOG, XFS_SBS_LOGSECTSIZE, XFS_SBS_LOGSUNIT, 277 XFS_SBS_LOGSECTLOG, XFS_SBS_LOGSECTSIZE, XFS_SBS_LOGSUNIT,
253 XFS_SBS_FEATURES2, XFS_SBS_BAD_FEATURES2, 278 XFS_SBS_FEATURES2, XFS_SBS_BAD_FEATURES2, XFS_SBS_FEATURES_COMPAT,
279 XFS_SBS_FEATURES_RO_COMPAT, XFS_SBS_FEATURES_INCOMPAT, XFS_SBS_CRC,
280 XFS_SBS_PQUOTINO, XFS_SBS_LSN,
254 XFS_SBS_FIELDCOUNT 281 XFS_SBS_FIELDCOUNT
255} xfs_sb_field_t; 282} xfs_sb_field_t;
256 283
@@ -276,6 +303,11 @@ typedef enum {
276#define XFS_SB_FDBLOCKS XFS_SB_MVAL(FDBLOCKS) 303#define XFS_SB_FDBLOCKS XFS_SB_MVAL(FDBLOCKS)
277#define XFS_SB_FEATURES2 XFS_SB_MVAL(FEATURES2) 304#define XFS_SB_FEATURES2 XFS_SB_MVAL(FEATURES2)
278#define XFS_SB_BAD_FEATURES2 XFS_SB_MVAL(BAD_FEATURES2) 305#define XFS_SB_BAD_FEATURES2 XFS_SB_MVAL(BAD_FEATURES2)
306#define XFS_SB_FEATURES_COMPAT XFS_SB_MVAL(FEATURES_COMPAT)
307#define XFS_SB_FEATURES_RO_COMPAT XFS_SB_MVAL(FEATURES_RO_COMPAT)
308#define XFS_SB_FEATURES_INCOMPAT XFS_SB_MVAL(FEATURES_INCOMPAT)
309#define XFS_SB_CRC XFS_SB_MVAL(CRC)
310#define XFS_SB_PQUOTINO XFS_SB_MVAL(PQUOTINO)
279#define XFS_SB_NUM_BITS ((int)XFS_SBS_FIELDCOUNT) 311#define XFS_SB_NUM_BITS ((int)XFS_SBS_FIELDCOUNT)
280#define XFS_SB_ALL_BITS ((1LL << XFS_SB_NUM_BITS) - 1) 312#define XFS_SB_ALL_BITS ((1LL << XFS_SB_NUM_BITS) - 1)
281#define XFS_SB_MOD_BITS \ 313#define XFS_SB_MOD_BITS \
@@ -283,7 +315,8 @@ typedef enum {
283 XFS_SB_VERSIONNUM | XFS_SB_UQUOTINO | XFS_SB_GQUOTINO | \ 315 XFS_SB_VERSIONNUM | XFS_SB_UQUOTINO | XFS_SB_GQUOTINO | \
284 XFS_SB_QFLAGS | XFS_SB_SHARED_VN | XFS_SB_UNIT | XFS_SB_WIDTH | \ 316 XFS_SB_QFLAGS | XFS_SB_SHARED_VN | XFS_SB_UNIT | XFS_SB_WIDTH | \
285 XFS_SB_ICOUNT | XFS_SB_IFREE | XFS_SB_FDBLOCKS | XFS_SB_FEATURES2 | \ 317 XFS_SB_ICOUNT | XFS_SB_IFREE | XFS_SB_FDBLOCKS | XFS_SB_FEATURES2 | \
286 XFS_SB_BAD_FEATURES2) 318 XFS_SB_BAD_FEATURES2 | XFS_SB_FEATURES_COMPAT | \
319 XFS_SB_FEATURES_RO_COMPAT | XFS_SB_FEATURES_INCOMPAT | XFS_SB_PQUOTINO)
287 320
288 321
289/* 322/*
@@ -325,6 +358,8 @@ static inline int xfs_sb_good_version(xfs_sb_t *sbp)
325 358
326 return 1; 359 return 1;
327 } 360 }
361 if (XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_5)
362 return 1;
328 363
329 return 0; 364 return 0;
330} 365}
@@ -365,7 +400,7 @@ static inline int xfs_sb_version_hasattr(xfs_sb_t *sbp)
365{ 400{
366 return sbp->sb_versionnum == XFS_SB_VERSION_2 || 401 return sbp->sb_versionnum == XFS_SB_VERSION_2 ||
367 sbp->sb_versionnum == XFS_SB_VERSION_3 || 402 sbp->sb_versionnum == XFS_SB_VERSION_3 ||
368 (XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_4 && 403 (XFS_SB_VERSION_NUM(sbp) >= XFS_SB_VERSION_4 &&
369 (sbp->sb_versionnum & XFS_SB_VERSION_ATTRBIT)); 404 (sbp->sb_versionnum & XFS_SB_VERSION_ATTRBIT));
370} 405}
371 406
@@ -373,7 +408,7 @@ static inline void xfs_sb_version_addattr(xfs_sb_t *sbp)
373{ 408{
374 if (sbp->sb_versionnum == XFS_SB_VERSION_1) 409 if (sbp->sb_versionnum == XFS_SB_VERSION_1)
375 sbp->sb_versionnum = XFS_SB_VERSION_2; 410 sbp->sb_versionnum = XFS_SB_VERSION_2;
376 else if (XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_4) 411 else if (XFS_SB_VERSION_NUM(sbp) >= XFS_SB_VERSION_4)
377 sbp->sb_versionnum |= XFS_SB_VERSION_ATTRBIT; 412 sbp->sb_versionnum |= XFS_SB_VERSION_ATTRBIT;
378 else 413 else
379 sbp->sb_versionnum = XFS_SB_VERSION_4 | XFS_SB_VERSION_ATTRBIT; 414 sbp->sb_versionnum = XFS_SB_VERSION_4 | XFS_SB_VERSION_ATTRBIT;
@@ -382,7 +417,7 @@ static inline void xfs_sb_version_addattr(xfs_sb_t *sbp)
382static inline int xfs_sb_version_hasnlink(xfs_sb_t *sbp) 417static inline int xfs_sb_version_hasnlink(xfs_sb_t *sbp)
383{ 418{
384 return sbp->sb_versionnum == XFS_SB_VERSION_3 || 419 return sbp->sb_versionnum == XFS_SB_VERSION_3 ||
385 (XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_4 && 420 (XFS_SB_VERSION_NUM(sbp) >= XFS_SB_VERSION_4 &&
386 (sbp->sb_versionnum & XFS_SB_VERSION_NLINKBIT)); 421 (sbp->sb_versionnum & XFS_SB_VERSION_NLINKBIT));
387} 422}
388 423
@@ -396,13 +431,13 @@ static inline void xfs_sb_version_addnlink(xfs_sb_t *sbp)
396 431
397static inline int xfs_sb_version_hasquota(xfs_sb_t *sbp) 432static inline int xfs_sb_version_hasquota(xfs_sb_t *sbp)
398{ 433{
399 return XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_4 && 434 return XFS_SB_VERSION_NUM(sbp) >= XFS_SB_VERSION_4 &&
400 (sbp->sb_versionnum & XFS_SB_VERSION_QUOTABIT); 435 (sbp->sb_versionnum & XFS_SB_VERSION_QUOTABIT);
401} 436}
402 437
403static inline void xfs_sb_version_addquota(xfs_sb_t *sbp) 438static inline void xfs_sb_version_addquota(xfs_sb_t *sbp)
404{ 439{
405 if (XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_4) 440 if (XFS_SB_VERSION_NUM(sbp) >= XFS_SB_VERSION_4)
406 sbp->sb_versionnum |= XFS_SB_VERSION_QUOTABIT; 441 sbp->sb_versionnum |= XFS_SB_VERSION_QUOTABIT;
407 else 442 else
408 sbp->sb_versionnum = xfs_sb_version_tonew(sbp->sb_versionnum) | 443 sbp->sb_versionnum = xfs_sb_version_tonew(sbp->sb_versionnum) |
@@ -411,13 +446,14 @@ static inline void xfs_sb_version_addquota(xfs_sb_t *sbp)
411 446
412static inline int xfs_sb_version_hasalign(xfs_sb_t *sbp) 447static inline int xfs_sb_version_hasalign(xfs_sb_t *sbp)
413{ 448{
414 return XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_4 && 449 return (XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_5) ||
415 (sbp->sb_versionnum & XFS_SB_VERSION_ALIGNBIT); 450 (XFS_SB_VERSION_NUM(sbp) >= XFS_SB_VERSION_4 &&
451 (sbp->sb_versionnum & XFS_SB_VERSION_ALIGNBIT));
416} 452}
417 453
418static inline int xfs_sb_version_hasdalign(xfs_sb_t *sbp) 454static inline int xfs_sb_version_hasdalign(xfs_sb_t *sbp)
419{ 455{
420 return XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_4 && 456 return XFS_SB_VERSION_NUM(sbp) >= XFS_SB_VERSION_4 &&
421 (sbp->sb_versionnum & XFS_SB_VERSION_DALIGNBIT); 457 (sbp->sb_versionnum & XFS_SB_VERSION_DALIGNBIT);
422} 458}
423 459
@@ -429,38 +465,42 @@ static inline int xfs_sb_version_hasshared(xfs_sb_t *sbp)
429 465
430static inline int xfs_sb_version_hasdirv2(xfs_sb_t *sbp) 466static inline int xfs_sb_version_hasdirv2(xfs_sb_t *sbp)
431{ 467{
432 return XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_4 && 468 return (XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_5) ||
433 (sbp->sb_versionnum & XFS_SB_VERSION_DIRV2BIT); 469 (XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_4 &&
470 (sbp->sb_versionnum & XFS_SB_VERSION_DIRV2BIT));
434} 471}
435 472
436static inline int xfs_sb_version_haslogv2(xfs_sb_t *sbp) 473static inline int xfs_sb_version_haslogv2(xfs_sb_t *sbp)
437{ 474{
438 return XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_4 && 475 return (XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_5) ||
439 (sbp->sb_versionnum & XFS_SB_VERSION_LOGV2BIT); 476 (XFS_SB_VERSION_NUM(sbp) >= XFS_SB_VERSION_4 &&
477 (sbp->sb_versionnum & XFS_SB_VERSION_LOGV2BIT));
440} 478}
441 479
442static inline int xfs_sb_version_hasextflgbit(xfs_sb_t *sbp) 480static inline int xfs_sb_version_hasextflgbit(xfs_sb_t *sbp)
443{ 481{
444 return XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_4 && 482 return (XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_5) ||
445 (sbp->sb_versionnum & XFS_SB_VERSION_EXTFLGBIT); 483 (XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_4 &&
484 (sbp->sb_versionnum & XFS_SB_VERSION_EXTFLGBIT));
446} 485}
447 486
448static inline int xfs_sb_version_hassector(xfs_sb_t *sbp) 487static inline int xfs_sb_version_hassector(xfs_sb_t *sbp)
449{ 488{
450 return XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_4 && 489 return XFS_SB_VERSION_NUM(sbp) >= XFS_SB_VERSION_4 &&
451 (sbp->sb_versionnum & XFS_SB_VERSION_SECTORBIT); 490 (sbp->sb_versionnum & XFS_SB_VERSION_SECTORBIT);
452} 491}
453 492
454static inline int xfs_sb_version_hasasciici(xfs_sb_t *sbp) 493static inline int xfs_sb_version_hasasciici(xfs_sb_t *sbp)
455{ 494{
456 return XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_4 && 495 return XFS_SB_VERSION_NUM(sbp) >= XFS_SB_VERSION_4 &&
457 (sbp->sb_versionnum & XFS_SB_VERSION_BORGBIT); 496 (sbp->sb_versionnum & XFS_SB_VERSION_BORGBIT);
458} 497}
459 498
460static inline int xfs_sb_version_hasmorebits(xfs_sb_t *sbp) 499static inline int xfs_sb_version_hasmorebits(xfs_sb_t *sbp)
461{ 500{
462 return XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_4 && 501 return (XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_5) ||
463 (sbp->sb_versionnum & XFS_SB_VERSION_MOREBITSBIT); 502 (XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_4 &&
503 (sbp->sb_versionnum & XFS_SB_VERSION_MOREBITSBIT));
464} 504}
465 505
466/* 506/*
@@ -475,14 +515,16 @@ static inline int xfs_sb_version_hasmorebits(xfs_sb_t *sbp)
475 515
476static inline int xfs_sb_version_haslazysbcount(xfs_sb_t *sbp) 516static inline int xfs_sb_version_haslazysbcount(xfs_sb_t *sbp)
477{ 517{
478 return xfs_sb_version_hasmorebits(sbp) && 518 return (XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_5) ||
479 (sbp->sb_features2 & XFS_SB_VERSION2_LAZYSBCOUNTBIT); 519 (xfs_sb_version_hasmorebits(sbp) &&
520 (sbp->sb_features2 & XFS_SB_VERSION2_LAZYSBCOUNTBIT));
480} 521}
481 522
482static inline int xfs_sb_version_hasattr2(xfs_sb_t *sbp) 523static inline int xfs_sb_version_hasattr2(xfs_sb_t *sbp)
483{ 524{
484 return xfs_sb_version_hasmorebits(sbp) && 525 return (XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_5) ||
485 (sbp->sb_features2 & XFS_SB_VERSION2_ATTR2BIT); 526 (xfs_sb_version_hasmorebits(sbp) &&
527 (sbp->sb_features2 & XFS_SB_VERSION2_ATTR2BIT));
486} 528}
487 529
488static inline void xfs_sb_version_addattr2(xfs_sb_t *sbp) 530static inline void xfs_sb_version_addattr2(xfs_sb_t *sbp)
@@ -500,14 +542,14 @@ static inline void xfs_sb_version_removeattr2(xfs_sb_t *sbp)
500 542
501static inline int xfs_sb_version_hasprojid32bit(xfs_sb_t *sbp) 543static inline int xfs_sb_version_hasprojid32bit(xfs_sb_t *sbp)
502{ 544{
503 return xfs_sb_version_hasmorebits(sbp) && 545 return (XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_5) ||
504 (sbp->sb_features2 & XFS_SB_VERSION2_PROJID32BIT); 546 (xfs_sb_version_hasmorebits(sbp) &&
547 (sbp->sb_features2 & XFS_SB_VERSION2_PROJID32BIT));
505} 548}
506 549
507static inline int xfs_sb_version_hascrc(xfs_sb_t *sbp) 550static inline int xfs_sb_version_hascrc(xfs_sb_t *sbp)
508{ 551{
509 return (xfs_sb_version_hasmorebits(sbp) && 552 return XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_5;
510 (sbp->sb_features2 & XFS_SB_VERSION2_CRCBIT));
511} 553}
512 554
513/* 555/*