diff options
author | Dave Chinner <dchinner@redhat.com> | 2013-04-03 01:11:31 -0400 |
---|---|---|
committer | Ben Myers <bpm@sgi.com> | 2013-04-27 14:03:12 -0400 |
commit | 04a1e6c5b222b089c6960dfc5352002002a4355f (patch) | |
tree | 8d6fd5760be10aad7e11e50a8fd12a678a288908 /fs/xfs/xfs_sb.h | |
parent | 61fe135c1dde112f483bba01d645debd881b5428 (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/xfs_sb.h')
-rw-r--r-- | fs/xfs/xfs_sb.h | 100 |
1 files changed, 71 insertions, 29 deletions
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) | |||
382 | static inline int xfs_sb_version_hasnlink(xfs_sb_t *sbp) | 417 | static 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 | ||
397 | static inline int xfs_sb_version_hasquota(xfs_sb_t *sbp) | 432 | static 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 | ||
403 | static inline void xfs_sb_version_addquota(xfs_sb_t *sbp) | 438 | static 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 | ||
412 | static inline int xfs_sb_version_hasalign(xfs_sb_t *sbp) | 447 | static 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 | ||
418 | static inline int xfs_sb_version_hasdalign(xfs_sb_t *sbp) | 454 | static 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 | ||
430 | static inline int xfs_sb_version_hasdirv2(xfs_sb_t *sbp) | 466 | static 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 | ||
436 | static inline int xfs_sb_version_haslogv2(xfs_sb_t *sbp) | 473 | static 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 | ||
442 | static inline int xfs_sb_version_hasextflgbit(xfs_sb_t *sbp) | 480 | static 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 | ||
448 | static inline int xfs_sb_version_hassector(xfs_sb_t *sbp) | 487 | static 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 | ||
454 | static inline int xfs_sb_version_hasasciici(xfs_sb_t *sbp) | 493 | static 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 | ||
460 | static inline int xfs_sb_version_hasmorebits(xfs_sb_t *sbp) | 499 | static 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 | ||
476 | static inline int xfs_sb_version_haslazysbcount(xfs_sb_t *sbp) | 516 | static 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 | ||
482 | static inline int xfs_sb_version_hasattr2(xfs_sb_t *sbp) | 523 | static 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 | ||
488 | static inline void xfs_sb_version_addattr2(xfs_sb_t *sbp) | 530 | static 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 | ||
501 | static inline int xfs_sb_version_hasprojid32bit(xfs_sb_t *sbp) | 543 | static 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 | ||
507 | static inline int xfs_sb_version_hascrc(xfs_sb_t *sbp) | 550 | static 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 | /* |