[PATCH] debugfs inode leak
[linux/fpc-iii.git] / fs / xfs / xfs_sb.h
blobbf168a91ddb83ffd4e91f7456fe83fd5bf937e8f
1 /*
2 * Copyright (c) 2000-2005 Silicon Graphics, Inc.
3 * All Rights Reserved.
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
18 #ifndef __XFS_SB_H__
19 #define __XFS_SB_H__
22 * Super block
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.
27 struct xfs_buf;
28 struct xfs_mount;
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_MOREBITSBIT 0x8000
50 #define XFS_SB_VERSION_OKSASHFBITS \
51 (XFS_SB_VERSION_EXTFLGBIT | \
52 XFS_SB_VERSION_DIRV2BIT)
53 #define XFS_SB_VERSION_OKREALFBITS \
54 (XFS_SB_VERSION_ATTRBIT | \
55 XFS_SB_VERSION_NLINKBIT | \
56 XFS_SB_VERSION_QUOTABIT | \
57 XFS_SB_VERSION_ALIGNBIT | \
58 XFS_SB_VERSION_DALIGNBIT | \
59 XFS_SB_VERSION_SHAREDBIT | \
60 XFS_SB_VERSION_LOGV2BIT | \
61 XFS_SB_VERSION_SECTORBIT | \
62 XFS_SB_VERSION_MOREBITSBIT)
63 #define XFS_SB_VERSION_OKSASHBITS \
64 (XFS_SB_VERSION_NUMBITS | \
65 XFS_SB_VERSION_REALFBITS | \
66 XFS_SB_VERSION_OKSASHFBITS)
67 #define XFS_SB_VERSION_OKREALBITS \
68 (XFS_SB_VERSION_NUMBITS | \
69 XFS_SB_VERSION_OKREALFBITS | \
70 XFS_SB_VERSION_OKSASHFBITS)
73 * There are two words to hold XFS "feature" bits: the original
74 * word, sb_versionnum, and sb_features2. Whenever a bit is set in
75 * sb_features2, the feature bit XFS_SB_VERSION_MOREBITSBIT must be set.
77 * These defines represent bits in sb_features2.
79 #define XFS_SB_VERSION2_REALFBITS 0x00ffffff /* Mask: features */
80 #define XFS_SB_VERSION2_RESERVED1BIT 0x00000001
81 #define XFS_SB_VERSION2_RESERVED2BIT 0x00000002
82 #define XFS_SB_VERSION2_RESERVED4BIT 0x00000004
83 #define XFS_SB_VERSION2_ATTR2BIT 0x00000008 /* Inline attr rework */
84 #define XFS_SB_VERSION2_SASHFBITS 0xff000000 /* Mask: features that
85 require changing
86 PROM and SASH */
88 #define XFS_SB_VERSION2_OKREALFBITS \
89 (XFS_SB_VERSION2_ATTR2BIT)
90 #define XFS_SB_VERSION2_OKSASHFBITS \
91 (0)
92 #define XFS_SB_VERSION2_OKREALBITS \
93 (XFS_SB_VERSION2_OKREALFBITS | \
94 XFS_SB_VERSION2_OKSASHFBITS )
96 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 */
126 /* statistics */
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 */
152 } xfs_sb_t;
155 * Sequence number values for the fields.
157 typedef enum {
158 XFS_SBS_MAGICNUM, XFS_SBS_BLOCKSIZE, XFS_SBS_DBLOCKS, XFS_SBS_RBLOCKS,
159 XFS_SBS_REXTENTS, XFS_SBS_UUID, XFS_SBS_LOGSTART, XFS_SBS_ROOTINO,
160 XFS_SBS_RBMINO, XFS_SBS_RSUMINO, XFS_SBS_REXTSIZE, XFS_SBS_AGBLOCKS,
161 XFS_SBS_AGCOUNT, XFS_SBS_RBMBLOCKS, XFS_SBS_LOGBLOCKS,
162 XFS_SBS_VERSIONNUM, XFS_SBS_SECTSIZE, XFS_SBS_INODESIZE,
163 XFS_SBS_INOPBLOCK, XFS_SBS_FNAME, XFS_SBS_BLOCKLOG,
164 XFS_SBS_SECTLOG, XFS_SBS_INODELOG, XFS_SBS_INOPBLOG, XFS_SBS_AGBLKLOG,
165 XFS_SBS_REXTSLOG, XFS_SBS_INPROGRESS, XFS_SBS_IMAX_PCT, XFS_SBS_ICOUNT,
166 XFS_SBS_IFREE, XFS_SBS_FDBLOCKS, XFS_SBS_FREXTENTS, XFS_SBS_UQUOTINO,
167 XFS_SBS_GQUOTINO, XFS_SBS_QFLAGS, XFS_SBS_FLAGS, XFS_SBS_SHARED_VN,
168 XFS_SBS_INOALIGNMT, XFS_SBS_UNIT, XFS_SBS_WIDTH, XFS_SBS_DIRBLKLOG,
169 XFS_SBS_LOGSECTLOG, XFS_SBS_LOGSECTSIZE, XFS_SBS_LOGSUNIT,
170 XFS_SBS_FEATURES2,
171 XFS_SBS_FIELDCOUNT
172 } xfs_sb_field_t;
175 * Mask values, defined based on the xfs_sb_field_t values.
176 * Only define the ones we're using.
178 #define XFS_SB_MVAL(x) (1LL << XFS_SBS_ ## x)
179 #define XFS_SB_UUID XFS_SB_MVAL(UUID)
180 #define XFS_SB_FNAME XFS_SB_MVAL(FNAME)
181 #define XFS_SB_ROOTINO XFS_SB_MVAL(ROOTINO)
182 #define XFS_SB_RBMINO XFS_SB_MVAL(RBMINO)
183 #define XFS_SB_RSUMINO XFS_SB_MVAL(RSUMINO)
184 #define XFS_SB_VERSIONNUM XFS_SB_MVAL(VERSIONNUM)
185 #define XFS_SB_UQUOTINO XFS_SB_MVAL(UQUOTINO)
186 #define XFS_SB_GQUOTINO XFS_SB_MVAL(GQUOTINO)
187 #define XFS_SB_QFLAGS XFS_SB_MVAL(QFLAGS)
188 #define XFS_SB_SHARED_VN XFS_SB_MVAL(SHARED_VN)
189 #define XFS_SB_UNIT XFS_SB_MVAL(UNIT)
190 #define XFS_SB_WIDTH XFS_SB_MVAL(WIDTH)
191 #define XFS_SB_FEATURES2 XFS_SB_MVAL(FEATURES2)
192 #define XFS_SB_NUM_BITS ((int)XFS_SBS_FIELDCOUNT)
193 #define XFS_SB_ALL_BITS ((1LL << XFS_SB_NUM_BITS) - 1)
194 #define XFS_SB_MOD_BITS \
195 (XFS_SB_UUID | XFS_SB_ROOTINO | XFS_SB_RBMINO | XFS_SB_RSUMINO | \
196 XFS_SB_VERSIONNUM | XFS_SB_UQUOTINO | XFS_SB_GQUOTINO | \
197 XFS_SB_QFLAGS | XFS_SB_SHARED_VN | XFS_SB_UNIT | XFS_SB_WIDTH | \
198 XFS_SB_FEATURES2)
202 * Misc. Flags - warning - these will be cleared by xfs_repair unless
203 * a feature bit is set when the flag is used.
205 #define XFS_SBF_NOFLAGS 0x00 /* no flags set */
206 #define XFS_SBF_READONLY 0x01 /* only read-only mounts allowed */
209 * define max. shared version we can interoperate with
211 #define XFS_SB_MAX_SHARED_VN 0
213 #define XFS_SB_VERSION_NUM(sbp) ((sbp)->sb_versionnum & XFS_SB_VERSION_NUMBITS)
215 #define XFS_SB_GOOD_VERSION(sbp) xfs_sb_good_version(sbp)
216 #ifdef __KERNEL__
217 static inline int xfs_sb_good_version(xfs_sb_t *sbp)
219 return (((sbp->sb_versionnum >= XFS_SB_VERSION_1) && \
220 (sbp->sb_versionnum <= XFS_SB_VERSION_3)) || \
221 ((XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_4) && \
222 !((sbp->sb_versionnum & ~XFS_SB_VERSION_OKREALBITS) || \
223 ((sbp->sb_versionnum & XFS_SB_VERSION_MOREBITSBIT) && \
224 (sbp->sb_features2 & ~XFS_SB_VERSION2_OKREALBITS))) && \
225 (sbp->sb_shared_vn <= XFS_SB_MAX_SHARED_VN)));
227 #else
228 static inline int xfs_sb_good_version(xfs_sb_t *sbp)
230 return (((sbp->sb_versionnum >= XFS_SB_VERSION_1) && \
231 (sbp->sb_versionnum <= XFS_SB_VERSION_3)) || \
232 ((XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_4) && \
233 !((sbp->sb_versionnum & ~XFS_SB_VERSION_OKREALBITS) || \
234 ((sbp->sb_versionnum & XFS_SB_VERSION_MOREBITSBIT) && \
235 (sbp->sb_features2 & ~XFS_SB_VERSION2_OKREALBITS))) && \
236 (!(sbp->sb_versionnum & XFS_SB_VERSION_SHAREDBIT) || \
237 (sbp->sb_shared_vn <= XFS_SB_MAX_SHARED_VN))));
239 #endif /* __KERNEL__ */
241 #define XFS_SB_GOOD_SASH_VERSION(sbp) \
242 ((((sbp)->sb_versionnum >= XFS_SB_VERSION_1) && \
243 ((sbp)->sb_versionnum <= XFS_SB_VERSION_3)) || \
244 ((XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_4) && \
245 !((sbp)->sb_versionnum & ~XFS_SB_VERSION_OKSASHBITS)))
247 #define XFS_SB_VERSION_TONEW(v) xfs_sb_version_tonew(v)
248 static inline unsigned xfs_sb_version_tonew(unsigned v)
250 return ((((v) == XFS_SB_VERSION_1) ? \
251 0 : \
252 (((v) == XFS_SB_VERSION_2) ? \
253 XFS_SB_VERSION_ATTRBIT : \
254 (XFS_SB_VERSION_ATTRBIT | XFS_SB_VERSION_NLINKBIT))) | \
255 XFS_SB_VERSION_4);
258 #define XFS_SB_VERSION_TOOLD(v) xfs_sb_version_toold(v)
259 static inline unsigned xfs_sb_version_toold(unsigned v)
261 return (((v) & (XFS_SB_VERSION_QUOTABIT | XFS_SB_VERSION_ALIGNBIT)) ? \
262 0 : \
263 (((v) & XFS_SB_VERSION_NLINKBIT) ? \
264 XFS_SB_VERSION_3 : \
265 (((v) & XFS_SB_VERSION_ATTRBIT) ? \
266 XFS_SB_VERSION_2 : \
267 XFS_SB_VERSION_1)));
270 #define XFS_SB_VERSION_HASATTR(sbp) xfs_sb_version_hasattr(sbp)
271 static inline int xfs_sb_version_hasattr(xfs_sb_t *sbp)
273 return ((sbp)->sb_versionnum == XFS_SB_VERSION_2) || \
274 ((sbp)->sb_versionnum == XFS_SB_VERSION_3) || \
275 ((XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_4) && \
276 ((sbp)->sb_versionnum & XFS_SB_VERSION_ATTRBIT));
279 #define XFS_SB_VERSION_ADDATTR(sbp) xfs_sb_version_addattr(sbp)
280 static inline void xfs_sb_version_addattr(xfs_sb_t *sbp)
282 (sbp)->sb_versionnum = (((sbp)->sb_versionnum == XFS_SB_VERSION_1) ? \
283 XFS_SB_VERSION_2 : \
284 ((XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_4) ? \
285 ((sbp)->sb_versionnum | XFS_SB_VERSION_ATTRBIT) : \
286 (XFS_SB_VERSION_4 | XFS_SB_VERSION_ATTRBIT)));
289 #define XFS_SB_VERSION_HASNLINK(sbp) xfs_sb_version_hasnlink(sbp)
290 static inline int xfs_sb_version_hasnlink(xfs_sb_t *sbp)
292 return ((sbp)->sb_versionnum == XFS_SB_VERSION_3) || \
293 ((XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_4) && \
294 ((sbp)->sb_versionnum & XFS_SB_VERSION_NLINKBIT));
297 #define XFS_SB_VERSION_ADDNLINK(sbp) xfs_sb_version_addnlink(sbp)
298 static inline void xfs_sb_version_addnlink(xfs_sb_t *sbp)
300 (sbp)->sb_versionnum = ((sbp)->sb_versionnum <= XFS_SB_VERSION_2 ? \
301 XFS_SB_VERSION_3 : \
302 ((sbp)->sb_versionnum | XFS_SB_VERSION_NLINKBIT));
305 #define XFS_SB_VERSION_HASQUOTA(sbp) xfs_sb_version_hasquota(sbp)
306 static inline int xfs_sb_version_hasquota(xfs_sb_t *sbp)
308 return (XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_4) && \
309 ((sbp)->sb_versionnum & XFS_SB_VERSION_QUOTABIT);
312 #define XFS_SB_VERSION_ADDQUOTA(sbp) xfs_sb_version_addquota(sbp)
313 static inline void xfs_sb_version_addquota(xfs_sb_t *sbp)
315 (sbp)->sb_versionnum = \
316 (XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_4 ? \
317 ((sbp)->sb_versionnum | XFS_SB_VERSION_QUOTABIT) : \
318 (XFS_SB_VERSION_TONEW((sbp)->sb_versionnum) | \
319 XFS_SB_VERSION_QUOTABIT));
322 #define XFS_SB_VERSION_HASALIGN(sbp) xfs_sb_version_hasalign(sbp)
323 static inline int xfs_sb_version_hasalign(xfs_sb_t *sbp)
325 return (XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_4) && \
326 ((sbp)->sb_versionnum & XFS_SB_VERSION_ALIGNBIT);
329 #define XFS_SB_VERSION_SUBALIGN(sbp) xfs_sb_version_subalign(sbp)
330 static inline void xfs_sb_version_subalign(xfs_sb_t *sbp)
332 (sbp)->sb_versionnum = \
333 XFS_SB_VERSION_TOOLD((sbp)->sb_versionnum & ~XFS_SB_VERSION_ALIGNBIT);
336 #define XFS_SB_VERSION_HASDALIGN(sbp) xfs_sb_version_hasdalign(sbp)
337 static inline int xfs_sb_version_hasdalign(xfs_sb_t *sbp)
339 return (XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_4) && \
340 ((sbp)->sb_versionnum & XFS_SB_VERSION_DALIGNBIT);
343 #define XFS_SB_VERSION_ADDDALIGN(sbp) xfs_sb_version_adddalign(sbp)
344 static inline int xfs_sb_version_adddalign(xfs_sb_t *sbp)
346 return (sbp)->sb_versionnum = \
347 ((sbp)->sb_versionnum | XFS_SB_VERSION_DALIGNBIT);
350 #define XFS_SB_VERSION_HASSHARED(sbp) xfs_sb_version_hasshared(sbp)
351 static inline int xfs_sb_version_hasshared(xfs_sb_t *sbp)
353 return (XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_4) && \
354 ((sbp)->sb_versionnum & XFS_SB_VERSION_SHAREDBIT);
357 #define XFS_SB_VERSION_ADDSHARED(sbp) xfs_sb_version_addshared(sbp)
358 static inline int xfs_sb_version_addshared(xfs_sb_t *sbp)
360 return (sbp)->sb_versionnum = \
361 ((sbp)->sb_versionnum | XFS_SB_VERSION_SHAREDBIT);
364 #define XFS_SB_VERSION_SUBSHARED(sbp) xfs_sb_version_subshared(sbp)
365 static inline int xfs_sb_version_subshared(xfs_sb_t *sbp)
367 return (sbp)->sb_versionnum = \
368 ((sbp)->sb_versionnum & ~XFS_SB_VERSION_SHAREDBIT);
371 #define XFS_SB_VERSION_HASDIRV2(sbp) xfs_sb_version_hasdirv2(sbp)
372 static inline int xfs_sb_version_hasdirv2(xfs_sb_t *sbp)
374 return (XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_4) && \
375 ((sbp)->sb_versionnum & XFS_SB_VERSION_DIRV2BIT);
378 #define XFS_SB_VERSION_HASLOGV2(sbp) xfs_sb_version_haslogv2(sbp)
379 static inline int xfs_sb_version_haslogv2(xfs_sb_t *sbp)
381 return (XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_4) && \
382 ((sbp)->sb_versionnum & XFS_SB_VERSION_LOGV2BIT);
385 #define XFS_SB_VERSION_HASEXTFLGBIT(sbp) xfs_sb_version_hasextflgbit(sbp)
386 static inline int xfs_sb_version_hasextflgbit(xfs_sb_t *sbp)
388 return (XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_4) && \
389 ((sbp)->sb_versionnum & XFS_SB_VERSION_EXTFLGBIT);
392 #define XFS_SB_VERSION_ADDEXTFLGBIT(sbp) xfs_sb_version_addextflgbit(sbp)
393 static inline int xfs_sb_version_addextflgbit(xfs_sb_t *sbp)
395 return (sbp)->sb_versionnum = \
396 ((sbp)->sb_versionnum | XFS_SB_VERSION_EXTFLGBIT);
399 #define XFS_SB_VERSION_SUBEXTFLGBIT(sbp) xfs_sb_version_subextflgbit(sbp)
400 static inline int xfs_sb_version_subextflgbit(xfs_sb_t *sbp)
402 return (sbp)->sb_versionnum = \
403 ((sbp)->sb_versionnum & ~XFS_SB_VERSION_EXTFLGBIT);
406 #define XFS_SB_VERSION_HASSECTOR(sbp) xfs_sb_version_hassector(sbp)
407 static inline int xfs_sb_version_hassector(xfs_sb_t *sbp)
409 return (XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_4) && \
410 ((sbp)->sb_versionnum & XFS_SB_VERSION_SECTORBIT);
413 #define XFS_SB_VERSION_HASMOREBITS(sbp) xfs_sb_version_hasmorebits(sbp)
414 static inline int xfs_sb_version_hasmorebits(xfs_sb_t *sbp)
416 return (XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_4) && \
417 ((sbp)->sb_versionnum & XFS_SB_VERSION_MOREBITSBIT);
421 * sb_features2 bit version macros.
423 * For example, for a bit defined as XFS_SB_VERSION2_FUNBIT, has a macro:
425 * SB_VERSION_HASFUNBIT(xfs_sb_t *sbp)
426 * ((XFS_SB_VERSION_HASMOREBITS(sbp) &&
427 * ((sbp)->sb_features2 & XFS_SB_VERSION2_FUNBIT)
430 #define XFS_SB_VERSION_HASATTR2(sbp) xfs_sb_version_hasattr2(sbp)
431 static inline int xfs_sb_version_hasattr2(xfs_sb_t *sbp)
433 return (XFS_SB_VERSION_HASMOREBITS(sbp)) && \
434 ((sbp)->sb_features2 & XFS_SB_VERSION2_ATTR2BIT);
437 #define XFS_SB_VERSION_ADDATTR2(sbp) xfs_sb_version_addattr2(sbp)
438 static inline void xfs_sb_version_addattr2(xfs_sb_t *sbp)
440 ((sbp)->sb_versionnum = \
441 ((sbp)->sb_versionnum | XFS_SB_VERSION_MOREBITSBIT), \
442 ((sbp)->sb_features2 = \
443 ((sbp)->sb_features2 | XFS_SB_VERSION2_ATTR2BIT)));
447 * end of superblock version macros
450 #define XFS_SB_DADDR ((xfs_daddr_t)0) /* daddr in filesystem/ag */
451 #define XFS_SB_BLOCK(mp) XFS_HDR_BLOCK(mp, XFS_SB_DADDR)
452 #define XFS_BUF_TO_SBP(bp) ((xfs_sb_t *)XFS_BUF_PTR(bp))
454 #define XFS_HDR_BLOCK(mp,d) ((xfs_agblock_t)XFS_BB_TO_FSBT(mp,d))
455 #define XFS_DADDR_TO_FSB(mp,d) XFS_AGB_TO_FSB(mp, \
456 XFS_DADDR_TO_AGNO(mp,d), XFS_DADDR_TO_AGBNO(mp,d))
457 #define XFS_FSB_TO_DADDR(mp,fsbno) XFS_AGB_TO_DADDR(mp, \
458 XFS_FSB_TO_AGNO(mp,fsbno), XFS_FSB_TO_AGBNO(mp,fsbno))
461 * File system sector to basic block conversions.
463 #define XFS_FSS_TO_BB(mp,sec) ((sec) << (mp)->m_sectbb_log)
464 #define XFS_BB_TO_FSS(mp,bb) \
465 (((bb) + (XFS_FSS_TO_BB(mp,1) - 1)) >> (mp)->m_sectbb_log)
466 #define XFS_BB_TO_FSST(mp,bb) ((bb) >> (mp)->m_sectbb_log)
469 * File system sector to byte conversions.
471 #define XFS_FSS_TO_B(mp,sectno) ((xfs_fsize_t)(sectno) << (mp)->m_sb.sb_sectlog)
472 #define XFS_B_TO_FSST(mp,b) (((__uint64_t)(b)) >> (mp)->m_sb.sb_sectlog)
475 * File system block to basic block conversions.
477 #define XFS_FSB_TO_BB(mp,fsbno) ((fsbno) << (mp)->m_blkbb_log)
478 #define XFS_BB_TO_FSB(mp,bb) \
479 (((bb) + (XFS_FSB_TO_BB(mp,1) - 1)) >> (mp)->m_blkbb_log)
480 #define XFS_BB_TO_FSBT(mp,bb) ((bb) >> (mp)->m_blkbb_log)
481 #define XFS_BB_FSB_OFFSET(mp,bb) ((bb) & ((mp)->m_bsize - 1))
484 * File system block to byte conversions.
486 #define XFS_FSB_TO_B(mp,fsbno) ((xfs_fsize_t)(fsbno) << (mp)->m_sb.sb_blocklog)
487 #define XFS_B_TO_FSB(mp,b) \
488 ((((__uint64_t)(b)) + (mp)->m_blockmask) >> (mp)->m_sb.sb_blocklog)
489 #define XFS_B_TO_FSBT(mp,b) (((__uint64_t)(b)) >> (mp)->m_sb.sb_blocklog)
490 #define XFS_B_FSB_OFFSET(mp,b) ((b) & (mp)->m_blockmask)
492 #endif /* __XFS_SB_H__ */