libparted 3.6
Loading...
Searching...
No Matches
xfs_sb.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2000 Silicon Graphics, Inc. All Rights Reserved.
3 *
4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms of version 3 of the GNU General Public License as
6 * published by the Free Software Foundation.
7 *
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.
11 *
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.
18 *
19 * You should have received a copy of the GNU General Public License along
20 * with this program. If not, see <http://www.gnu.org/licenses/>.
21 *
22 * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
23 * Mountain View, CA 94043, or:
24 *
25 * http://www.sgi.com
26 *
27 * For further information regarding this notice, see:
28 *
29 * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
30 */
31#ifndef __XFS_SB_H__
32#define __XFS_SB_H__
33
34/*
35 * Super block
36 * Fits into a 512-byte buffer at daddr_t 0 of each allocation group.
37 * Only the first of these is ever updated except during growfs.
38 */
39
40struct xfs_buf;
41struct xfs_mount;
42
43#define XFS_SB_MAGIC 0x58465342 /* 'XFSB' */
44#define XFS_SB_VERSION_1 1 /* 5.3, 6.0.1, 6.1 */
45#define XFS_SB_VERSION_2 2 /* 6.2 - attributes */
46#define XFS_SB_VERSION_3 3 /* 6.2 - new inode version */
47#define XFS_SB_VERSION_4 4 /* 6.2+ - bitmask version */
48#define XFS_SB_VERSION_NUMBITS 0x000f
49#define XFS_SB_VERSION_ALLFBITS 0xfff0
50#define XFS_SB_VERSION_SASHFBITS 0xf000
51#define XFS_SB_VERSION_REALFBITS 0x0ff0
52#define XFS_SB_VERSION_ATTRBIT 0x0010
53#define XFS_SB_VERSION_NLINKBIT 0x0020
54#define XFS_SB_VERSION_QUOTABIT 0x0040
55#define XFS_SB_VERSION_ALIGNBIT 0x0080
56#define XFS_SB_VERSION_DALIGNBIT 0x0100
57#define XFS_SB_VERSION_SHAREDBIT 0x0200
58#define XFS_SB_VERSION_EXTFLGBIT 0x1000
59#define XFS_SB_VERSION_DIRV2BIT 0x2000
60#define XFS_SB_VERSION_OKSASHFBITS \
61 (XFS_SB_VERSION_EXTFLGBIT | \
62 XFS_SB_VERSION_DIRV2BIT)
63#define XFS_SB_VERSION_OKREALFBITS \
64 (XFS_SB_VERSION_ATTRBIT | \
65 XFS_SB_VERSION_NLINKBIT | \
66 XFS_SB_VERSION_QUOTABIT | \
67 XFS_SB_VERSION_ALIGNBIT | \
68 XFS_SB_VERSION_DALIGNBIT | \
69 XFS_SB_VERSION_SHAREDBIT)
70#define XFS_SB_VERSION_OKSASHBITS \
71 (XFS_SB_VERSION_NUMBITS | \
72 XFS_SB_VERSION_REALFBITS | \
73 XFS_SB_VERSION_OKSASHFBITS)
74#define XFS_SB_VERSION_OKREALBITS \
75 (XFS_SB_VERSION_NUMBITS | \
76 XFS_SB_VERSION_OKREALFBITS | \
77 XFS_SB_VERSION_OKSASHFBITS)
78#define XFS_SB_VERSION_MKFS(ia,dia,extflag,dirv2) \
79 (((ia) || (dia) || (extflag) || (dirv2)) ? \
80 (XFS_SB_VERSION_4 | \
81 ((ia) ? XFS_SB_VERSION_ALIGNBIT : 0) | \
82 ((dia) ? XFS_SB_VERSION_DALIGNBIT : 0) | \
83 ((extflag) ? XFS_SB_VERSION_EXTFLGBIT : 0) | \
84 ((dirv2) ? XFS_SB_VERSION_DIRV2BIT : 0)) : \
85 XFS_SB_VERSION_1)
86
87typedef struct xfs_sb
88{
89 uint32_t sb_magicnum; /* magic number == XFS_SB_MAGIC */
90 uint32_t sb_blocksize; /* logical block size, bytes */
91 xfs_drfsbno_t sb_dblocks; /* number of data blocks */
92 xfs_drfsbno_t sb_rblocks; /* number of realtime blocks */
93 xfs_drtbno_t sb_rextents; /* number of realtime extents */
94 uuid_t sb_uuid; /* file system unique id */
95 xfs_dfsbno_t sb_logstart; /* starting block of log if internal */
96 xfs_ino_t sb_rootino; /* root inode number */
97 xfs_ino_t sb_rbmino; /* bitmap inode for realtime extents */
98 xfs_ino_t sb_rsumino; /* summary inode for rt bitmap */
99 xfs_agblock_t sb_rextsize; /* realtime extent size, blocks */
100 xfs_agblock_t sb_agblocks; /* size of an allocation group */
101 xfs_agnumber_t sb_agcount; /* number of allocation groups */
102 xfs_extlen_t sb_rbmblocks; /* number of rt bitmap blocks */
103 xfs_extlen_t sb_logblocks; /* number of log blocks */
104 uint16_t sb_versionnum; /* header version == XFS_SB_VERSION */
105 uint16_t sb_sectsize; /* volume sector size, bytes */
106 uint16_t sb_inodesize; /* inode size, bytes */
107 uint16_t sb_inopblock; /* inodes per block */
108 char sb_fname[12]; /* file system name */
109 uint8_t sb_blocklog; /* log2 of sb_blocksize */
110 uint8_t sb_sectlog; /* log2 of sb_sectsize */
111 uint8_t sb_inodelog; /* log2 of sb_inodesize */
112 uint8_t sb_inopblog; /* log2 of sb_inopblock */
113 uint8_t sb_agblklog; /* log2 of sb_agblocks (rounded up) */
114 uint8_t sb_rextslog; /* log2 of sb_rextents */
115 uint8_t sb_inprogress; /* mkfs is in progress, don't mount */
116 uint8_t sb_imax_pct; /* max % of fs for inode space */
117 /* statistics */
118 /*
119 * These fields must remain contiguous. If you really
120 * want to change their layout, make sure you fix the
121 * code in xfs_trans_apply_sb_deltas().
122 */
123 uint64_t sb_icount; /* allocated inodes */
124 uint64_t sb_ifree; /* free inodes */
125 uint64_t sb_fdblocks; /* free data blocks */
126 uint64_t sb_frextents; /* free realtime extents */
127 /*
128 * End contiguous fields.
129 */
130 xfs_ino_t sb_uquotino; /* user quota inode */
131 xfs_ino_t sb_gquotino; /* group quota inode */
132 uint16_t sb_qflags; /* quota flags */
133 uint8_t sb_flags; /* misc. flags */
134 uint8_t sb_shared_vn; /* shared version number */
135 xfs_extlen_t sb_inoalignmt; /* inode chunk alignment, fsblocks */
136 uint32_t sb_unit; /* stripe or raid unit */
137 uint32_t sb_width; /* stripe or raid width */
138 uint8_t sb_dirblklog; /* log2 of dir block size (fsbs) */
139 uint8_t sb_dummy[7]; /* padding */
141
142/*
143 * Sequence number values for the fields.
144 */
145typedef enum {
160
161/*
162 * Mask values, defined based on the xfs_sb_field_t values.
163 * Only define the ones we're using.
164 */
165#define XFS_SB_MVAL(x) (1LL << XFS_SBS_ ## x)
166#define XFS_SB_UUID XFS_SB_MVAL(UUID)
167#define XFS_SB_FNAME XFS_SB_MVAL(FNAME)
168#define XFS_SB_ROOTINO XFS_SB_MVAL(ROOTINO)
169#define XFS_SB_RBMINO XFS_SB_MVAL(RBMINO)
170#define XFS_SB_RSUMINO XFS_SB_MVAL(RSUMINO)
171#define XFS_SB_VERSIONNUM XFS_SB_MVAL(VERSIONNUM)
172#define XFS_SB_UQUOTINO XFS_SB_MVAL(UQUOTINO)
173#define XFS_SB_GQUOTINO XFS_SB_MVAL(GQUOTINO)
174#define XFS_SB_QFLAGS XFS_SB_MVAL(QFLAGS)
175#define XFS_SB_SHARED_VN XFS_SB_MVAL(SHARED_VN)
176#define XFS_SB_UNIT XFS_SB_MVAL(UNIT)
177#define XFS_SB_WIDTH XFS_SB_MVAL(WIDTH)
178#define XFS_SB_NUM_BITS ((int)XFS_SBS_FIELDCOUNT)
179#define XFS_SB_ALL_BITS ((1LL << XFS_SB_NUM_BITS) - 1)
180#define XFS_SB_MOD_BITS \
181 (XFS_SB_UUID | XFS_SB_ROOTINO | XFS_SB_RBMINO | XFS_SB_RSUMINO | \
182 XFS_SB_VERSIONNUM | XFS_SB_UQUOTINO | XFS_SB_GQUOTINO | \
183 XFS_SB_QFLAGS | XFS_SB_SHARED_VN | XFS_SB_UNIT | XFS_SB_WIDTH)
184
185/*
186 * Misc. Flags - warning - these will be cleared by xfs_repair unless
187 * a feature bit is set when the flag is used.
188 */
189#define XFS_SBF_NOFLAGS 0x00 /* no flags set */
190#define XFS_SBF_READONLY 0x01 /* only read-only mounts allowed */
191
192/*
193 * define max. shared version we can interoperate with
194 */
195#define XFS_SB_MAX_SHARED_VN 0
196
197#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_SB_VERSION_NUM)
198int xfs_sb_version_num(xfs_sb_t *sbp);
199#define XFS_SB_VERSION_NUM(sbp) xfs_sb_version_num(sbp)
200#else
201#define XFS_SB_VERSION_NUM(sbp) ((sbp)->sb_versionnum & XFS_SB_VERSION_NUMBITS)
202#endif
203
204#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_SB_GOOD_VERSION)
205int xfs_sb_good_version(xfs_sb_t *sbp);
206#define XFS_SB_GOOD_VERSION(sbp) xfs_sb_good_version(sbp)
207#else
208#define XFS_SB_GOOD_VERSION_INT(sbp) \
209 ((((sbp)->sb_versionnum >= XFS_SB_VERSION_1) && \
210 ((sbp)->sb_versionnum <= XFS_SB_VERSION_3)) || \
211 ((XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_4) && \
212 !((sbp)->sb_versionnum & ~XFS_SB_VERSION_OKREALBITS)
213#ifdef __KERNEL__
214#define XFS_SB_GOOD_VERSION(sbp) \
215 (XFS_SB_GOOD_VERSION_INT(sbp) && \
216 (sbp)->sb_shared_vn <= XFS_SB_MAX_SHARED_VN) ))
217#else
218/*
219 * extra 2 paren's here (( to unconfuse paren-matching editors
220 * like vi because XFS_SB_GOOD_VERSION_INT is a partial expression
221 * and the two XFS_SB_GOOD_VERSION's each 2 more close paren's to
222 * complete the expression.
223 */
224#define XFS_SB_GOOD_VERSION(sbp) \
225 (XFS_SB_GOOD_VERSION_INT(sbp) && \
226 (!((sbp)->sb_versionnum & XFS_SB_VERSION_SHAREDBIT) || \
227 (sbp)->sb_shared_vn <= XFS_SB_MAX_SHARED_VN)) ))
228#endif /* __KERNEL__ */
229#endif
230
231#define XFS_SB_GOOD_SASH_VERSION(sbp) \
232 ((((sbp)->sb_versionnum >= XFS_SB_VERSION_1) && \
233 ((sbp)->sb_versionnum <= XFS_SB_VERSION_3)) || \
234 ((XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_4) && \
235 !((sbp)->sb_versionnum & ~XFS_SB_VERSION_OKSASHBITS)))
236
237#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_SB_VERSION_TONEW)
238unsigned xfs_sb_version_tonew(unsigned v);
239#define XFS_SB_VERSION_TONEW(v) xfs_sb_version_tonew(v)
240#else
241#define XFS_SB_VERSION_TONEW(v) \
242 ((((v) == XFS_SB_VERSION_1) ? \
243 0 : \
244 (((v) == XFS_SB_VERSION_2) ? \
245 XFS_SB_VERSION_ATTRBIT : \
246 (XFS_SB_VERSION_ATTRBIT | XFS_SB_VERSION_NLINKBIT))) | \
247 XFS_SB_VERSION_4)
248#endif
249
250#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_SB_VERSION_TOOLD)
251unsigned xfs_sb_version_toold(unsigned v);
252#define XFS_SB_VERSION_TOOLD(v) xfs_sb_version_toold(v)
253#else
254#define XFS_SB_VERSION_TOOLD(v) \
255 (((v) & (XFS_SB_VERSION_QUOTABIT | XFS_SB_VERSION_ALIGNBIT)) ? \
256 0 : \
257 (((v) & XFS_SB_VERSION_NLINKBIT) ? \
258 XFS_SB_VERSION_3 : \
259 (((v) & XFS_SB_VERSION_ATTRBIT) ? \
260 XFS_SB_VERSION_2 : \
261 XFS_SB_VERSION_1)))
262#endif
263
264#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_SB_VERSION_HASATTR)
265int xfs_sb_version_hasattr(xfs_sb_t *sbp);
266#define XFS_SB_VERSION_HASATTR(sbp) xfs_sb_version_hasattr(sbp)
267#else
268#define XFS_SB_VERSION_HASATTR(sbp) \
269 (((sbp)->sb_versionnum == XFS_SB_VERSION_2) || \
270 ((sbp)->sb_versionnum == XFS_SB_VERSION_3) || \
271 ((XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_4) && \
272 ((sbp)->sb_versionnum & XFS_SB_VERSION_ATTRBIT)))
273#endif
274
275#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_SB_VERSION_ADDATTR)
276void xfs_sb_version_addattr(xfs_sb_t *sbp);
277#define XFS_SB_VERSION_ADDATTR(sbp) xfs_sb_version_addattr(sbp)
278#else
279#define XFS_SB_VERSION_ADDATTR(sbp) \
280 ((sbp)->sb_versionnum = \
281 (((sbp)->sb_versionnum == XFS_SB_VERSION_1) ? \
282 XFS_SB_VERSION_2 : \
283 ((XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_4) ? \
284 ((sbp)->sb_versionnum | XFS_SB_VERSION_ATTRBIT) : \
285 (XFS_SB_VERSION_4 | XFS_SB_VERSION_ATTRBIT))))
286#endif
287
288#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_SB_VERSION_HASNLINK)
289int xfs_sb_version_hasnlink(xfs_sb_t *sbp);
290#define XFS_SB_VERSION_HASNLINK(sbp) xfs_sb_version_hasnlink(sbp)
291#else
292#define XFS_SB_VERSION_HASNLINK(sbp) \
293 (((sbp)->sb_versionnum == XFS_SB_VERSION_3) || \
294 ((XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_4) && \
295 ((sbp)->sb_versionnum & XFS_SB_VERSION_NLINKBIT)))
296#endif
297
298#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_SB_VERSION_ADDNLINK)
299void xfs_sb_version_addnlink(xfs_sb_t *sbp);
300#define XFS_SB_VERSION_ADDNLINK(sbp) xfs_sb_version_addnlink(sbp)
301#else
302#define XFS_SB_VERSION_ADDNLINK(sbp) \
303 ((sbp)->sb_versionnum = \
304 ((sbp)->sb_versionnum <= XFS_SB_VERSION_2 ? \
305 XFS_SB_VERSION_3 : \
306 ((sbp)->sb_versionnum | XFS_SB_VERSION_NLINKBIT)))
307#endif
308
309#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_SB_VERSION_HASQUOTA)
310int xfs_sb_version_hasquota(xfs_sb_t *sbp);
311#define XFS_SB_VERSION_HASQUOTA(sbp) xfs_sb_version_hasquota(sbp)
312#else
313#define XFS_SB_VERSION_HASQUOTA(sbp) \
314 ((XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_4) && \
315 ((sbp)->sb_versionnum & XFS_SB_VERSION_QUOTABIT))
316#endif
317
318#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_SB_VERSION_ADDQUOTA)
319void xfs_sb_version_addquota(xfs_sb_t *sbp);
320#define XFS_SB_VERSION_ADDQUOTA(sbp) xfs_sb_version_addquota(sbp)
321#else
322#define XFS_SB_VERSION_ADDQUOTA(sbp) \
323 ((sbp)->sb_versionnum = \
324 (XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_4 ? \
325 ((sbp)->sb_versionnum | XFS_SB_VERSION_QUOTABIT) : \
326 (XFS_SB_VERSION_TONEW((sbp)->sb_versionnum) | \
327 XFS_SB_VERSION_QUOTABIT)))
328#endif
329
330#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_SB_VERSION_HASALIGN)
331int xfs_sb_version_hasalign(xfs_sb_t *sbp);
332#define XFS_SB_VERSION_HASALIGN(sbp) xfs_sb_version_hasalign(sbp)
333#else
334#define XFS_SB_VERSION_HASALIGN(sbp) \
335 ((XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_4) && \
336 ((sbp)->sb_versionnum & XFS_SB_VERSION_ALIGNBIT))
337#endif
338
339#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_SB_VERSION_SUBALIGN)
340void xfs_sb_version_subalign(xfs_sb_t *sbp);
341#define XFS_SB_VERSION_SUBALIGN(sbp) xfs_sb_version_subalign(sbp)
342#else
343#define XFS_SB_VERSION_SUBALIGN(sbp) \
344 ((sbp)->sb_versionnum = \
345 XFS_SB_VERSION_TOOLD((sbp)->sb_versionnum & ~XFS_SB_VERSION_ALIGNBIT))
346#endif
347
348#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_SB_VERSION_HASDALIGN)
349int xfs_sb_version_hasdalign(xfs_sb_t *sbp);
350#define XFS_SB_VERSION_HASDALIGN(sbp) xfs_sb_version_hasdalign(sbp)
351#else
352#define XFS_SB_VERSION_HASDALIGN(sbp) \
353 ((XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_4) && \
354 ((sbp)->sb_versionnum & XFS_SB_VERSION_DALIGNBIT))
355#endif
356
357#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_SB_VERSION_ADDDALIGN)
358int xfs_sb_version_adddalign(xfs_sb_t *sbp);
359#define XFS_SB_VERSION_ADDDALIGN(sbp) xfs_sb_version_adddalign(sbp)
360#else
361#define XFS_SB_VERSION_ADDDALIGN(sbp) \
362 ((sbp)->sb_versionnum = \
363 ((sbp)->sb_versionnum | XFS_SB_VERSION_DALIGNBIT))
364#endif
365
366#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_SB_VERSION_HASSHARED)
367int xfs_sb_version_hasshared(xfs_sb_t *sbp);
368#define XFS_SB_VERSION_HASSHARED(sbp) xfs_sb_version_hasshared(sbp)
369#else
370#define XFS_SB_VERSION_HASSHARED(sbp) \
371 ((XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_4) && \
372 ((sbp)->sb_versionnum & XFS_SB_VERSION_SHAREDBIT))
373#endif
374
375#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_SB_VERSION_ADDSHARED)
376int xfs_sb_version_addshared(xfs_sb_t *sbp);
377#define XFS_SB_VERSION_ADDSHARED(sbp) xfs_sb_version_addshared(sbp)
378#else
379#define XFS_SB_VERSION_ADDSHARED(sbp) \
380 ((sbp)->sb_versionnum = \
381 ((sbp)->sb_versionnum | XFS_SB_VERSION_SHAREDBIT))
382#endif
383
384#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_SB_VERSION_SUBSHARED)
385int xfs_sb_version_subshared(xfs_sb_t *sbp);
386#define XFS_SB_VERSION_SUBSHARED(sbp) xfs_sb_version_subshared(sbp)
387#else
388#define XFS_SB_VERSION_SUBSHARED(sbp) \
389 ((sbp)->sb_versionnum = \
390 ((sbp)->sb_versionnum & ~XFS_SB_VERSION_SHAREDBIT))
391#endif
392
393#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_SB_VERSION_HASDIRV2)
394int xfs_sb_version_hasdirv2(xfs_sb_t *sbp);
395#define XFS_SB_VERSION_HASDIRV2(sbp) xfs_sb_version_hasdirv2(sbp)
396#else
397#define XFS_SB_VERSION_HASDIRV2(sbp) \
398 ((XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_4) && \
399 ((sbp)->sb_versionnum & XFS_SB_VERSION_DIRV2BIT))
400#endif
401
402#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_SB_VERSION_HASEXTFLGBIT)
403int xfs_sb_version_hasextflgbit(xfs_sb_t *sbp);
404#define XFS_SB_VERSION_HASEXTFLGBIT(sbp) xfs_sb_version_hasextflgbit(sbp)
405#else
406#define XFS_SB_VERSION_HASEXTFLGBIT(sbp) \
407 ((XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_4) && \
408 ((sbp)->sb_versionnum & XFS_SB_VERSION_EXTFLGBIT))
409#endif
410
411#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_SB_VERSION_ADDEXTFLGBIT)
412int xfs_sb_version_addextflgbit(xfs_sb_t *sbp);
413#define XFS_SB_VERSION_ADDEXTFLGBIT(sbp) xfs_sb_version_addextflgbit(sbp)
414#else
415#define XFS_SB_VERSION_ADDEXTFLGBIT(sbp) \
416 ((sbp)->sb_versionnum = \
417 ((sbp)->sb_versionnum | XFS_SB_VERSION_EXTFLGBIT))
418#endif
419
420#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_SB_VERSION_SUBEXTFLGBIT)
421int xfs_sb_version_subextflgbit(xfs_sb_t *sbp);
422#define XFS_SB_VERSION_SUBEXTFLGBIT(sbp) xfs_sb_version_subextflgbit(sbp)
423#else
424#define XFS_SB_VERSION_SUBEXTFLGBIT(sbp) \
425 ((sbp)->sb_versionnum = \
426 ((sbp)->sb_versionnum & ~XFS_SB_VERSION_EXTFLGBIT))
427#endif
428
429/*
430 * end of superblock version macros
431 */
432
433#define XFS_SB_DADDR ((xfs_daddr_t)0) /* daddr in file system/ag */
434#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_SB_BLOCK)
435xfs_agblock_t xfs_sb_block(struct xfs_mount *mp);
436#define XFS_SB_BLOCK(mp) xfs_sb_block(mp)
437#else
438#define XFS_SB_BLOCK(mp) XFS_HDR_BLOCK(mp, XFS_SB_DADDR)
439#endif
440
441#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_HDR_BLOCK)
442xfs_agblock_t xfs_hdr_block(struct xfs_mount *mp, xfs_daddr_t d);
443#define XFS_HDR_BLOCK(mp,d) xfs_hdr_block(mp,d)
444#else
445#define XFS_HDR_BLOCK(mp,d) ((xfs_agblock_t)(XFS_BB_TO_FSBT(mp,d)))
446#endif
447#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_DADDR_TO_FSB)
448xfs_fsblock_t xfs_daddr_to_fsb(struct xfs_mount *mp, xfs_daddr_t d);
449#define XFS_DADDR_TO_FSB(mp,d) xfs_daddr_to_fsb(mp,d)
450#else
451#define XFS_DADDR_TO_FSB(mp,d) \
452 XFS_AGB_TO_FSB(mp, XFS_DADDR_TO_AGNO(mp,d), XFS_DADDR_TO_AGBNO(mp,d))
453#endif
454#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_FSB_TO_DADDR)
455xfs_daddr_t xfs_fsb_to_daddr(struct xfs_mount *mp, xfs_fsblock_t fsbno);
456#define XFS_FSB_TO_DADDR(mp,fsbno) xfs_fsb_to_daddr(mp,fsbno)
457#else
458#define XFS_FSB_TO_DADDR(mp,fsbno) \
459 XFS_AGB_TO_DADDR(mp, XFS_FSB_TO_AGNO(mp,fsbno), \
460 XFS_FSB_TO_AGBNO(mp,fsbno))
461#endif
462
463/*
464 * File system block to basic block conversions.
465 */
466#define XFS_FSB_TO_BB(mp,fsbno) ((fsbno) << (mp)->m_blkbb_log)
467#define XFS_BB_TO_FSB(mp,bb) \
468 (((bb) + (XFS_FSB_TO_BB(mp,1) - 1)) >> (mp)->m_blkbb_log)
469#define XFS_BB_TO_FSBT(mp,bb) ((bb) >> (mp)->m_blkbb_log)
470#define XFS_BB_FSB_OFFSET(mp,bb) ((bb) & ((mp)->m_bsize - 1))
471
472/*
473 * File system block to byte conversions.
474 */
475#define XFS_FSB_TO_B(mp,fsbno) ((xfs_fsize_t)(fsbno) << \
476 (mp)->m_sb.sb_blocklog)
477#define XFS_B_TO_FSB(mp,b) \
478 ((((uint64_t)(b)) + (mp)->m_blockmask) >> (mp)->m_sb.sb_blocklog)
479#define XFS_B_TO_FSBT(mp,b) (((uint64_t)(b)) >> (mp)->m_sb.sb_blocklog)
480#define XFS_B_FSB_OFFSET(mp,b) ((b) & (mp)->m_blockmask)
481
482#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_BUF_TO_SBP)
483xfs_sb_t *xfs_buf_to_sbp(struct xfs_buf *bp);
484#define XFS_BUF_TO_SBP(bp) xfs_buf_to_sbp(bp)
485#else
486#define XFS_BUF_TO_SBP(bp) ((xfs_sb_t *)XFS_BUF_PTR(bp))
487#endif
488
489#endif /* __XFS_SB_H__ */
int64_t xfs_daddr_t
Definition: platform_defs.h:58
uint64_t xfs_ino_t
Definition: platform_defs.h:56
Definition: xfs_sb.h:88
uuid_t sb_uuid
Definition: xfs_sb.h:94
uint16_t sb_inodesize
Definition: xfs_sb.h:106
uint8_t sb_imax_pct
Definition: xfs_sb.h:116
xfs_agblock_t sb_rextsize
Definition: xfs_sb.h:99
uint8_t sb_shared_vn
Definition: xfs_sb.h:134
uint32_t sb_width
Definition: xfs_sb.h:137
uint8_t sb_dummy[7]
Definition: xfs_sb.h:139
xfs_extlen_t sb_rbmblocks
Definition: xfs_sb.h:102
uint8_t sb_inodelog
Definition: xfs_sb.h:111
uint16_t sb_inopblock
Definition: xfs_sb.h:107
uint32_t sb_magicnum
Definition: xfs_sb.h:89
xfs_extlen_t sb_logblocks
Definition: xfs_sb.h:103
uint32_t sb_unit
Definition: xfs_sb.h:136
xfs_extlen_t sb_inoalignmt
Definition: xfs_sb.h:135
uint8_t sb_dirblklog
Definition: xfs_sb.h:138
uint64_t sb_fdblocks
Definition: xfs_sb.h:125
uint8_t sb_blocklog
Definition: xfs_sb.h:109
xfs_agnumber_t sb_agcount
Definition: xfs_sb.h:101
uint16_t sb_sectsize
Definition: xfs_sb.h:105
uint16_t sb_qflags
Definition: xfs_sb.h:132
uint8_t sb_inprogress
Definition: xfs_sb.h:115
uint8_t sb_flags
Definition: xfs_sb.h:133
xfs_dfsbno_t sb_logstart
Definition: xfs_sb.h:95
uint8_t sb_inopblog
Definition: xfs_sb.h:112
uint64_t sb_frextents
Definition: xfs_sb.h:126
uint32_t sb_blocksize
Definition: xfs_sb.h:90
xfs_agblock_t sb_agblocks
Definition: xfs_sb.h:100
xfs_ino_t sb_uquotino
Definition: xfs_sb.h:130
xfs_ino_t sb_rsumino
Definition: xfs_sb.h:98
uint16_t sb_versionnum
Definition: xfs_sb.h:104
xfs_drtbno_t sb_rextents
Definition: xfs_sb.h:93
uint8_t sb_sectlog
Definition: xfs_sb.h:110
uint8_t sb_agblklog
Definition: xfs_sb.h:113
xfs_ino_t sb_rbmino
Definition: xfs_sb.h:97
xfs_drfsbno_t sb_dblocks
Definition: xfs_sb.h:91
xfs_drfsbno_t sb_rblocks
Definition: xfs_sb.h:92
uint8_t sb_rextslog
Definition: xfs_sb.h:114
char sb_fname[12]
Definition: xfs_sb.h:108
xfs_ino_t sb_gquotino
Definition: xfs_sb.h:131
xfs_ino_t sb_rootino
Definition: xfs_sb.h:96
uint64_t sb_icount
Definition: xfs_sb.h:123
uint64_t sb_ifree
Definition: xfs_sb.h:124
xfs_sb_field_t
Definition: xfs_sb.h:145
@ XFS_SBS_FREXTENTS
Definition: xfs_sb.h:154
@ XFS_SBS_SECTLOG
Definition: xfs_sb.h:152
@ XFS_SBS_UUID
Definition: xfs_sb.h:147
@ XFS_SBS_UNIT
Definition: xfs_sb.h:156
@ XFS_SBS_FIELDCOUNT
Definition: xfs_sb.h:158
@ XFS_SBS_REXTSIZE
Definition: xfs_sb.h:148
@ XFS_SBS_AGBLKLOG
Definition: xfs_sb.h:152
@ XFS_SBS_UQUOTINO
Definition: xfs_sb.h:154
@ XFS_SBS_AGBLOCKS
Definition: xfs_sb.h:148
@ XFS_SBS_REXTSLOG
Definition: xfs_sb.h:153
@ XFS_SBS_LOGBLOCKS
Definition: xfs_sb.h:149
@ XFS_SBS_RBMBLOCKS
Definition: xfs_sb.h:149
@ XFS_SBS_INODESIZE
Definition: xfs_sb.h:150
@ XFS_SBS_AGCOUNT
Definition: xfs_sb.h:149
@ XFS_SBS_BLOCKSIZE
Definition: xfs_sb.h:146
@ XFS_SBS_QFLAGS
Definition: xfs_sb.h:155
@ XFS_SBS_MAGICNUM
Definition: xfs_sb.h:146
@ XFS_SBS_RSUMINO
Definition: xfs_sb.h:148
@ XFS_SBS_SECTSIZE
Definition: xfs_sb.h:150
@ XFS_SBS_FDBLOCKS
Definition: xfs_sb.h:154
@ XFS_SBS_INOALIGNMT
Definition: xfs_sb.h:156
@ XFS_SBS_INPROGRESS
Definition: xfs_sb.h:153
@ XFS_SBS_LOGSTART
Definition: xfs_sb.h:147
@ XFS_SBS_RBLOCKS
Definition: xfs_sb.h:146
@ XFS_SBS_WIDTH
Definition: xfs_sb.h:156
@ XFS_SBS_REXTENTS
Definition: xfs_sb.h:147
@ XFS_SBS_RBMINO
Definition: xfs_sb.h:148
@ XFS_SBS_IMAX_PCT
Definition: xfs_sb.h:153
@ XFS_SBS_SHARED_VN
Definition: xfs_sb.h:155
@ XFS_SBS_IFREE
Definition: xfs_sb.h:154
@ XFS_SBS_DUMMY
Definition: xfs_sb.h:157
@ XFS_SBS_DIRBLKLOG
Definition: xfs_sb.h:156
@ XFS_SBS_ICOUNT
Definition: xfs_sb.h:153
@ XFS_SBS_INODELOG
Definition: xfs_sb.h:152
@ XFS_SBS_FNAME
Definition: xfs_sb.h:151
@ XFS_SBS_BLOCKLOG
Definition: xfs_sb.h:151
@ XFS_SBS_VERSIONNUM
Definition: xfs_sb.h:150
@ XFS_SBS_ROOTINO
Definition: xfs_sb.h:147
@ XFS_SBS_GQUOTINO
Definition: xfs_sb.h:155
@ XFS_SBS_INOPBLOCK
Definition: xfs_sb.h:151
@ XFS_SBS_FLAGS
Definition: xfs_sb.h:155
@ XFS_SBS_INOPBLOG
Definition: xfs_sb.h:152
@ XFS_SBS_DBLOCKS
Definition: xfs_sb.h:146
struct xfs_sb xfs_sb_t
uint64_t xfs_drtbno_t
Definition: xfs_types.h:73
uint32_t xfs_agnumber_t
Definition: xfs_types.h:50
uint64_t xfs_dfsbno_t
Definition: xfs_types.h:71
uint64_t xfs_drfsbno_t
Definition: xfs_types.h:72
uint64_t xfs_fsblock_t
Definition: xfs_types.h:81
uint32_t xfs_agblock_t
Definition: xfs_types.h:48
uint32_t xfs_extlen_t
Definition: xfs_types.h:49