Linux 2.6.13-rc4
[linux-2.6/next.git] / fs / xfs / xfs_sb.h
blobad090a834ced6909dddfeca1b89608795725f083
1 /*
2 * Copyright (c) 2000-2001 Silicon Graphics, Inc. All Rights Reserved.
4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms of version 2 of the GNU General Public License as
6 * published by the Free Software Foundation.
8 * This program is distributed in the hope that it would be useful, but
9 * WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
12 * Further, this software is distributed without any warranty that it is
13 * free of the rightful claim of any third person regarding infringement
14 * or the like. Any license provided herein, whether implied or
15 * otherwise, applies only to this software file. Patent licenses, if
16 * any, provided herein do not apply to combinations of this program with
17 * other software, or any other product whatsoever.
19 * You should have received a copy of the GNU General Public License along
20 * with this program; if not, write the Free Software Foundation, Inc., 59
21 * Temple Place - Suite 330, Boston MA 02111-1307, USA.
23 * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
24 * Mountain View, CA 94043, or:
26 * http://www.sgi.com
28 * For further information regarding this notice, see:
30 * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
32 #ifndef __XFS_SB_H__
33 #define __XFS_SB_H__
36 * Super block
37 * Fits into a sector-sized buffer at address 0 of each allocation group.
38 * Only the first of these is ever updated except during growfs.
41 struct xfs_buf;
42 struct xfs_mount;
44 #define XFS_SB_MAGIC 0x58465342 /* 'XFSB' */
45 #define XFS_SB_VERSION_1 1 /* 5.3, 6.0.1, 6.1 */
46 #define XFS_SB_VERSION_2 2 /* 6.2 - attributes */
47 #define XFS_SB_VERSION_3 3 /* 6.2 - new inode version */
48 #define XFS_SB_VERSION_4 4 /* 6.2+ - bitmask version */
49 #define XFS_SB_VERSION_NUMBITS 0x000f
50 #define XFS_SB_VERSION_ALLFBITS 0xfff0
51 #define XFS_SB_VERSION_SASHFBITS 0xf000
52 #define XFS_SB_VERSION_REALFBITS 0x0ff0
53 #define XFS_SB_VERSION_ATTRBIT 0x0010
54 #define XFS_SB_VERSION_NLINKBIT 0x0020
55 #define XFS_SB_VERSION_QUOTABIT 0x0040
56 #define XFS_SB_VERSION_ALIGNBIT 0x0080
57 #define XFS_SB_VERSION_DALIGNBIT 0x0100
58 #define XFS_SB_VERSION_SHAREDBIT 0x0200
59 #define XFS_SB_VERSION_LOGV2BIT 0x0400
60 #define XFS_SB_VERSION_SECTORBIT 0x0800
61 #define XFS_SB_VERSION_EXTFLGBIT 0x1000
62 #define XFS_SB_VERSION_DIRV2BIT 0x2000
63 #define XFS_SB_VERSION_MOREBITSBIT 0x8000
64 #define XFS_SB_VERSION_OKSASHFBITS \
65 (XFS_SB_VERSION_EXTFLGBIT | \
66 XFS_SB_VERSION_DIRV2BIT)
67 #define XFS_SB_VERSION_OKREALFBITS \
68 (XFS_SB_VERSION_ATTRBIT | \
69 XFS_SB_VERSION_NLINKBIT | \
70 XFS_SB_VERSION_QUOTABIT | \
71 XFS_SB_VERSION_ALIGNBIT | \
72 XFS_SB_VERSION_DALIGNBIT | \
73 XFS_SB_VERSION_SHAREDBIT | \
74 XFS_SB_VERSION_LOGV2BIT | \
75 XFS_SB_VERSION_SECTORBIT)
76 #define XFS_SB_VERSION_OKSASHBITS \
77 (XFS_SB_VERSION_NUMBITS | \
78 XFS_SB_VERSION_REALFBITS | \
79 XFS_SB_VERSION_OKSASHFBITS)
80 #define XFS_SB_VERSION_OKREALBITS \
81 (XFS_SB_VERSION_NUMBITS | \
82 XFS_SB_VERSION_OKREALFBITS | \
83 XFS_SB_VERSION_OKSASHFBITS)
84 #define XFS_SB_VERSION_MKFS(ia,dia,extflag,dirv2,na,sflag,morebits) \
85 (((ia) || (dia) || (extflag) || (dirv2) || (na) || (sflag) || \
86 (morebits)) ? \
87 (XFS_SB_VERSION_4 | \
88 ((ia) ? XFS_SB_VERSION_ALIGNBIT : 0) | \
89 ((dia) ? XFS_SB_VERSION_DALIGNBIT : 0) | \
90 ((extflag) ? XFS_SB_VERSION_EXTFLGBIT : 0) | \
91 ((dirv2) ? XFS_SB_VERSION_DIRV2BIT : 0) | \
92 ((na) ? XFS_SB_VERSION_LOGV2BIT : 0) | \
93 ((sflag) ? XFS_SB_VERSION_SECTORBIT : 0) | \
94 ((morebits) ? XFS_SB_VERSION_MOREBITSBIT : 0)) : \
95 XFS_SB_VERSION_1)
98 * There are two words to hold XFS "feature" bits: the original
99 * word, sb_versionnum, and sb_features2. Whenever a bit is set in
100 * sb_features2, the feature bit XFS_SB_VERSION_MOREBITSBIT must be set.
102 * These defines represent bits in sb_features2.
104 #define XFS_SB_VERSION2_REALFBITS 0x00ffffff /* Mask: features */
105 #define XFS_SB_VERSION2_RESERVED1BIT 0x00000001
106 #define XFS_SB_VERSION2_SASHFBITS 0xff000000 /* Mask: features that
107 require changing
108 PROM and SASH */
110 #define XFS_SB_VERSION2_OKREALFBITS \
112 #define XFS_SB_VERSION2_OKSASHFBITS \
114 #define XFS_SB_VERSION2_OKREALBITS \
115 (XFS_SB_VERSION2_OKREALFBITS | \
116 XFS_SB_VERSION2_OKSASHFBITS )
119 * mkfs macro to set up sb_features2 word
121 #define XFS_SB_VERSION2_MKFS(xyz) \
122 ((xyz) ? 0 : 0)
124 typedef struct xfs_sb
126 __uint32_t sb_magicnum; /* magic number == XFS_SB_MAGIC */
127 __uint32_t sb_blocksize; /* logical block size, bytes */
128 xfs_drfsbno_t sb_dblocks; /* number of data blocks */
129 xfs_drfsbno_t sb_rblocks; /* number of realtime blocks */
130 xfs_drtbno_t sb_rextents; /* number of realtime extents */
131 uuid_t sb_uuid; /* file system unique id */
132 xfs_dfsbno_t sb_logstart; /* starting block of log if internal */
133 xfs_ino_t sb_rootino; /* root inode number */
134 xfs_ino_t sb_rbmino; /* bitmap inode for realtime extents */
135 xfs_ino_t sb_rsumino; /* summary inode for rt bitmap */
136 xfs_agblock_t sb_rextsize; /* realtime extent size, blocks */
137 xfs_agblock_t sb_agblocks; /* size of an allocation group */
138 xfs_agnumber_t sb_agcount; /* number of allocation groups */
139 xfs_extlen_t sb_rbmblocks; /* number of rt bitmap blocks */
140 xfs_extlen_t sb_logblocks; /* number of log blocks */
141 __uint16_t sb_versionnum; /* header version == XFS_SB_VERSION */
142 __uint16_t sb_sectsize; /* volume sector size, bytes */
143 __uint16_t sb_inodesize; /* inode size, bytes */
144 __uint16_t sb_inopblock; /* inodes per block */
145 char sb_fname[12]; /* file system name */
146 __uint8_t sb_blocklog; /* log2 of sb_blocksize */
147 __uint8_t sb_sectlog; /* log2 of sb_sectsize */
148 __uint8_t sb_inodelog; /* log2 of sb_inodesize */
149 __uint8_t sb_inopblog; /* log2 of sb_inopblock */
150 __uint8_t sb_agblklog; /* log2 of sb_agblocks (rounded up) */
151 __uint8_t sb_rextslog; /* log2 of sb_rextents */
152 __uint8_t sb_inprogress; /* mkfs is in progress, don't mount */
153 __uint8_t sb_imax_pct; /* max % of fs for inode space */
154 /* statistics */
156 * These fields must remain contiguous. If you really
157 * want to change their layout, make sure you fix the
158 * code in xfs_trans_apply_sb_deltas().
160 __uint64_t sb_icount; /* allocated inodes */
161 __uint64_t sb_ifree; /* free inodes */
162 __uint64_t sb_fdblocks; /* free data blocks */
163 __uint64_t sb_frextents; /* free realtime extents */
165 * End contiguous fields.
167 xfs_ino_t sb_uquotino; /* user quota inode */
168 xfs_ino_t sb_gquotino; /* group quota inode */
169 __uint16_t sb_qflags; /* quota flags */
170 __uint8_t sb_flags; /* misc. flags */
171 __uint8_t sb_shared_vn; /* shared version number */
172 xfs_extlen_t sb_inoalignmt; /* inode chunk alignment, fsblocks */
173 __uint32_t sb_unit; /* stripe or raid unit */
174 __uint32_t sb_width; /* stripe or raid width */
175 __uint8_t sb_dirblklog; /* log2 of dir block size (fsbs) */
176 __uint8_t sb_logsectlog; /* log2 of the log sector size */
177 __uint16_t sb_logsectsize; /* sector size for the log, bytes */
178 __uint32_t sb_logsunit; /* stripe unit size for the log */
179 __uint32_t sb_features2; /* additonal feature bits */
180 } xfs_sb_t;
183 * Sequence number values for the fields.
185 typedef enum {
186 XFS_SBS_MAGICNUM, XFS_SBS_BLOCKSIZE, XFS_SBS_DBLOCKS, XFS_SBS_RBLOCKS,
187 XFS_SBS_REXTENTS, XFS_SBS_UUID, XFS_SBS_LOGSTART, XFS_SBS_ROOTINO,
188 XFS_SBS_RBMINO, XFS_SBS_RSUMINO, XFS_SBS_REXTSIZE, XFS_SBS_AGBLOCKS,
189 XFS_SBS_AGCOUNT, XFS_SBS_RBMBLOCKS, XFS_SBS_LOGBLOCKS,
190 XFS_SBS_VERSIONNUM, XFS_SBS_SECTSIZE, XFS_SBS_INODESIZE,
191 XFS_SBS_INOPBLOCK, XFS_SBS_FNAME, XFS_SBS_BLOCKLOG,
192 XFS_SBS_SECTLOG, XFS_SBS_INODELOG, XFS_SBS_INOPBLOG, XFS_SBS_AGBLKLOG,
193 XFS_SBS_REXTSLOG, XFS_SBS_INPROGRESS, XFS_SBS_IMAX_PCT, XFS_SBS_ICOUNT,
194 XFS_SBS_IFREE, XFS_SBS_FDBLOCKS, XFS_SBS_FREXTENTS, XFS_SBS_UQUOTINO,
195 XFS_SBS_GQUOTINO, XFS_SBS_QFLAGS, XFS_SBS_FLAGS, XFS_SBS_SHARED_VN,
196 XFS_SBS_INOALIGNMT, XFS_SBS_UNIT, XFS_SBS_WIDTH, XFS_SBS_DIRBLKLOG,
197 XFS_SBS_LOGSECTLOG, XFS_SBS_LOGSECTSIZE, XFS_SBS_LOGSUNIT,
198 XFS_SBS_FEATURES2,
199 XFS_SBS_FIELDCOUNT
200 } xfs_sb_field_t;
203 * Mask values, defined based on the xfs_sb_field_t values.
204 * Only define the ones we're using.
206 #define XFS_SB_MVAL(x) (1LL << XFS_SBS_ ## x)
207 #define XFS_SB_UUID XFS_SB_MVAL(UUID)
208 #define XFS_SB_FNAME XFS_SB_MVAL(FNAME)
209 #define XFS_SB_ROOTINO XFS_SB_MVAL(ROOTINO)
210 #define XFS_SB_RBMINO XFS_SB_MVAL(RBMINO)
211 #define XFS_SB_RSUMINO XFS_SB_MVAL(RSUMINO)
212 #define XFS_SB_VERSIONNUM XFS_SB_MVAL(VERSIONNUM)
213 #define XFS_SB_UQUOTINO XFS_SB_MVAL(UQUOTINO)
214 #define XFS_SB_GQUOTINO XFS_SB_MVAL(GQUOTINO)
215 #define XFS_SB_QFLAGS XFS_SB_MVAL(QFLAGS)
216 #define XFS_SB_SHARED_VN XFS_SB_MVAL(SHARED_VN)
217 #define XFS_SB_UNIT XFS_SB_MVAL(UNIT)
218 #define XFS_SB_WIDTH XFS_SB_MVAL(WIDTH)
219 #define XFS_SB_NUM_BITS ((int)XFS_SBS_FIELDCOUNT)
220 #define XFS_SB_ALL_BITS ((1LL << XFS_SB_NUM_BITS) - 1)
221 #define XFS_SB_MOD_BITS \
222 (XFS_SB_UUID | XFS_SB_ROOTINO | XFS_SB_RBMINO | XFS_SB_RSUMINO | \
223 XFS_SB_VERSIONNUM | XFS_SB_UQUOTINO | XFS_SB_GQUOTINO | \
224 XFS_SB_QFLAGS | XFS_SB_SHARED_VN | XFS_SB_UNIT | XFS_SB_WIDTH)
227 * Misc. Flags - warning - these will be cleared by xfs_repair unless
228 * a feature bit is set when the flag is used.
230 #define XFS_SBF_NOFLAGS 0x00 /* no flags set */
231 #define XFS_SBF_READONLY 0x01 /* only read-only mounts allowed */
234 * define max. shared version we can interoperate with
236 #define XFS_SB_MAX_SHARED_VN 0
238 #if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_SB_VERSION_NUM)
239 int xfs_sb_version_num(xfs_sb_t *sbp);
240 #define XFS_SB_VERSION_NUM(sbp) xfs_sb_version_num(sbp)
241 #else
242 #define XFS_SB_VERSION_NUM(sbp) ((sbp)->sb_versionnum & XFS_SB_VERSION_NUMBITS)
243 #endif
245 #if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_SB_GOOD_VERSION)
246 int xfs_sb_good_version(xfs_sb_t *sbp);
247 #define XFS_SB_GOOD_VERSION(sbp) xfs_sb_good_version(sbp)
248 #else
249 #define XFS_SB_GOOD_VERSION_INT(sbp) \
250 ((((sbp)->sb_versionnum >= XFS_SB_VERSION_1) && \
251 ((sbp)->sb_versionnum <= XFS_SB_VERSION_3)) || \
252 ((XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_4) && \
253 !(((sbp)->sb_versionnum & ~XFS_SB_VERSION_OKREALBITS) || \
254 (((sbp)->sb_versionnum & XFS_SB_VERSION_MOREBITSBIT) && \
255 ((sbp)->sb_features2 & ~XFS_SB_VERSION2_OKREALBITS)))
257 #ifdef __KERNEL__
258 #define XFS_SB_GOOD_VERSION(sbp) \
259 (XFS_SB_GOOD_VERSION_INT(sbp) && \
260 (sbp)->sb_shared_vn <= XFS_SB_MAX_SHARED_VN) ))
261 #else
263 * extra 2 paren's here (( to unconfuse paren-matching editors
264 * like vi because XFS_SB_GOOD_VERSION_INT is a partial expression
265 * and the two XFS_SB_GOOD_VERSION's each 2 more close paren's to
266 * complete the expression.
268 #define XFS_SB_GOOD_VERSION(sbp) \
269 (XFS_SB_GOOD_VERSION_INT(sbp) && \
270 (!((sbp)->sb_versionnum & XFS_SB_VERSION_SHAREDBIT) || \
271 (sbp)->sb_shared_vn <= XFS_SB_MAX_SHARED_VN)) ))
272 #endif /* __KERNEL__ */
273 #endif
275 #define XFS_SB_GOOD_SASH_VERSION(sbp) \
276 ((((sbp)->sb_versionnum >= XFS_SB_VERSION_1) && \
277 ((sbp)->sb_versionnum <= XFS_SB_VERSION_3)) || \
278 ((XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_4) && \
279 !((sbp)->sb_versionnum & ~XFS_SB_VERSION_OKSASHBITS)))
281 #if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_SB_VERSION_TONEW)
282 unsigned xfs_sb_version_tonew(unsigned v);
283 #define XFS_SB_VERSION_TONEW(v) xfs_sb_version_tonew(v)
284 #else
285 #define XFS_SB_VERSION_TONEW(v) \
286 ((((v) == XFS_SB_VERSION_1) ? \
287 0 : \
288 (((v) == XFS_SB_VERSION_2) ? \
289 XFS_SB_VERSION_ATTRBIT : \
290 (XFS_SB_VERSION_ATTRBIT | XFS_SB_VERSION_NLINKBIT))) | \
291 XFS_SB_VERSION_4)
292 #endif
294 #if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_SB_VERSION_TOOLD)
295 unsigned xfs_sb_version_toold(unsigned v);
296 #define XFS_SB_VERSION_TOOLD(v) xfs_sb_version_toold(v)
297 #else
298 #define XFS_SB_VERSION_TOOLD(v) \
299 (((v) & (XFS_SB_VERSION_QUOTABIT | XFS_SB_VERSION_ALIGNBIT)) ? \
300 0 : \
301 (((v) & XFS_SB_VERSION_NLINKBIT) ? \
302 XFS_SB_VERSION_3 : \
303 (((v) & XFS_SB_VERSION_ATTRBIT) ? \
304 XFS_SB_VERSION_2 : \
305 XFS_SB_VERSION_1)))
306 #endif
308 #if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_SB_VERSION_HASATTR)
309 int xfs_sb_version_hasattr(xfs_sb_t *sbp);
310 #define XFS_SB_VERSION_HASATTR(sbp) xfs_sb_version_hasattr(sbp)
311 #else
312 #define XFS_SB_VERSION_HASATTR(sbp) \
313 (((sbp)->sb_versionnum == XFS_SB_VERSION_2) || \
314 ((sbp)->sb_versionnum == XFS_SB_VERSION_3) || \
315 ((XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_4) && \
316 ((sbp)->sb_versionnum & XFS_SB_VERSION_ATTRBIT)))
317 #endif
319 #if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_SB_VERSION_ADDATTR)
320 void xfs_sb_version_addattr(xfs_sb_t *sbp);
321 #define XFS_SB_VERSION_ADDATTR(sbp) xfs_sb_version_addattr(sbp)
322 #else
323 #define XFS_SB_VERSION_ADDATTR(sbp) \
324 ((sbp)->sb_versionnum = \
325 (((sbp)->sb_versionnum == XFS_SB_VERSION_1) ? \
326 XFS_SB_VERSION_2 : \
327 ((XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_4) ? \
328 ((sbp)->sb_versionnum | XFS_SB_VERSION_ATTRBIT) : \
329 (XFS_SB_VERSION_4 | XFS_SB_VERSION_ATTRBIT))))
330 #endif
332 #if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_SB_VERSION_HASNLINK)
333 int xfs_sb_version_hasnlink(xfs_sb_t *sbp);
334 #define XFS_SB_VERSION_HASNLINK(sbp) xfs_sb_version_hasnlink(sbp)
335 #else
336 #define XFS_SB_VERSION_HASNLINK(sbp) \
337 (((sbp)->sb_versionnum == XFS_SB_VERSION_3) || \
338 ((XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_4) && \
339 ((sbp)->sb_versionnum & XFS_SB_VERSION_NLINKBIT)))
340 #endif
342 #if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_SB_VERSION_ADDNLINK)
343 void xfs_sb_version_addnlink(xfs_sb_t *sbp);
344 #define XFS_SB_VERSION_ADDNLINK(sbp) xfs_sb_version_addnlink(sbp)
345 #else
346 #define XFS_SB_VERSION_ADDNLINK(sbp) \
347 ((sbp)->sb_versionnum = \
348 ((sbp)->sb_versionnum <= XFS_SB_VERSION_2 ? \
349 XFS_SB_VERSION_3 : \
350 ((sbp)->sb_versionnum | XFS_SB_VERSION_NLINKBIT)))
351 #endif
353 #if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_SB_VERSION_HASQUOTA)
354 int xfs_sb_version_hasquota(xfs_sb_t *sbp);
355 #define XFS_SB_VERSION_HASQUOTA(sbp) xfs_sb_version_hasquota(sbp)
356 #else
357 #define XFS_SB_VERSION_HASQUOTA(sbp) \
358 ((XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_4) && \
359 ((sbp)->sb_versionnum & XFS_SB_VERSION_QUOTABIT))
360 #endif
362 #if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_SB_VERSION_ADDQUOTA)
363 void xfs_sb_version_addquota(xfs_sb_t *sbp);
364 #define XFS_SB_VERSION_ADDQUOTA(sbp) xfs_sb_version_addquota(sbp)
365 #else
366 #define XFS_SB_VERSION_ADDQUOTA(sbp) \
367 ((sbp)->sb_versionnum = \
368 (XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_4 ? \
369 ((sbp)->sb_versionnum | XFS_SB_VERSION_QUOTABIT) : \
370 (XFS_SB_VERSION_TONEW((sbp)->sb_versionnum) | \
371 XFS_SB_VERSION_QUOTABIT)))
372 #endif
374 #if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_SB_VERSION_HASALIGN)
375 int xfs_sb_version_hasalign(xfs_sb_t *sbp);
376 #define XFS_SB_VERSION_HASALIGN(sbp) xfs_sb_version_hasalign(sbp)
377 #else
378 #define XFS_SB_VERSION_HASALIGN(sbp) \
379 ((XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_4) && \
380 ((sbp)->sb_versionnum & XFS_SB_VERSION_ALIGNBIT))
381 #endif
383 #if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_SB_VERSION_SUBALIGN)
384 void xfs_sb_version_subalign(xfs_sb_t *sbp);
385 #define XFS_SB_VERSION_SUBALIGN(sbp) xfs_sb_version_subalign(sbp)
386 #else
387 #define XFS_SB_VERSION_SUBALIGN(sbp) \
388 ((sbp)->sb_versionnum = \
389 XFS_SB_VERSION_TOOLD((sbp)->sb_versionnum & ~XFS_SB_VERSION_ALIGNBIT))
390 #endif
392 #if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_SB_VERSION_HASDALIGN)
393 int xfs_sb_version_hasdalign(xfs_sb_t *sbp);
394 #define XFS_SB_VERSION_HASDALIGN(sbp) xfs_sb_version_hasdalign(sbp)
395 #else
396 #define XFS_SB_VERSION_HASDALIGN(sbp) \
397 ((XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_4) && \
398 ((sbp)->sb_versionnum & XFS_SB_VERSION_DALIGNBIT))
399 #endif
401 #if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_SB_VERSION_ADDDALIGN)
402 int xfs_sb_version_adddalign(xfs_sb_t *sbp);
403 #define XFS_SB_VERSION_ADDDALIGN(sbp) xfs_sb_version_adddalign(sbp)
404 #else
405 #define XFS_SB_VERSION_ADDDALIGN(sbp) \
406 ((sbp)->sb_versionnum = \
407 ((sbp)->sb_versionnum | XFS_SB_VERSION_DALIGNBIT))
408 #endif
410 #if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_SB_VERSION_HASSHARED)
411 int xfs_sb_version_hasshared(xfs_sb_t *sbp);
412 #define XFS_SB_VERSION_HASSHARED(sbp) xfs_sb_version_hasshared(sbp)
413 #else
414 #define XFS_SB_VERSION_HASSHARED(sbp) \
415 ((XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_4) && \
416 ((sbp)->sb_versionnum & XFS_SB_VERSION_SHAREDBIT))
417 #endif
419 #if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_SB_VERSION_ADDSHARED)
420 int xfs_sb_version_addshared(xfs_sb_t *sbp);
421 #define XFS_SB_VERSION_ADDSHARED(sbp) xfs_sb_version_addshared(sbp)
422 #else
423 #define XFS_SB_VERSION_ADDSHARED(sbp) \
424 ((sbp)->sb_versionnum = \
425 ((sbp)->sb_versionnum | XFS_SB_VERSION_SHAREDBIT))
426 #endif
428 #if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_SB_VERSION_SUBSHARED)
429 int xfs_sb_version_subshared(xfs_sb_t *sbp);
430 #define XFS_SB_VERSION_SUBSHARED(sbp) xfs_sb_version_subshared(sbp)
431 #else
432 #define XFS_SB_VERSION_SUBSHARED(sbp) \
433 ((sbp)->sb_versionnum = \
434 ((sbp)->sb_versionnum & ~XFS_SB_VERSION_SHAREDBIT))
435 #endif
437 #if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_SB_VERSION_HASDIRV2)
438 int xfs_sb_version_hasdirv2(xfs_sb_t *sbp);
439 #define XFS_SB_VERSION_HASDIRV2(sbp) xfs_sb_version_hasdirv2(sbp)
440 #else
441 #define XFS_SB_VERSION_HASDIRV2(sbp) \
442 ((XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_4) && \
443 ((sbp)->sb_versionnum & XFS_SB_VERSION_DIRV2BIT))
444 #endif
446 #if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_SB_VERSION_HASLOGV2)
447 int xfs_sb_version_haslogv2(xfs_sb_t *sbp);
448 #define XFS_SB_VERSION_HASLOGV2(sbp) xfs_sb_version_haslogv2(sbp)
449 #else
450 #define XFS_SB_VERSION_HASLOGV2(sbp) \
451 ((XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_4) && \
452 ((sbp)->sb_versionnum & XFS_SB_VERSION_LOGV2BIT))
453 #endif
455 #if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_SB_VERSION_HASEXTFLGBIT)
456 int xfs_sb_version_hasextflgbit(xfs_sb_t *sbp);
457 #define XFS_SB_VERSION_HASEXTFLGBIT(sbp) xfs_sb_version_hasextflgbit(sbp)
458 #else
459 #define XFS_SB_VERSION_HASEXTFLGBIT(sbp) \
460 ((XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_4) && \
461 ((sbp)->sb_versionnum & XFS_SB_VERSION_EXTFLGBIT))
462 #endif
464 #if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_SB_VERSION_ADDEXTFLGBIT)
465 int xfs_sb_version_addextflgbit(xfs_sb_t *sbp);
466 #define XFS_SB_VERSION_ADDEXTFLGBIT(sbp) xfs_sb_version_addextflgbit(sbp)
467 #else
468 #define XFS_SB_VERSION_ADDEXTFLGBIT(sbp) \
469 ((sbp)->sb_versionnum = \
470 ((sbp)->sb_versionnum | XFS_SB_VERSION_EXTFLGBIT))
471 #endif
473 #if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_SB_VERSION_SUBEXTFLGBIT)
474 int xfs_sb_version_subextflgbit(xfs_sb_t *sbp);
475 #define XFS_SB_VERSION_SUBEXTFLGBIT(sbp) xfs_sb_version_subextflgbit(sbp)
476 #else
477 #define XFS_SB_VERSION_SUBEXTFLGBIT(sbp) \
478 ((sbp)->sb_versionnum = \
479 ((sbp)->sb_versionnum & ~XFS_SB_VERSION_EXTFLGBIT))
480 #endif
482 #if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_SB_VERSION_HASSECTOR)
483 int xfs_sb_version_hassector(xfs_sb_t *sbp);
484 #define XFS_SB_VERSION_HASSECTOR(sbp) xfs_sb_version_hassector(sbp)
485 #else
486 #define XFS_SB_VERSION_HASSECTOR(sbp) \
487 ((XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_4) && \
488 ((sbp)->sb_versionnum & XFS_SB_VERSION_SECTORBIT))
489 #endif
491 #if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_SB_VERSION_HASMOREBITSBIT)
492 int xfs_sb_version_hasmorebits(xfs_sb_t *sbp);
493 #define XFS_SB_VERSION_HASMOREBITS(sbp) xfs_sb_version_hasmorebits(sbp)
494 #else
495 #define XFS_SB_VERSION_HASMOREBITS(sbp) \
496 ((XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_4) && \
497 ((sbp)->sb_versionnum & XFS_SB_VERSION_MOREBITSBIT))
498 #endif
501 * sb_features2 bit version macros.
503 * For example, for a bit defined as XFS_SB_VERSION2_YBIT, has a macro:
505 * SB_VERSION_HASYBIT(xfs_sb_t *sbp)
506 * ((XFS_SB_VERSION_HASMOREBITS(sbp) &&
507 * ((sbp)->sb_versionnum & XFS_SB_VERSION2_YBIT)
511 * end of superblock version macros
514 #define XFS_SB_DADDR ((xfs_daddr_t)0) /* daddr in filesystem/ag */
515 #if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_SB_BLOCK)
516 xfs_agblock_t xfs_sb_block(struct xfs_mount *mp);
517 #define XFS_SB_BLOCK(mp) xfs_sb_block(mp)
518 #else
519 #define XFS_SB_BLOCK(mp) XFS_HDR_BLOCK(mp, XFS_SB_DADDR)
520 #endif
522 #if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_HDR_BLOCK)
523 xfs_agblock_t xfs_hdr_block(struct xfs_mount *mp, xfs_daddr_t d);
524 #define XFS_HDR_BLOCK(mp,d) xfs_hdr_block(mp,d)
525 #else
526 #define XFS_HDR_BLOCK(mp,d) ((xfs_agblock_t)(XFS_BB_TO_FSBT(mp,d)))
527 #endif
528 #if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_DADDR_TO_FSB)
529 xfs_fsblock_t xfs_daddr_to_fsb(struct xfs_mount *mp, xfs_daddr_t d);
530 #define XFS_DADDR_TO_FSB(mp,d) xfs_daddr_to_fsb(mp,d)
531 #else
532 #define XFS_DADDR_TO_FSB(mp,d) \
533 XFS_AGB_TO_FSB(mp, XFS_DADDR_TO_AGNO(mp,d), XFS_DADDR_TO_AGBNO(mp,d))
534 #endif
535 #if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_FSB_TO_DADDR)
536 xfs_daddr_t xfs_fsb_to_daddr(struct xfs_mount *mp, xfs_fsblock_t fsbno);
537 #define XFS_FSB_TO_DADDR(mp,fsbno) xfs_fsb_to_daddr(mp,fsbno)
538 #else
539 #define XFS_FSB_TO_DADDR(mp,fsbno) \
540 XFS_AGB_TO_DADDR(mp, XFS_FSB_TO_AGNO(mp,fsbno), \
541 XFS_FSB_TO_AGBNO(mp,fsbno))
542 #endif
544 #if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_BUF_TO_SBP)
545 xfs_sb_t *xfs_buf_to_sbp(struct xfs_buf *bp);
546 #define XFS_BUF_TO_SBP(bp) xfs_buf_to_sbp(bp)
547 #else
548 #define XFS_BUF_TO_SBP(bp) ((xfs_sb_t *)XFS_BUF_PTR(bp))
549 #endif
552 * File system sector to basic block conversions.
554 #define XFS_FSS_TO_BB(mp,sec) ((sec) << (mp)->m_sectbb_log)
555 #define XFS_BB_TO_FSS(mp,bb) \
556 (((bb) + (XFS_FSS_TO_BB(mp,1) - 1)) >> (mp)->m_sectbb_log)
557 #define XFS_BB_TO_FSST(mp,bb) ((bb) >> (mp)->m_sectbb_log)
560 * File system sector to byte conversions.
562 #define XFS_FSS_TO_B(mp,sectno) ((xfs_fsize_t)(sectno) << (mp)->m_sb.sb_sectlog)
563 #define XFS_B_TO_FSST(mp,b) (((__uint64_t)(b)) >> (mp)->m_sb.sb_sectlog)
566 * File system block to basic block conversions.
568 #define XFS_FSB_TO_BB(mp,fsbno) ((fsbno) << (mp)->m_blkbb_log)
569 #define XFS_BB_TO_FSB(mp,bb) \
570 (((bb) + (XFS_FSB_TO_BB(mp,1) - 1)) >> (mp)->m_blkbb_log)
571 #define XFS_BB_TO_FSBT(mp,bb) ((bb) >> (mp)->m_blkbb_log)
572 #define XFS_BB_FSB_OFFSET(mp,bb) ((bb) & ((mp)->m_bsize - 1))
575 * File system block to byte conversions.
577 #define XFS_FSB_TO_B(mp,fsbno) ((xfs_fsize_t)(fsbno) << (mp)->m_sb.sb_blocklog)
578 #define XFS_B_TO_FSB(mp,b) \
579 ((((__uint64_t)(b)) + (mp)->m_blockmask) >> (mp)->m_sb.sb_blocklog)
580 #define XFS_B_TO_FSBT(mp,b) (((__uint64_t)(b)) >> (mp)->m_sb.sb_blocklog)
581 #define XFS_B_FSB_OFFSET(mp,b) ((b) & (mp)->m_blockmask)
583 #endif /* __XFS_SB_H__ */