30 #define XFS_SB_MAGIC 0x58465342
31 #define XFS_SB_VERSION_1 1
32 #define XFS_SB_VERSION_2 2
33 #define XFS_SB_VERSION_3 3
34 #define XFS_SB_VERSION_4 4
35 #define XFS_SB_VERSION_NUMBITS 0x000f
36 #define XFS_SB_VERSION_ALLFBITS 0xfff0
37 #define XFS_SB_VERSION_SASHFBITS 0xf000
38 #define XFS_SB_VERSION_REALFBITS 0x0ff0
39 #define XFS_SB_VERSION_ATTRBIT 0x0010
40 #define XFS_SB_VERSION_NLINKBIT 0x0020
41 #define XFS_SB_VERSION_QUOTABIT 0x0040
42 #define XFS_SB_VERSION_ALIGNBIT 0x0080
43 #define XFS_SB_VERSION_DALIGNBIT 0x0100
44 #define XFS_SB_VERSION_SHAREDBIT 0x0200
45 #define XFS_SB_VERSION_LOGV2BIT 0x0400
46 #define XFS_SB_VERSION_SECTORBIT 0x0800
47 #define XFS_SB_VERSION_EXTFLGBIT 0x1000
48 #define XFS_SB_VERSION_DIRV2BIT 0x2000
49 #define XFS_SB_VERSION_BORGBIT 0x4000
50 #define XFS_SB_VERSION_MOREBITSBIT 0x8000
51 #define XFS_SB_VERSION_OKSASHFBITS \
52 (XFS_SB_VERSION_EXTFLGBIT | \
53 XFS_SB_VERSION_DIRV2BIT | \
54 XFS_SB_VERSION_BORGBIT)
55 #define XFS_SB_VERSION_OKREALFBITS \
56 (XFS_SB_VERSION_ATTRBIT | \
57 XFS_SB_VERSION_NLINKBIT | \
58 XFS_SB_VERSION_QUOTABIT | \
59 XFS_SB_VERSION_ALIGNBIT | \
60 XFS_SB_VERSION_DALIGNBIT | \
61 XFS_SB_VERSION_SHAREDBIT | \
62 XFS_SB_VERSION_LOGV2BIT | \
63 XFS_SB_VERSION_SECTORBIT | \
64 XFS_SB_VERSION_MOREBITSBIT)
65 #define XFS_SB_VERSION_OKREALBITS \
66 (XFS_SB_VERSION_NUMBITS | \
67 XFS_SB_VERSION_OKREALFBITS | \
68 XFS_SB_VERSION_OKSASHFBITS)
77 #define XFS_SB_VERSION2_REALFBITS 0x00ffffff
78 #define XFS_SB_VERSION2_RESERVED1BIT 0x00000001
79 #define XFS_SB_VERSION2_LAZYSBCOUNTBIT 0x00000002
80 #define XFS_SB_VERSION2_RESERVED4BIT 0x00000004
81 #define XFS_SB_VERSION2_ATTR2BIT 0x00000008
82 #define XFS_SB_VERSION2_PARENTBIT 0x00000010
83 #define XFS_SB_VERSION2_PROJID32BIT 0x00000080
85 #define XFS_SB_VERSION2_OKREALFBITS \
86 (XFS_SB_VERSION2_LAZYSBCOUNTBIT | \
87 XFS_SB_VERSION2_ATTR2BIT | \
88 XFS_SB_VERSION2_PROJID32BIT)
89 #define XFS_SB_VERSION2_OKSASHFBITS \
91 #define XFS_SB_VERSION2_OKREALBITS \
92 (XFS_SB_VERSION2_OKREALFBITS | \
93 XFS_SB_VERSION2_OKSASHFBITS )
260 #define XFS_SB_MVAL(x) (1LL << XFS_SBS_ ## x)
261 #define XFS_SB_UUID XFS_SB_MVAL(UUID)
262 #define XFS_SB_FNAME XFS_SB_MVAL(FNAME)
263 #define XFS_SB_ROOTINO XFS_SB_MVAL(ROOTINO)
264 #define XFS_SB_RBMINO XFS_SB_MVAL(RBMINO)
265 #define XFS_SB_RSUMINO XFS_SB_MVAL(RSUMINO)
266 #define XFS_SB_VERSIONNUM XFS_SB_MVAL(VERSIONNUM)
267 #define XFS_SB_UQUOTINO XFS_SB_MVAL(UQUOTINO)
268 #define XFS_SB_GQUOTINO XFS_SB_MVAL(GQUOTINO)
269 #define XFS_SB_QFLAGS XFS_SB_MVAL(QFLAGS)
270 #define XFS_SB_SHARED_VN XFS_SB_MVAL(SHARED_VN)
271 #define XFS_SB_UNIT XFS_SB_MVAL(UNIT)
272 #define XFS_SB_WIDTH XFS_SB_MVAL(WIDTH)
273 #define XFS_SB_ICOUNT XFS_SB_MVAL(ICOUNT)
274 #define XFS_SB_IFREE XFS_SB_MVAL(IFREE)
275 #define XFS_SB_FDBLOCKS XFS_SB_MVAL(FDBLOCKS)
276 #define XFS_SB_FEATURES2 XFS_SB_MVAL(FEATURES2)
277 #define XFS_SB_BAD_FEATURES2 XFS_SB_MVAL(BAD_FEATURES2)
278 #define XFS_SB_NUM_BITS ((int)XFS_SBS_FIELDCOUNT)
279 #define XFS_SB_ALL_BITS ((1LL << XFS_SB_NUM_BITS) - 1)
280 #define XFS_SB_MOD_BITS \
281 (XFS_SB_UUID | XFS_SB_ROOTINO | XFS_SB_RBMINO | XFS_SB_RSUMINO | \
282 XFS_SB_VERSIONNUM | XFS_SB_UQUOTINO | XFS_SB_GQUOTINO | \
283 XFS_SB_QFLAGS | XFS_SB_SHARED_VN | XFS_SB_UNIT | XFS_SB_WIDTH | \
284 XFS_SB_ICOUNT | XFS_SB_IFREE | XFS_SB_FDBLOCKS | XFS_SB_FEATURES2 | \
285 XFS_SB_BAD_FEATURES2)
292 #define XFS_SBF_NOFLAGS 0x00
293 #define XFS_SBF_READONLY 0x01
298 #define XFS_SB_MAX_SHARED_VN 0
300 #define XFS_SB_VERSION_NUM(sbp) ((sbp)->sb_versionnum & XFS_SB_VERSION_NUMBITS)
302 static inline int xfs_sb_good_version(
xfs_sb_t *sbp)
335 static inline int xfs_sb_has_mismatched_features2(
xfs_sb_t *sbp)
340 static inline unsigned xfs_sb_version_tonew(
unsigned v)
352 static inline unsigned xfs_sb_version_toold(
unsigned v)
363 static inline int xfs_sb_version_hasattr(
xfs_sb_t *sbp)
371 static inline void xfs_sb_version_addattr(
xfs_sb_t *sbp)
381 static inline int xfs_sb_version_hasnlink(
xfs_sb_t *sbp)
388 static inline void xfs_sb_version_addnlink(
xfs_sb_t *sbp)
396 static inline int xfs_sb_version_hasquota(
xfs_sb_t *sbp)
402 static inline void xfs_sb_version_addquota(
xfs_sb_t *sbp)
411 static inline int xfs_sb_version_hasalign(
xfs_sb_t *sbp)
417 static inline int xfs_sb_version_hasdalign(
xfs_sb_t *sbp)
423 static inline int xfs_sb_version_hasshared(
xfs_sb_t *sbp)
429 static inline int xfs_sb_version_hasdirv2(
xfs_sb_t *sbp)
435 static inline int xfs_sb_version_haslogv2(
xfs_sb_t *sbp)
441 static inline int xfs_sb_version_hasextflgbit(
xfs_sb_t *sbp)
447 static inline int xfs_sb_version_hassector(
xfs_sb_t *sbp)
453 static inline int xfs_sb_version_hasasciici(
xfs_sb_t *sbp)
459 static inline int xfs_sb_version_hasmorebits(
xfs_sb_t *sbp)
475 static inline int xfs_sb_version_haslazysbcount(
xfs_sb_t *sbp)
477 return xfs_sb_version_hasmorebits(sbp) &&
481 static inline int xfs_sb_version_hasattr2(
xfs_sb_t *sbp)
483 return xfs_sb_version_hasmorebits(sbp) &&
487 static inline void xfs_sb_version_addattr2(
xfs_sb_t *sbp)
493 static inline void xfs_sb_version_removeattr2(
xfs_sb_t *sbp)
500 static inline int xfs_sb_version_hasprojid32bit(
xfs_sb_t *sbp)
502 return xfs_sb_version_hasmorebits(sbp) &&
510 #define XFS_SB_DADDR ((xfs_daddr_t)0)
511 #define XFS_SB_BLOCK(mp) XFS_HDR_BLOCK(mp, XFS_SB_DADDR)
512 #define XFS_BUF_TO_SBP(bp) ((xfs_dsb_t *)((bp)->b_addr))
514 #define XFS_HDR_BLOCK(mp,d) ((xfs_agblock_t)XFS_BB_TO_FSBT(mp,d))
515 #define XFS_DADDR_TO_FSB(mp,d) XFS_AGB_TO_FSB(mp, \
516 xfs_daddr_to_agno(mp,d), xfs_daddr_to_agbno(mp,d))
517 #define XFS_FSB_TO_DADDR(mp,fsbno) XFS_AGB_TO_DADDR(mp, \
518 XFS_FSB_TO_AGNO(mp,fsbno), XFS_FSB_TO_AGBNO(mp,fsbno))
523 #define XFS_FSS_TO_BB(mp,sec) ((sec) << (mp)->m_sectbb_log)
528 #define XFS_FSB_TO_BB(mp,fsbno) ((fsbno) << (mp)->m_blkbb_log)
529 #define XFS_BB_TO_FSB(mp,bb) \
530 (((bb) + (XFS_FSB_TO_BB(mp,1) - 1)) >> (mp)->m_blkbb_log)
531 #define XFS_BB_TO_FSBT(mp,bb) ((bb) >> (mp)->m_blkbb_log)
536 #define XFS_FSB_TO_B(mp,fsbno) ((xfs_fsize_t)(fsbno) << (mp)->m_sb.sb_blocklog)
537 #define XFS_B_TO_FSB(mp,b) \
538 ((((__uint64_t)(b)) + (mp)->m_blockmask) >> (mp)->m_sb.sb_blocklog)
539 #define XFS_B_TO_FSBT(mp,b) (((__uint64_t)(b)) >> (mp)->m_sb.sb_blocklog)
540 #define XFS_B_FSB_OFFSET(mp,b) ((b) & (mp)->m_blockmask)