2 * Copyright (c) 2000-2005 Silicon Graphics, Inc.
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License as
7 * published by the Free Software Foundation.
9 * This program is distributed in the hope that it would be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write the Free Software Foundation,
16 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
23 * Fits into a sector-sized buffer at address 0 of each allocation group.
24 * Only the first of these is ever updated except during growfs.
30 #define XFS_SB_MAGIC 0x58465342 /* 'XFSB' */
31 #define XFS_SB_VERSION_1 1 /* 5.3, 6.0.1, 6.1 */
32 #define XFS_SB_VERSION_2 2 /* 6.2 - attributes */
33 #define XFS_SB_VERSION_3 3 /* 6.2 - new inode version */
34 #define XFS_SB_VERSION_4 4 /* 6.2+ - bitmask version */
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 /* ASCII only case-insens. */
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)
71 * There are two words to hold XFS "feature" bits: the original
72 * word, sb_versionnum, and sb_features2. Whenever a bit is set in
73 * sb_features2, the feature bit XFS_SB_VERSION_MOREBITSBIT must be set.
75 * These defines represent bits in sb_features2.
77 #define XFS_SB_VERSION2_REALFBITS 0x00ffffff /* Mask: features */
78 #define XFS_SB_VERSION2_RESERVED1BIT 0x00000001
79 #define XFS_SB_VERSION2_LAZYSBCOUNTBIT 0x00000002 /* Superblk counters */
80 #define XFS_SB_VERSION2_RESERVED4BIT 0x00000004
81 #define XFS_SB_VERSION2_ATTR2BIT 0x00000008 /* Inline attr rework */
82 #define XFS_SB_VERSION2_PARENTBIT 0x00000010 /* parent pointers */
84 #define XFS_SB_VERSION2_OKREALFBITS \
85 (XFS_SB_VERSION2_LAZYSBCOUNTBIT | \
86 XFS_SB_VERSION2_ATTR2BIT)
87 #define XFS_SB_VERSION2_OKSASHFBITS \
89 #define XFS_SB_VERSION2_OKREALBITS \
90 (XFS_SB_VERSION2_OKREALFBITS | \
91 XFS_SB_VERSION2_OKSASHFBITS )
94 * Superblock - in core version. Must match the ondisk version below.
95 * Must be padded to 64 bit alignment.
97 typedef struct xfs_sb {
98 __uint32_t sb_magicnum; /* magic number == XFS_SB_MAGIC */
99 __uint32_t sb_blocksize; /* logical block size, bytes */
100 xfs_drfsbno_t sb_dblocks; /* number of data blocks */
101 xfs_drfsbno_t sb_rblocks; /* number of realtime blocks */
102 xfs_drtbno_t sb_rextents; /* number of realtime extents */
103 uuid_t sb_uuid; /* file system unique id */
104 xfs_dfsbno_t sb_logstart; /* starting block of log if internal */
105 xfs_ino_t sb_rootino; /* root inode number */
106 xfs_ino_t sb_rbmino; /* bitmap inode for realtime extents */
107 xfs_ino_t sb_rsumino; /* summary inode for rt bitmap */
108 xfs_agblock_t sb_rextsize; /* realtime extent size, blocks */
109 xfs_agblock_t sb_agblocks; /* size of an allocation group */
110 xfs_agnumber_t sb_agcount; /* number of allocation groups */
111 xfs_extlen_t sb_rbmblocks; /* number of rt bitmap blocks */
112 xfs_extlen_t sb_logblocks; /* number of log blocks */
113 __uint16_t sb_versionnum; /* header version == XFS_SB_VERSION */
114 __uint16_t sb_sectsize; /* volume sector size, bytes */
115 __uint16_t sb_inodesize; /* inode size, bytes */
116 __uint16_t sb_inopblock; /* inodes per block */
117 char sb_fname[12]; /* file system name */
118 __uint8_t sb_blocklog; /* log2 of sb_blocksize */
119 __uint8_t sb_sectlog; /* log2 of sb_sectsize */
120 __uint8_t sb_inodelog; /* log2 of sb_inodesize */
121 __uint8_t sb_inopblog; /* log2 of sb_inopblock */
122 __uint8_t sb_agblklog; /* log2 of sb_agblocks (rounded up) */
123 __uint8_t sb_rextslog; /* log2 of sb_rextents */
124 __uint8_t sb_inprogress; /* mkfs is in progress, don't mount */
125 __uint8_t sb_imax_pct; /* max % of fs for inode space */
128 * These fields must remain contiguous. If you really
129 * want to change their layout, make sure you fix the
130 * code in xfs_trans_apply_sb_deltas().
132 __uint64_t sb_icount; /* allocated inodes */
133 __uint64_t sb_ifree; /* free inodes */
134 __uint64_t sb_fdblocks; /* free data blocks */
135 __uint64_t sb_frextents; /* free realtime extents */
137 * End contiguous fields.
139 xfs_ino_t sb_uquotino; /* user quota inode */
140 xfs_ino_t sb_gquotino; /* group quota inode */
141 __uint16_t sb_qflags; /* quota flags */
142 __uint8_t sb_flags; /* misc. flags */
143 __uint8_t sb_shared_vn; /* shared version number */
144 xfs_extlen_t sb_inoalignmt; /* inode chunk alignment, fsblocks */
145 __uint32_t sb_unit; /* stripe or raid unit */
146 __uint32_t sb_width; /* stripe or raid width */
147 __uint8_t sb_dirblklog; /* log2 of dir block size (fsbs) */
148 __uint8_t sb_logsectlog; /* log2 of the log sector size */
149 __uint16_t sb_logsectsize; /* sector size for the log, bytes */
150 __uint32_t sb_logsunit; /* stripe unit size for the log */
151 __uint32_t sb_features2; /* additional feature bits */
154 * bad features2 field as a result of failing to pad the sb
155 * structure to 64 bits. Some machines will be using this field
156 * for features2 bits. Easiest just to mark it bad and not use
157 * it for anything else.
159 __uint32_t sb_bad_features2;
161 /* must be padded to 64 bit alignment */
165 * Superblock - on disk version. Must match the in core version above.
166 * Must be padded to 64 bit alignment.
168 typedef struct xfs_dsb {
169 __be32 sb_magicnum; /* magic number == XFS_SB_MAGIC */
170 __be32 sb_blocksize; /* logical block size, bytes */
171 __be64 sb_dblocks; /* number of data blocks */
172 __be64 sb_rblocks; /* number of realtime blocks */
173 __be64 sb_rextents; /* number of realtime extents */
174 uuid_t sb_uuid; /* file system unique id */
175 __be64 sb_logstart; /* starting block of log if internal */
176 __be64 sb_rootino; /* root inode number */
177 __be64 sb_rbmino; /* bitmap inode for realtime extents */
178 __be64 sb_rsumino; /* summary inode for rt bitmap */
179 __be32 sb_rextsize; /* realtime extent size, blocks */
180 __be32 sb_agblocks; /* size of an allocation group */
181 __be32 sb_agcount; /* number of allocation groups */
182 __be32 sb_rbmblocks; /* number of rt bitmap blocks */
183 __be32 sb_logblocks; /* number of log blocks */
184 __be16 sb_versionnum; /* header version == XFS_SB_VERSION */
185 __be16 sb_sectsize; /* volume sector size, bytes */
186 __be16 sb_inodesize; /* inode size, bytes */
187 __be16 sb_inopblock; /* inodes per block */
188 char sb_fname[12]; /* file system name */
189 __u8 sb_blocklog; /* log2 of sb_blocksize */
190 __u8 sb_sectlog; /* log2 of sb_sectsize */
191 __u8 sb_inodelog; /* log2 of sb_inodesize */
192 __u8 sb_inopblog; /* log2 of sb_inopblock */
193 __u8 sb_agblklog; /* log2 of sb_agblocks (rounded up) */
194 __u8 sb_rextslog; /* log2 of sb_rextents */
195 __u8 sb_inprogress; /* mkfs is in progress, don't mount */
196 __u8 sb_imax_pct; /* max % of fs for inode space */
199 * These fields must remain contiguous. If you really
200 * want to change their layout, make sure you fix the
201 * code in xfs_trans_apply_sb_deltas().
203 __be64 sb_icount; /* allocated inodes */
204 __be64 sb_ifree; /* free inodes */
205 __be64 sb_fdblocks; /* free data blocks */
206 __be64 sb_frextents; /* free realtime extents */
208 * End contiguous fields.
210 __be64 sb_uquotino; /* user quota inode */
211 __be64 sb_gquotino; /* group quota inode */
212 __be16 sb_qflags; /* quota flags */
213 __u8 sb_flags; /* misc. flags */
214 __u8 sb_shared_vn; /* shared version number */
215 __be32 sb_inoalignmt; /* inode chunk alignment, fsblocks */
216 __be32 sb_unit; /* stripe or raid unit */
217 __be32 sb_width; /* stripe or raid width */
218 __u8 sb_dirblklog; /* log2 of dir block size (fsbs) */
219 __u8 sb_logsectlog; /* log2 of the log sector size */
220 __be16 sb_logsectsize; /* sector size for the log, bytes */
221 __be32 sb_logsunit; /* stripe unit size for the log */
222 __be32 sb_features2; /* additional feature bits */
224 * bad features2 field as a result of failing to pad the sb
225 * structure to 64 bits. Some machines will be using this field
226 * for features2 bits. Easiest just to mark it bad and not use
227 * it for anything else.
229 __be32 sb_bad_features2;
231 /* must be padded to 64 bit alignment */
235 * Sequence number values for the fields.
238 XFS_SBS_MAGICNUM, XFS_SBS_BLOCKSIZE, XFS_SBS_DBLOCKS, XFS_SBS_RBLOCKS,
239 XFS_SBS_REXTENTS, XFS_SBS_UUID, XFS_SBS_LOGSTART, XFS_SBS_ROOTINO,
240 XFS_SBS_RBMINO, XFS_SBS_RSUMINO, XFS_SBS_REXTSIZE, XFS_SBS_AGBLOCKS,
241 XFS_SBS_AGCOUNT, XFS_SBS_RBMBLOCKS, XFS_SBS_LOGBLOCKS,
242 XFS_SBS_VERSIONNUM, XFS_SBS_SECTSIZE, XFS_SBS_INODESIZE,
243 XFS_SBS_INOPBLOCK, XFS_SBS_FNAME, XFS_SBS_BLOCKLOG,
244 XFS_SBS_SECTLOG, XFS_SBS_INODELOG, XFS_SBS_INOPBLOG, XFS_SBS_AGBLKLOG,
245 XFS_SBS_REXTSLOG, XFS_SBS_INPROGRESS, XFS_SBS_IMAX_PCT, XFS_SBS_ICOUNT,
246 XFS_SBS_IFREE, XFS_SBS_FDBLOCKS, XFS_SBS_FREXTENTS, XFS_SBS_UQUOTINO,
247 XFS_SBS_GQUOTINO, XFS_SBS_QFLAGS, XFS_SBS_FLAGS, XFS_SBS_SHARED_VN,
248 XFS_SBS_INOALIGNMT, XFS_SBS_UNIT, XFS_SBS_WIDTH, XFS_SBS_DIRBLKLOG,
249 XFS_SBS_LOGSECTLOG, XFS_SBS_LOGSECTSIZE, XFS_SBS_LOGSUNIT,
250 XFS_SBS_FEATURES2, XFS_SBS_BAD_FEATURES2,
255 * Mask values, defined based on the xfs_sb_field_t values.
256 * Only define the ones we're using.
258 #define XFS_SB_MVAL(x) (1LL << XFS_SBS_ ## x)
259 #define XFS_SB_UUID XFS_SB_MVAL(UUID)
260 #define XFS_SB_FNAME XFS_SB_MVAL(FNAME)
261 #define XFS_SB_ROOTINO XFS_SB_MVAL(ROOTINO)
262 #define XFS_SB_RBMINO XFS_SB_MVAL(RBMINO)
263 #define XFS_SB_RSUMINO XFS_SB_MVAL(RSUMINO)
264 #define XFS_SB_VERSIONNUM XFS_SB_MVAL(VERSIONNUM)
265 #define XFS_SB_UQUOTINO XFS_SB_MVAL(UQUOTINO)
266 #define XFS_SB_GQUOTINO XFS_SB_MVAL(GQUOTINO)
267 #define XFS_SB_QFLAGS XFS_SB_MVAL(QFLAGS)
268 #define XFS_SB_SHARED_VN XFS_SB_MVAL(SHARED_VN)
269 #define XFS_SB_UNIT XFS_SB_MVAL(UNIT)
270 #define XFS_SB_WIDTH XFS_SB_MVAL(WIDTH)
271 #define XFS_SB_ICOUNT XFS_SB_MVAL(ICOUNT)
272 #define XFS_SB_IFREE XFS_SB_MVAL(IFREE)
273 #define XFS_SB_FDBLOCKS XFS_SB_MVAL(FDBLOCKS)
274 #define XFS_SB_FEATURES2 XFS_SB_MVAL(FEATURES2)
275 #define XFS_SB_BAD_FEATURES2 XFS_SB_MVAL(BAD_FEATURES2)
276 #define XFS_SB_NUM_BITS ((int)XFS_SBS_FIELDCOUNT)
277 #define XFS_SB_ALL_BITS ((1LL << XFS_SB_NUM_BITS) - 1)
278 #define XFS_SB_MOD_BITS \
279 (XFS_SB_UUID | XFS_SB_ROOTINO | XFS_SB_RBMINO | XFS_SB_RSUMINO | \
280 XFS_SB_VERSIONNUM | XFS_SB_UQUOTINO | XFS_SB_GQUOTINO | \
281 XFS_SB_QFLAGS | XFS_SB_SHARED_VN | XFS_SB_UNIT | XFS_SB_WIDTH | \
282 XFS_SB_ICOUNT | XFS_SB_IFREE | XFS_SB_FDBLOCKS | XFS_SB_FEATURES2 | \
283 XFS_SB_BAD_FEATURES2)
287 * Misc. Flags - warning - these will be cleared by xfs_repair unless
288 * a feature bit is set when the flag is used.
290 #define XFS_SBF_NOFLAGS 0x00 /* no flags set */
291 #define XFS_SBF_READONLY 0x01 /* only read-only mounts allowed */
294 * define max. shared version we can interoperate with
296 #define XFS_SB_MAX_SHARED_VN 0
298 #define XFS_SB_VERSION_NUM(sbp) ((sbp)->sb_versionnum & XFS_SB_VERSION_NUMBITS)
300 static inline int xfs_sb_good_version(xfs_sb_t *sbp)
302 /* We always support version 1-3 */
303 if (sbp->sb_versionnum >= XFS_SB_VERSION_1 &&
304 sbp->sb_versionnum <= XFS_SB_VERSION_3)
307 /* We support version 4 if all feature bits are supported */
308 if (XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_4) {
309 if ((sbp->sb_versionnum & ~XFS_SB_VERSION_OKREALBITS) ||
310 ((sbp->sb_versionnum & XFS_SB_VERSION_MOREBITSBIT) &&
311 (sbp->sb_features2 & ~XFS_SB_VERSION2_OKREALBITS)))
315 if (sbp->sb_shared_vn > XFS_SB_MAX_SHARED_VN)
318 if ((sbp->sb_versionnum & XFS_SB_VERSION_SHAREDBIT) &&
319 sbp->sb_shared_vn > XFS_SB_MAX_SHARED_VN)
330 * Detect a mismatched features2 field. Older kernels read/wrote
331 * this into the wrong slot, so to be safe we keep them in sync.
333 static inline int xfs_sb_has_mismatched_features2(xfs_sb_t *sbp)
335 return (sbp->sb_bad_features2 != sbp->sb_features2);
338 static inline unsigned xfs_sb_version_tonew(unsigned v)
340 if (v == XFS_SB_VERSION_1)
341 return XFS_SB_VERSION_4;
343 if (v == XFS_SB_VERSION_2)
344 return XFS_SB_VERSION_4 | XFS_SB_VERSION_ATTRBIT;
346 return XFS_SB_VERSION_4 | XFS_SB_VERSION_ATTRBIT |
347 XFS_SB_VERSION_NLINKBIT;
350 static inline unsigned xfs_sb_version_toold(unsigned v)
352 if (v & (XFS_SB_VERSION_QUOTABIT | XFS_SB_VERSION_ALIGNBIT))
354 if (v & XFS_SB_VERSION_NLINKBIT)
355 return XFS_SB_VERSION_3;
356 if (v & XFS_SB_VERSION_ATTRBIT)
357 return XFS_SB_VERSION_2;
358 return XFS_SB_VERSION_1;
361 static inline int xfs_sb_version_hasattr(xfs_sb_t *sbp)
363 return sbp->sb_versionnum == XFS_SB_VERSION_2 ||
364 sbp->sb_versionnum == XFS_SB_VERSION_3 ||
365 (XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_4 &&
366 (sbp->sb_versionnum & XFS_SB_VERSION_ATTRBIT));
369 static inline void xfs_sb_version_addattr(xfs_sb_t *sbp)
371 if (sbp->sb_versionnum == XFS_SB_VERSION_1)
372 sbp->sb_versionnum = XFS_SB_VERSION_2;
373 else if (XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_4)
374 sbp->sb_versionnum |= XFS_SB_VERSION_ATTRBIT;
376 sbp->sb_versionnum = XFS_SB_VERSION_4 | XFS_SB_VERSION_ATTRBIT;
379 static inline int xfs_sb_version_hasnlink(xfs_sb_t *sbp)
381 return sbp->sb_versionnum == XFS_SB_VERSION_3 ||
382 (XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_4 &&
383 (sbp->sb_versionnum & XFS_SB_VERSION_NLINKBIT));
386 static inline void xfs_sb_version_addnlink(xfs_sb_t *sbp)
388 if (sbp->sb_versionnum <= XFS_SB_VERSION_2)
389 sbp->sb_versionnum = XFS_SB_VERSION_3;
391 sbp->sb_versionnum |= XFS_SB_VERSION_NLINKBIT;
394 static inline int xfs_sb_version_hasquota(xfs_sb_t *sbp)
396 return XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_4 &&
397 (sbp->sb_versionnum & XFS_SB_VERSION_QUOTABIT);
400 static inline void xfs_sb_version_addquota(xfs_sb_t *sbp)
402 if (XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_4)
403 sbp->sb_versionnum |= XFS_SB_VERSION_QUOTABIT;
405 sbp->sb_versionnum = xfs_sb_version_tonew(sbp->sb_versionnum) |
406 XFS_SB_VERSION_QUOTABIT;
409 static inline int xfs_sb_version_hasalign(xfs_sb_t *sbp)
411 return XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_4 &&
412 (sbp->sb_versionnum & XFS_SB_VERSION_ALIGNBIT);
415 static inline int xfs_sb_version_hasdalign(xfs_sb_t *sbp)
417 return XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_4 &&
418 (sbp->sb_versionnum & XFS_SB_VERSION_DALIGNBIT);
421 static inline int xfs_sb_version_hasshared(xfs_sb_t *sbp)
423 return XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_4 &&
424 (sbp->sb_versionnum & XFS_SB_VERSION_SHAREDBIT);
427 static inline int xfs_sb_version_hasdirv2(xfs_sb_t *sbp)
429 return XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_4 &&
430 (sbp->sb_versionnum & XFS_SB_VERSION_DIRV2BIT);
433 static inline int xfs_sb_version_haslogv2(xfs_sb_t *sbp)
435 return XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_4 &&
436 (sbp->sb_versionnum & XFS_SB_VERSION_LOGV2BIT);
439 static inline int xfs_sb_version_hasextflgbit(xfs_sb_t *sbp)
441 return XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_4 &&
442 (sbp->sb_versionnum & XFS_SB_VERSION_EXTFLGBIT);
445 static inline int xfs_sb_version_hassector(xfs_sb_t *sbp)
447 return XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_4 &&
448 (sbp->sb_versionnum & XFS_SB_VERSION_SECTORBIT);
451 static inline int xfs_sb_version_hasasciici(xfs_sb_t *sbp)
453 return XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_4 &&
454 (sbp->sb_versionnum & XFS_SB_VERSION_BORGBIT);
457 static inline int xfs_sb_version_hasmorebits(xfs_sb_t *sbp)
459 return XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_4 &&
460 (sbp->sb_versionnum & XFS_SB_VERSION_MOREBITSBIT);
464 * sb_features2 bit version macros.
466 * For example, for a bit defined as XFS_SB_VERSION2_FUNBIT, has a macro:
468 * SB_VERSION_HASFUNBIT(xfs_sb_t *sbp)
469 * ((xfs_sb_version_hasmorebits(sbp) &&
470 * ((sbp)->sb_features2 & XFS_SB_VERSION2_FUNBIT)
473 static inline int xfs_sb_version_haslazysbcount(xfs_sb_t *sbp)
475 return xfs_sb_version_hasmorebits(sbp) &&
476 (sbp->sb_features2 & XFS_SB_VERSION2_LAZYSBCOUNTBIT);
479 static inline int xfs_sb_version_hasattr2(xfs_sb_t *sbp)
481 return xfs_sb_version_hasmorebits(sbp) &&
482 (sbp->sb_features2 & XFS_SB_VERSION2_ATTR2BIT);
485 static inline void xfs_sb_version_addattr2(xfs_sb_t *sbp)
487 sbp->sb_versionnum |= XFS_SB_VERSION_MOREBITSBIT;
488 sbp->sb_features2 |= XFS_SB_VERSION2_ATTR2BIT;
491 static inline void xfs_sb_version_removeattr2(xfs_sb_t *sbp)
493 sbp->sb_features2 &= ~XFS_SB_VERSION2_ATTR2BIT;
494 if (!sbp->sb_features2)
495 sbp->sb_versionnum &= ~XFS_SB_VERSION_MOREBITSBIT;
499 * end of superblock version macros
502 #define XFS_SB_DADDR ((xfs_daddr_t)0) /* daddr in filesystem/ag */
503 #define XFS_SB_BLOCK(mp) XFS_HDR_BLOCK(mp, XFS_SB_DADDR)
504 #define XFS_BUF_TO_SBP(bp) ((xfs_dsb_t *)XFS_BUF_PTR(bp))
506 #define XFS_HDR_BLOCK(mp,d) ((xfs_agblock_t)XFS_BB_TO_FSBT(mp,d))
507 #define XFS_DADDR_TO_FSB(mp,d) XFS_AGB_TO_FSB(mp, \
508 xfs_daddr_to_agno(mp,d), xfs_daddr_to_agbno(mp,d))
509 #define XFS_FSB_TO_DADDR(mp,fsbno) XFS_AGB_TO_DADDR(mp, \
510 XFS_FSB_TO_AGNO(mp,fsbno), XFS_FSB_TO_AGBNO(mp,fsbno))
513 * File system sector to basic block conversions.
515 #define XFS_FSS_TO_BB(mp,sec) ((sec) << (mp)->m_sectbb_log)
518 * File system block to basic block conversions.
520 #define XFS_FSB_TO_BB(mp,fsbno) ((fsbno) << (mp)->m_blkbb_log)
521 #define XFS_BB_TO_FSB(mp,bb) \
522 (((bb) + (XFS_FSB_TO_BB(mp,1) - 1)) >> (mp)->m_blkbb_log)
523 #define XFS_BB_TO_FSBT(mp,bb) ((bb) >> (mp)->m_blkbb_log)
524 #define XFS_BB_FSB_OFFSET(mp,bb) ((bb) & ((mp)->m_bsize - 1))
527 * File system block to byte conversions.
529 #define XFS_FSB_TO_B(mp,fsbno) ((xfs_fsize_t)(fsbno) << (mp)->m_sb.sb_blocklog)
530 #define XFS_B_TO_FSB(mp,b) \
531 ((((__uint64_t)(b)) + (mp)->m_blockmask) >> (mp)->m_sb.sb_blocklog)
532 #define XFS_B_TO_FSBT(mp,b) (((__uint64_t)(b)) >> (mp)->m_sb.sb_blocklog)
533 #define XFS_B_FSB_OFFSET(mp,b) ((b) & (mp)->m_blockmask)
535 #endif /* __XFS_SB_H__ */