aboutsummaryrefslogtreecommitdiffstats
path: root/fs/xfs/xfs_sb.h
diff options
context:
space:
mode:
Diffstat (limited to 'fs/xfs/xfs_sb.h')
-rw-r--r--fs/xfs/xfs_sb.h166
1 files changed, 137 insertions, 29 deletions
diff --git a/fs/xfs/xfs_sb.h b/fs/xfs/xfs_sb.h
index a05b45175fb0..2de58a85833c 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,20 @@ 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 __uint32_t sb_features_log_incompat;
172
173 __uint32_t sb_crc; /* superblock crc */
174 __uint32_t sb_pad;
175
176 xfs_ino_t sb_pquotino; /* project quota inode */
177 xfs_lsn_t sb_lsn; /* last write sequence */
178
164 /* must be padded to 64 bit alignment */ 179 /* must be padded to 64 bit alignment */
165} xfs_sb_t; 180} xfs_sb_t;
166 181
@@ -229,7 +244,21 @@ typedef struct xfs_dsb {
229 * for features2 bits. Easiest just to mark it bad and not use 244 * for features2 bits. Easiest just to mark it bad and not use
230 * it for anything else. 245 * it for anything else.
231 */ 246 */
232 __be32 sb_bad_features2; 247 __be32 sb_bad_features2;
248
249 /* version 5 superblock fields start here */
250
251 /* feature masks */
252 __be32 sb_features_compat;
253 __be32 sb_features_ro_compat;
254 __be32 sb_features_incompat;
255 __be32 sb_features_log_incompat;
256
257 __le32 sb_crc; /* superblock crc */
258 __be32 sb_pad;
259
260 __be64 sb_pquotino; /* project quota inode */
261 __be64 sb_lsn; /* last write sequence */
233 262
234 /* must be padded to 64 bit alignment */ 263 /* must be padded to 64 bit alignment */
235} xfs_dsb_t; 264} xfs_dsb_t;
@@ -250,7 +279,10 @@ typedef enum {
250 XFS_SBS_GQUOTINO, XFS_SBS_QFLAGS, XFS_SBS_FLAGS, XFS_SBS_SHARED_VN, 279 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, 280 XFS_SBS_INOALIGNMT, XFS_SBS_UNIT, XFS_SBS_WIDTH, XFS_SBS_DIRBLKLOG,
252 XFS_SBS_LOGSECTLOG, XFS_SBS_LOGSECTSIZE, XFS_SBS_LOGSUNIT, 281 XFS_SBS_LOGSECTLOG, XFS_SBS_LOGSECTSIZE, XFS_SBS_LOGSUNIT,
253 XFS_SBS_FEATURES2, XFS_SBS_BAD_FEATURES2, 282 XFS_SBS_FEATURES2, XFS_SBS_BAD_FEATURES2, XFS_SBS_FEATURES_COMPAT,
283 XFS_SBS_FEATURES_RO_COMPAT, XFS_SBS_FEATURES_INCOMPAT,
284 XFS_SBS_FEATURES_LOG_INCOMPAT, XFS_SBS_CRC, XFS_SBS_PAD,
285 XFS_SBS_PQUOTINO, XFS_SBS_LSN,
254 XFS_SBS_FIELDCOUNT 286 XFS_SBS_FIELDCOUNT
255} xfs_sb_field_t; 287} xfs_sb_field_t;
256 288
@@ -276,6 +308,12 @@ typedef enum {
276#define XFS_SB_FDBLOCKS XFS_SB_MVAL(FDBLOCKS) 308#define XFS_SB_FDBLOCKS XFS_SB_MVAL(FDBLOCKS)
277#define XFS_SB_FEATURES2 XFS_SB_MVAL(FEATURES2) 309#define XFS_SB_FEATURES2 XFS_SB_MVAL(FEATURES2)
278#define XFS_SB_BAD_FEATURES2 XFS_SB_MVAL(BAD_FEATURES2) 310#define XFS_SB_BAD_FEATURES2 XFS_SB_MVAL(BAD_FEATURES2)
311#define XFS_SB_FEATURES_COMPAT XFS_SB_MVAL(FEATURES_COMPAT)
312#define XFS_SB_FEATURES_RO_COMPAT XFS_SB_MVAL(FEATURES_RO_COMPAT)
313#define XFS_SB_FEATURES_INCOMPAT XFS_SB_MVAL(FEATURES_INCOMPAT)
314#define XFS_SB_FEATURES_LOG_INCOMPAT XFS_SB_MVAL(FEATURES_LOG_INCOMPAT)
315#define XFS_SB_CRC XFS_SB_MVAL(CRC)
316#define XFS_SB_PQUOTINO XFS_SB_MVAL(PQUOTINO)
279#define XFS_SB_NUM_BITS ((int)XFS_SBS_FIELDCOUNT) 317#define XFS_SB_NUM_BITS ((int)XFS_SBS_FIELDCOUNT)
280#define XFS_SB_ALL_BITS ((1LL << XFS_SB_NUM_BITS) - 1) 318#define XFS_SB_ALL_BITS ((1LL << XFS_SB_NUM_BITS) - 1)
281#define XFS_SB_MOD_BITS \ 319#define XFS_SB_MOD_BITS \
@@ -283,7 +321,9 @@ typedef enum {
283 XFS_SB_VERSIONNUM | XFS_SB_UQUOTINO | XFS_SB_GQUOTINO | \ 321 XFS_SB_VERSIONNUM | XFS_SB_UQUOTINO | XFS_SB_GQUOTINO | \
284 XFS_SB_QFLAGS | XFS_SB_SHARED_VN | XFS_SB_UNIT | XFS_SB_WIDTH | \ 322 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 | \ 323 XFS_SB_ICOUNT | XFS_SB_IFREE | XFS_SB_FDBLOCKS | XFS_SB_FEATURES2 | \
286 XFS_SB_BAD_FEATURES2) 324 XFS_SB_BAD_FEATURES2 | XFS_SB_FEATURES_COMPAT | \
325 XFS_SB_FEATURES_RO_COMPAT | XFS_SB_FEATURES_INCOMPAT | \
326 XFS_SB_FEATURES_LOG_INCOMPAT | XFS_SB_PQUOTINO)
287 327
288 328
289/* 329/*
@@ -325,6 +365,8 @@ static inline int xfs_sb_good_version(xfs_sb_t *sbp)
325 365
326 return 1; 366 return 1;
327 } 367 }
368 if (XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_5)
369 return 1;
328 370
329 return 0; 371 return 0;
330} 372}
@@ -365,7 +407,7 @@ static inline int xfs_sb_version_hasattr(xfs_sb_t *sbp)
365{ 407{
366 return sbp->sb_versionnum == XFS_SB_VERSION_2 || 408 return sbp->sb_versionnum == XFS_SB_VERSION_2 ||
367 sbp->sb_versionnum == XFS_SB_VERSION_3 || 409 sbp->sb_versionnum == XFS_SB_VERSION_3 ||
368 (XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_4 && 410 (XFS_SB_VERSION_NUM(sbp) >= XFS_SB_VERSION_4 &&
369 (sbp->sb_versionnum & XFS_SB_VERSION_ATTRBIT)); 411 (sbp->sb_versionnum & XFS_SB_VERSION_ATTRBIT));
370} 412}
371 413
@@ -373,7 +415,7 @@ static inline void xfs_sb_version_addattr(xfs_sb_t *sbp)
373{ 415{
374 if (sbp->sb_versionnum == XFS_SB_VERSION_1) 416 if (sbp->sb_versionnum == XFS_SB_VERSION_1)
375 sbp->sb_versionnum = XFS_SB_VERSION_2; 417 sbp->sb_versionnum = XFS_SB_VERSION_2;
376 else if (XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_4) 418 else if (XFS_SB_VERSION_NUM(sbp) >= XFS_SB_VERSION_4)
377 sbp->sb_versionnum |= XFS_SB_VERSION_ATTRBIT; 419 sbp->sb_versionnum |= XFS_SB_VERSION_ATTRBIT;
378 else 420 else
379 sbp->sb_versionnum = XFS_SB_VERSION_4 | XFS_SB_VERSION_ATTRBIT; 421 sbp->sb_versionnum = XFS_SB_VERSION_4 | XFS_SB_VERSION_ATTRBIT;
@@ -382,7 +424,7 @@ static inline void xfs_sb_version_addattr(xfs_sb_t *sbp)
382static inline int xfs_sb_version_hasnlink(xfs_sb_t *sbp) 424static inline int xfs_sb_version_hasnlink(xfs_sb_t *sbp)
383{ 425{
384 return sbp->sb_versionnum == XFS_SB_VERSION_3 || 426 return sbp->sb_versionnum == XFS_SB_VERSION_3 ||
385 (XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_4 && 427 (XFS_SB_VERSION_NUM(sbp) >= XFS_SB_VERSION_4 &&
386 (sbp->sb_versionnum & XFS_SB_VERSION_NLINKBIT)); 428 (sbp->sb_versionnum & XFS_SB_VERSION_NLINKBIT));
387} 429}
388 430
@@ -396,13 +438,13 @@ static inline void xfs_sb_version_addnlink(xfs_sb_t *sbp)
396 438
397static inline int xfs_sb_version_hasquota(xfs_sb_t *sbp) 439static inline int xfs_sb_version_hasquota(xfs_sb_t *sbp)
398{ 440{
399 return XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_4 && 441 return XFS_SB_VERSION_NUM(sbp) >= XFS_SB_VERSION_4 &&
400 (sbp->sb_versionnum & XFS_SB_VERSION_QUOTABIT); 442 (sbp->sb_versionnum & XFS_SB_VERSION_QUOTABIT);
401} 443}
402 444
403static inline void xfs_sb_version_addquota(xfs_sb_t *sbp) 445static inline void xfs_sb_version_addquota(xfs_sb_t *sbp)
404{ 446{
405 if (XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_4) 447 if (XFS_SB_VERSION_NUM(sbp) >= XFS_SB_VERSION_4)
406 sbp->sb_versionnum |= XFS_SB_VERSION_QUOTABIT; 448 sbp->sb_versionnum |= XFS_SB_VERSION_QUOTABIT;
407 else 449 else
408 sbp->sb_versionnum = xfs_sb_version_tonew(sbp->sb_versionnum) | 450 sbp->sb_versionnum = xfs_sb_version_tonew(sbp->sb_versionnum) |
@@ -411,13 +453,14 @@ static inline void xfs_sb_version_addquota(xfs_sb_t *sbp)
411 453
412static inline int xfs_sb_version_hasalign(xfs_sb_t *sbp) 454static inline int xfs_sb_version_hasalign(xfs_sb_t *sbp)
413{ 455{
414 return XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_4 && 456 return (XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_5) ||
415 (sbp->sb_versionnum & XFS_SB_VERSION_ALIGNBIT); 457 (XFS_SB_VERSION_NUM(sbp) >= XFS_SB_VERSION_4 &&
458 (sbp->sb_versionnum & XFS_SB_VERSION_ALIGNBIT));
416} 459}
417 460
418static inline int xfs_sb_version_hasdalign(xfs_sb_t *sbp) 461static inline int xfs_sb_version_hasdalign(xfs_sb_t *sbp)
419{ 462{
420 return XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_4 && 463 return XFS_SB_VERSION_NUM(sbp) >= XFS_SB_VERSION_4 &&
421 (sbp->sb_versionnum & XFS_SB_VERSION_DALIGNBIT); 464 (sbp->sb_versionnum & XFS_SB_VERSION_DALIGNBIT);
422} 465}
423 466
@@ -429,38 +472,42 @@ static inline int xfs_sb_version_hasshared(xfs_sb_t *sbp)
429 472
430static inline int xfs_sb_version_hasdirv2(xfs_sb_t *sbp) 473static inline int xfs_sb_version_hasdirv2(xfs_sb_t *sbp)
431{ 474{
432 return XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_4 && 475 return (XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_5) ||
433 (sbp->sb_versionnum & XFS_SB_VERSION_DIRV2BIT); 476 (XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_4 &&
477 (sbp->sb_versionnum & XFS_SB_VERSION_DIRV2BIT));
434} 478}
435 479
436static inline int xfs_sb_version_haslogv2(xfs_sb_t *sbp) 480static inline int xfs_sb_version_haslogv2(xfs_sb_t *sbp)
437{ 481{
438 return XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_4 && 482 return (XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_5) ||
439 (sbp->sb_versionnum & XFS_SB_VERSION_LOGV2BIT); 483 (XFS_SB_VERSION_NUM(sbp) >= XFS_SB_VERSION_4 &&
484 (sbp->sb_versionnum & XFS_SB_VERSION_LOGV2BIT));
440} 485}
441 486
442static inline int xfs_sb_version_hasextflgbit(xfs_sb_t *sbp) 487static inline int xfs_sb_version_hasextflgbit(xfs_sb_t *sbp)
443{ 488{
444 return XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_4 && 489 return (XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_5) ||
445 (sbp->sb_versionnum & XFS_SB_VERSION_EXTFLGBIT); 490 (XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_4 &&
491 (sbp->sb_versionnum & XFS_SB_VERSION_EXTFLGBIT));
446} 492}
447 493
448static inline int xfs_sb_version_hassector(xfs_sb_t *sbp) 494static inline int xfs_sb_version_hassector(xfs_sb_t *sbp)
449{ 495{
450 return XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_4 && 496 return XFS_SB_VERSION_NUM(sbp) >= XFS_SB_VERSION_4 &&
451 (sbp->sb_versionnum & XFS_SB_VERSION_SECTORBIT); 497 (sbp->sb_versionnum & XFS_SB_VERSION_SECTORBIT);
452} 498}
453 499
454static inline int xfs_sb_version_hasasciici(xfs_sb_t *sbp) 500static inline int xfs_sb_version_hasasciici(xfs_sb_t *sbp)
455{ 501{
456 return XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_4 && 502 return XFS_SB_VERSION_NUM(sbp) >= XFS_SB_VERSION_4 &&
457 (sbp->sb_versionnum & XFS_SB_VERSION_BORGBIT); 503 (sbp->sb_versionnum & XFS_SB_VERSION_BORGBIT);
458} 504}
459 505
460static inline int xfs_sb_version_hasmorebits(xfs_sb_t *sbp) 506static inline int xfs_sb_version_hasmorebits(xfs_sb_t *sbp)
461{ 507{
462 return XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_4 && 508 return (XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_5) ||
463 (sbp->sb_versionnum & XFS_SB_VERSION_MOREBITSBIT); 509 (XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_4 &&
510 (sbp->sb_versionnum & XFS_SB_VERSION_MOREBITSBIT));
464} 511}
465 512
466/* 513/*
@@ -475,14 +522,16 @@ static inline int xfs_sb_version_hasmorebits(xfs_sb_t *sbp)
475 522
476static inline int xfs_sb_version_haslazysbcount(xfs_sb_t *sbp) 523static inline int xfs_sb_version_haslazysbcount(xfs_sb_t *sbp)
477{ 524{
478 return xfs_sb_version_hasmorebits(sbp) && 525 return (XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_5) ||
479 (sbp->sb_features2 & XFS_SB_VERSION2_LAZYSBCOUNTBIT); 526 (xfs_sb_version_hasmorebits(sbp) &&
527 (sbp->sb_features2 & XFS_SB_VERSION2_LAZYSBCOUNTBIT));
480} 528}
481 529
482static inline int xfs_sb_version_hasattr2(xfs_sb_t *sbp) 530static inline int xfs_sb_version_hasattr2(xfs_sb_t *sbp)
483{ 531{
484 return xfs_sb_version_hasmorebits(sbp) && 532 return (XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_5) ||
485 (sbp->sb_features2 & XFS_SB_VERSION2_ATTR2BIT); 533 (xfs_sb_version_hasmorebits(sbp) &&
534 (sbp->sb_features2 & XFS_SB_VERSION2_ATTR2BIT));
486} 535}
487 536
488static inline void xfs_sb_version_addattr2(xfs_sb_t *sbp) 537static inline void xfs_sb_version_addattr2(xfs_sb_t *sbp)
@@ -500,14 +549,73 @@ static inline void xfs_sb_version_removeattr2(xfs_sb_t *sbp)
500 549
501static inline int xfs_sb_version_hasprojid32bit(xfs_sb_t *sbp) 550static inline int xfs_sb_version_hasprojid32bit(xfs_sb_t *sbp)
502{ 551{
503 return xfs_sb_version_hasmorebits(sbp) && 552 return (XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_5) ||
504 (sbp->sb_features2 & XFS_SB_VERSION2_PROJID32BIT); 553 (xfs_sb_version_hasmorebits(sbp) &&
554 (sbp->sb_features2 & XFS_SB_VERSION2_PROJID32BIT));
505} 555}
506 556
507static inline int xfs_sb_version_hascrc(xfs_sb_t *sbp) 557static inline int xfs_sb_version_hascrc(xfs_sb_t *sbp)
508{ 558{
509 return (xfs_sb_version_hasmorebits(sbp) && 559 return XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_5;
510 (sbp->sb_features2 & XFS_SB_VERSION2_CRCBIT)); 560}
561
562
563/*
564 * Extended v5 superblock feature masks. These are to be used for new v5
565 * superblock features only.
566 *
567 * Compat features are new features that old kernels will not notice or affect
568 * and so can mount read-write without issues.
569 *
570 * RO-Compat (read only) are features that old kernels can read but will break
571 * if they write. Hence only read-only mounts of such filesystems are allowed on
572 * kernels that don't support the feature bit.
573 *
574 * InCompat features are features which old kernels will not understand and so
575 * must not mount.
576 *
577 * Log-InCompat features are for changes to log formats or new transactions that
578 * can't be replayed on older kernels. The fields are set when the filesystem is
579 * mounted, and a clean unmount clears the fields.
580 */
581#define XFS_SB_FEAT_COMPAT_ALL 0
582#define XFS_SB_FEAT_COMPAT_UNKNOWN ~XFS_SB_FEAT_COMPAT_ALL
583static inline bool
584xfs_sb_has_compat_feature(
585 struct xfs_sb *sbp,
586 __uint32_t feature)
587{
588 return (sbp->sb_features_compat & feature) != 0;
589}
590
591#define XFS_SB_FEAT_RO_COMPAT_ALL 0
592#define XFS_SB_FEAT_RO_COMPAT_UNKNOWN ~XFS_SB_FEAT_RO_COMPAT_ALL
593static inline bool
594xfs_sb_has_ro_compat_feature(
595 struct xfs_sb *sbp,
596 __uint32_t feature)
597{
598 return (sbp->sb_features_ro_compat & feature) != 0;
599}
600
601#define XFS_SB_FEAT_INCOMPAT_ALL 0
602#define XFS_SB_FEAT_INCOMPAT_UNKNOWN ~XFS_SB_FEAT_INCOMPAT_ALL
603static inline bool
604xfs_sb_has_incompat_feature(
605 struct xfs_sb *sbp,
606 __uint32_t feature)
607{
608 return (sbp->sb_features_incompat & feature) != 0;
609}
610
611#define XFS_SB_FEAT_INCOMPAT_LOG_ALL 0
612#define XFS_SB_FEAT_INCOMPAT_LOG_UNKNOWN ~XFS_SB_FEAT_INCOMPAT_LOG_ALL
613static inline bool
614xfs_sb_has_incompat_log_feature(
615 struct xfs_sb *sbp,
616 __uint32_t feature)
617{
618 return (sbp->sb_features_log_incompat & feature) != 0;
511} 619}
512 620
513/* 621/*