blob: 3c297a4516224bf36e6bac08494b94fda69f8db4 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
Nathan Scott7b718762005-11-02 14:58:39 +11002 * Copyright (c) 2000-2005 Silicon Graphics, Inc.
3 * All Rights Reserved.
Linus Torvalds1da177e2005-04-16 15:20:36 -07004 *
Nathan Scott7b718762005-11-02 14:58:39 +11005 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License as
Linus Torvalds1da177e2005-04-16 15:20:36 -07007 * published by the Free Software Foundation.
8 *
Nathan Scott7b718762005-11-02 14:58:39 +11009 * 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.
Linus Torvalds1da177e2005-04-16 15:20:36 -070013 *
Nathan Scott7b718762005-11-02 14:58:39 +110014 * 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
Linus Torvalds1da177e2005-04-16 15:20:36 -070017 */
18#ifndef __XFS_SB_H__
19#define __XFS_SB_H__
20
21/*
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.
25 */
26
27struct xfs_buf;
28struct xfs_mount;
Dave Chinnerff550682013-08-12 20:49:41 +100029struct xfs_trans;
Linus Torvalds1da177e2005-04-16 15:20:36 -070030
31#define XFS_SB_MAGIC 0x58465342 /* 'XFSB' */
32#define XFS_SB_VERSION_1 1 /* 5.3, 6.0.1, 6.1 */
33#define XFS_SB_VERSION_2 2 /* 6.2 - attributes */
34#define XFS_SB_VERSION_3 3 /* 6.2 - new inode version */
35#define XFS_SB_VERSION_4 4 /* 6.2+ - bitmask version */
Dave Chinner04a1e6c2013-04-03 16:11:31 +110036#define XFS_SB_VERSION_5 5 /* CRC enabled filesystem */
Linus Torvalds1da177e2005-04-16 15:20:36 -070037#define XFS_SB_VERSION_NUMBITS 0x000f
38#define XFS_SB_VERSION_ALLFBITS 0xfff0
39#define XFS_SB_VERSION_SASHFBITS 0xf000
40#define XFS_SB_VERSION_REALFBITS 0x0ff0
41#define XFS_SB_VERSION_ATTRBIT 0x0010
42#define XFS_SB_VERSION_NLINKBIT 0x0020
43#define XFS_SB_VERSION_QUOTABIT 0x0040
44#define XFS_SB_VERSION_ALIGNBIT 0x0080
45#define XFS_SB_VERSION_DALIGNBIT 0x0100
46#define XFS_SB_VERSION_SHAREDBIT 0x0200
47#define XFS_SB_VERSION_LOGV2BIT 0x0400
48#define XFS_SB_VERSION_SECTORBIT 0x0800
49#define XFS_SB_VERSION_EXTFLGBIT 0x1000
50#define XFS_SB_VERSION_DIRV2BIT 0x2000
Barry Naujok189f4bf2008-05-21 16:58:55 +100051#define XFS_SB_VERSION_BORGBIT 0x4000 /* ASCII only case-insens. */
Linus Torvalds1da177e2005-04-16 15:20:36 -070052#define XFS_SB_VERSION_MOREBITSBIT 0x8000
53#define XFS_SB_VERSION_OKSASHFBITS \
54 (XFS_SB_VERSION_EXTFLGBIT | \
Barry Naujok189f4bf2008-05-21 16:58:55 +100055 XFS_SB_VERSION_DIRV2BIT | \
56 XFS_SB_VERSION_BORGBIT)
Linus Torvalds1da177e2005-04-16 15:20:36 -070057#define XFS_SB_VERSION_OKREALFBITS \
58 (XFS_SB_VERSION_ATTRBIT | \
59 XFS_SB_VERSION_NLINKBIT | \
60 XFS_SB_VERSION_QUOTABIT | \
61 XFS_SB_VERSION_ALIGNBIT | \
62 XFS_SB_VERSION_DALIGNBIT | \
63 XFS_SB_VERSION_SHAREDBIT | \
64 XFS_SB_VERSION_LOGV2BIT | \
Nathan Scottd8cc8902005-11-02 10:34:53 +110065 XFS_SB_VERSION_SECTORBIT | \
66 XFS_SB_VERSION_MOREBITSBIT)
Linus Torvalds1da177e2005-04-16 15:20:36 -070067#define XFS_SB_VERSION_OKREALBITS \
68 (XFS_SB_VERSION_NUMBITS | \
69 XFS_SB_VERSION_OKREALFBITS | \
70 XFS_SB_VERSION_OKSASHFBITS)
Linus Torvalds1da177e2005-04-16 15:20:36 -070071
72/*
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.
76 *
77 * These defines represent bits in sb_features2.
78 */
79#define XFS_SB_VERSION2_REALFBITS 0x00ffffff /* Mask: features */
80#define XFS_SB_VERSION2_RESERVED1BIT 0x00000001
David Chinner92821e22007-05-24 15:26:31 +100081#define XFS_SB_VERSION2_LAZYSBCOUNTBIT 0x00000002 /* Superblk counters */
Nathan Scottd8cc8902005-11-02 10:34:53 +110082#define XFS_SB_VERSION2_RESERVED4BIT 0x00000004
83#define XFS_SB_VERSION2_ATTR2BIT 0x00000008 /* Inline attr rework */
Christoph Hellwig6d73cf12008-12-09 04:47:32 -050084#define XFS_SB_VERSION2_PARENTBIT 0x00000010 /* parent pointers */
Arkadiusz Mi?kiewicz67430992010-09-26 06:10:18 +000085#define XFS_SB_VERSION2_PROJID32BIT 0x00000080 /* 32 bit project id */
Christoph Hellwigbc02e862012-11-16 09:20:37 +110086#define XFS_SB_VERSION2_CRCBIT 0x00000100 /* metadata CRCs */
Linus Torvalds1da177e2005-04-16 15:20:36 -070087
88#define XFS_SB_VERSION2_OKREALFBITS \
David Chinner92821e22007-05-24 15:26:31 +100089 (XFS_SB_VERSION2_LAZYSBCOUNTBIT | \
Arkadiusz Mi?kiewicz67430992010-09-26 06:10:18 +000090 XFS_SB_VERSION2_ATTR2BIT | \
91 XFS_SB_VERSION2_PROJID32BIT)
Linus Torvalds1da177e2005-04-16 15:20:36 -070092#define XFS_SB_VERSION2_OKSASHFBITS \
93 (0)
94#define XFS_SB_VERSION2_OKREALBITS \
95 (XFS_SB_VERSION2_OKREALFBITS | \
96 XFS_SB_VERSION2_OKSASHFBITS )
97
Christoph Hellwig2bdf7cd2007-08-28 13:58:06 +100098/*
99 * Superblock - in core version. Must match the ondisk version below.
David Chinneree1c0902008-03-06 13:45:50 +1100100 * Must be padded to 64 bit alignment.
Christoph Hellwig2bdf7cd2007-08-28 13:58:06 +1000101 */
102typedef struct xfs_sb {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700103 __uint32_t sb_magicnum; /* magic number == XFS_SB_MAGIC */
104 __uint32_t sb_blocksize; /* logical block size, bytes */
105 xfs_drfsbno_t sb_dblocks; /* number of data blocks */
106 xfs_drfsbno_t sb_rblocks; /* number of realtime blocks */
107 xfs_drtbno_t sb_rextents; /* number of realtime extents */
108 uuid_t sb_uuid; /* file system unique id */
109 xfs_dfsbno_t sb_logstart; /* starting block of log if internal */
110 xfs_ino_t sb_rootino; /* root inode number */
111 xfs_ino_t sb_rbmino; /* bitmap inode for realtime extents */
112 xfs_ino_t sb_rsumino; /* summary inode for rt bitmap */
113 xfs_agblock_t sb_rextsize; /* realtime extent size, blocks */
114 xfs_agblock_t sb_agblocks; /* size of an allocation group */
115 xfs_agnumber_t sb_agcount; /* number of allocation groups */
116 xfs_extlen_t sb_rbmblocks; /* number of rt bitmap blocks */
117 xfs_extlen_t sb_logblocks; /* number of log blocks */
118 __uint16_t sb_versionnum; /* header version == XFS_SB_VERSION */
119 __uint16_t sb_sectsize; /* volume sector size, bytes */
120 __uint16_t sb_inodesize; /* inode size, bytes */
121 __uint16_t sb_inopblock; /* inodes per block */
122 char sb_fname[12]; /* file system name */
123 __uint8_t sb_blocklog; /* log2 of sb_blocksize */
124 __uint8_t sb_sectlog; /* log2 of sb_sectsize */
125 __uint8_t sb_inodelog; /* log2 of sb_inodesize */
126 __uint8_t sb_inopblog; /* log2 of sb_inopblock */
127 __uint8_t sb_agblklog; /* log2 of sb_agblocks (rounded up) */
128 __uint8_t sb_rextslog; /* log2 of sb_rextents */
129 __uint8_t sb_inprogress; /* mkfs is in progress, don't mount */
130 __uint8_t sb_imax_pct; /* max % of fs for inode space */
131 /* statistics */
132 /*
133 * These fields must remain contiguous. If you really
134 * want to change their layout, make sure you fix the
135 * code in xfs_trans_apply_sb_deltas().
136 */
137 __uint64_t sb_icount; /* allocated inodes */
138 __uint64_t sb_ifree; /* free inodes */
139 __uint64_t sb_fdblocks; /* free data blocks */
140 __uint64_t sb_frextents; /* free realtime extents */
141 /*
142 * End contiguous fields.
143 */
144 xfs_ino_t sb_uquotino; /* user quota inode */
145 xfs_ino_t sb_gquotino; /* group quota inode */
146 __uint16_t sb_qflags; /* quota flags */
147 __uint8_t sb_flags; /* misc. flags */
148 __uint8_t sb_shared_vn; /* shared version number */
149 xfs_extlen_t sb_inoalignmt; /* inode chunk alignment, fsblocks */
150 __uint32_t sb_unit; /* stripe or raid unit */
151 __uint32_t sb_width; /* stripe or raid width */
152 __uint8_t sb_dirblklog; /* log2 of dir block size (fsbs) */
153 __uint8_t sb_logsectlog; /* log2 of the log sector size */
154 __uint16_t sb_logsectsize; /* sector size for the log, bytes */
155 __uint32_t sb_logsunit; /* stripe unit size for the log */
Nathan Scottd8cc8902005-11-02 10:34:53 +1100156 __uint32_t sb_features2; /* additional feature bits */
David Chinneree1c0902008-03-06 13:45:50 +1100157
158 /*
159 * bad features2 field as a result of failing to pad the sb
160 * structure to 64 bits. Some machines will be using this field
161 * for features2 bits. Easiest just to mark it bad and not use
162 * it for anything else.
163 */
164 __uint32_t sb_bad_features2;
165
Dave Chinner04a1e6c2013-04-03 16:11:31 +1100166 /* version 5 superblock fields start here */
167
168 /* feature masks */
169 __uint32_t sb_features_compat;
170 __uint32_t sb_features_ro_compat;
171 __uint32_t sb_features_incompat;
Dave Chinnere721f502013-04-03 16:11:32 +1100172 __uint32_t sb_features_log_incompat;
Dave Chinner04a1e6c2013-04-03 16:11:31 +1100173
174 __uint32_t sb_crc; /* superblock crc */
Dave Chinnere721f502013-04-03 16:11:32 +1100175 __uint32_t sb_pad;
Dave Chinner04a1e6c2013-04-03 16:11:31 +1100176
177 xfs_ino_t sb_pquotino; /* project quota inode */
178 xfs_lsn_t sb_lsn; /* last write sequence */
179
David Chinneree1c0902008-03-06 13:45:50 +1100180 /* must be padded to 64 bit alignment */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700181} xfs_sb_t;
182
183/*
David Chinneree1c0902008-03-06 13:45:50 +1100184 * Superblock - on disk version. Must match the in core version above.
185 * Must be padded to 64 bit alignment.
Christoph Hellwig2bdf7cd2007-08-28 13:58:06 +1000186 */
187typedef struct xfs_dsb {
188 __be32 sb_magicnum; /* magic number == XFS_SB_MAGIC */
189 __be32 sb_blocksize; /* logical block size, bytes */
190 __be64 sb_dblocks; /* number of data blocks */
191 __be64 sb_rblocks; /* number of realtime blocks */
192 __be64 sb_rextents; /* number of realtime extents */
193 uuid_t sb_uuid; /* file system unique id */
194 __be64 sb_logstart; /* starting block of log if internal */
195 __be64 sb_rootino; /* root inode number */
196 __be64 sb_rbmino; /* bitmap inode for realtime extents */
197 __be64 sb_rsumino; /* summary inode for rt bitmap */
198 __be32 sb_rextsize; /* realtime extent size, blocks */
199 __be32 sb_agblocks; /* size of an allocation group */
200 __be32 sb_agcount; /* number of allocation groups */
201 __be32 sb_rbmblocks; /* number of rt bitmap blocks */
202 __be32 sb_logblocks; /* number of log blocks */
203 __be16 sb_versionnum; /* header version == XFS_SB_VERSION */
204 __be16 sb_sectsize; /* volume sector size, bytes */
205 __be16 sb_inodesize; /* inode size, bytes */
206 __be16 sb_inopblock; /* inodes per block */
207 char sb_fname[12]; /* file system name */
208 __u8 sb_blocklog; /* log2 of sb_blocksize */
209 __u8 sb_sectlog; /* log2 of sb_sectsize */
210 __u8 sb_inodelog; /* log2 of sb_inodesize */
211 __u8 sb_inopblog; /* log2 of sb_inopblock */
212 __u8 sb_agblklog; /* log2 of sb_agblocks (rounded up) */
213 __u8 sb_rextslog; /* log2 of sb_rextents */
214 __u8 sb_inprogress; /* mkfs is in progress, don't mount */
215 __u8 sb_imax_pct; /* max % of fs for inode space */
216 /* statistics */
217 /*
218 * These fields must remain contiguous. If you really
219 * want to change their layout, make sure you fix the
220 * code in xfs_trans_apply_sb_deltas().
221 */
222 __be64 sb_icount; /* allocated inodes */
223 __be64 sb_ifree; /* free inodes */
224 __be64 sb_fdblocks; /* free data blocks */
225 __be64 sb_frextents; /* free realtime extents */
226 /*
227 * End contiguous fields.
228 */
229 __be64 sb_uquotino; /* user quota inode */
230 __be64 sb_gquotino; /* group quota inode */
231 __be16 sb_qflags; /* quota flags */
232 __u8 sb_flags; /* misc. flags */
233 __u8 sb_shared_vn; /* shared version number */
234 __be32 sb_inoalignmt; /* inode chunk alignment, fsblocks */
235 __be32 sb_unit; /* stripe or raid unit */
236 __be32 sb_width; /* stripe or raid width */
237 __u8 sb_dirblklog; /* log2 of dir block size (fsbs) */
238 __u8 sb_logsectlog; /* log2 of the log sector size */
239 __be16 sb_logsectsize; /* sector size for the log, bytes */
240 __be32 sb_logsunit; /* stripe unit size for the log */
241 __be32 sb_features2; /* additional feature bits */
David Chinneree1c0902008-03-06 13:45:50 +1100242 /*
243 * bad features2 field as a result of failing to pad the sb
244 * structure to 64 bits. Some machines will be using this field
245 * for features2 bits. Easiest just to mark it bad and not use
246 * it for anything else.
247 */
Dave Chinner04a1e6c2013-04-03 16:11:31 +1100248 __be32 sb_bad_features2;
249
250 /* version 5 superblock fields start here */
251
252 /* feature masks */
253 __be32 sb_features_compat;
254 __be32 sb_features_ro_compat;
255 __be32 sb_features_incompat;
Dave Chinnere721f502013-04-03 16:11:32 +1100256 __be32 sb_features_log_incompat;
Dave Chinner04a1e6c2013-04-03 16:11:31 +1100257
258 __le32 sb_crc; /* superblock crc */
Dave Chinnere721f502013-04-03 16:11:32 +1100259 __be32 sb_pad;
Dave Chinner04a1e6c2013-04-03 16:11:31 +1100260
261 __be64 sb_pquotino; /* project quota inode */
262 __be64 sb_lsn; /* last write sequence */
David Chinneree1c0902008-03-06 13:45:50 +1100263
264 /* must be padded to 64 bit alignment */
Christoph Hellwig2bdf7cd2007-08-28 13:58:06 +1000265} xfs_dsb_t;
266
267/*
Linus Torvalds1da177e2005-04-16 15:20:36 -0700268 * Sequence number values for the fields.
269 */
270typedef enum {
271 XFS_SBS_MAGICNUM, XFS_SBS_BLOCKSIZE, XFS_SBS_DBLOCKS, XFS_SBS_RBLOCKS,
272 XFS_SBS_REXTENTS, XFS_SBS_UUID, XFS_SBS_LOGSTART, XFS_SBS_ROOTINO,
273 XFS_SBS_RBMINO, XFS_SBS_RSUMINO, XFS_SBS_REXTSIZE, XFS_SBS_AGBLOCKS,
274 XFS_SBS_AGCOUNT, XFS_SBS_RBMBLOCKS, XFS_SBS_LOGBLOCKS,
275 XFS_SBS_VERSIONNUM, XFS_SBS_SECTSIZE, XFS_SBS_INODESIZE,
276 XFS_SBS_INOPBLOCK, XFS_SBS_FNAME, XFS_SBS_BLOCKLOG,
277 XFS_SBS_SECTLOG, XFS_SBS_INODELOG, XFS_SBS_INOPBLOG, XFS_SBS_AGBLKLOG,
278 XFS_SBS_REXTSLOG, XFS_SBS_INPROGRESS, XFS_SBS_IMAX_PCT, XFS_SBS_ICOUNT,
279 XFS_SBS_IFREE, XFS_SBS_FDBLOCKS, XFS_SBS_FREXTENTS, XFS_SBS_UQUOTINO,
280 XFS_SBS_GQUOTINO, XFS_SBS_QFLAGS, XFS_SBS_FLAGS, XFS_SBS_SHARED_VN,
281 XFS_SBS_INOALIGNMT, XFS_SBS_UNIT, XFS_SBS_WIDTH, XFS_SBS_DIRBLKLOG,
282 XFS_SBS_LOGSECTLOG, XFS_SBS_LOGSECTSIZE, XFS_SBS_LOGSUNIT,
Dave Chinner04a1e6c2013-04-03 16:11:31 +1100283 XFS_SBS_FEATURES2, XFS_SBS_BAD_FEATURES2, XFS_SBS_FEATURES_COMPAT,
Dave Chinnere721f502013-04-03 16:11:32 +1100284 XFS_SBS_FEATURES_RO_COMPAT, XFS_SBS_FEATURES_INCOMPAT,
285 XFS_SBS_FEATURES_LOG_INCOMPAT, XFS_SBS_CRC, XFS_SBS_PAD,
Dave Chinner04a1e6c2013-04-03 16:11:31 +1100286 XFS_SBS_PQUOTINO, XFS_SBS_LSN,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700287 XFS_SBS_FIELDCOUNT
288} xfs_sb_field_t;
289
290/*
291 * Mask values, defined based on the xfs_sb_field_t values.
292 * Only define the ones we're using.
293 */
294#define XFS_SB_MVAL(x) (1LL << XFS_SBS_ ## x)
295#define XFS_SB_UUID XFS_SB_MVAL(UUID)
296#define XFS_SB_FNAME XFS_SB_MVAL(FNAME)
297#define XFS_SB_ROOTINO XFS_SB_MVAL(ROOTINO)
298#define XFS_SB_RBMINO XFS_SB_MVAL(RBMINO)
299#define XFS_SB_RSUMINO XFS_SB_MVAL(RSUMINO)
300#define XFS_SB_VERSIONNUM XFS_SB_MVAL(VERSIONNUM)
301#define XFS_SB_UQUOTINO XFS_SB_MVAL(UQUOTINO)
302#define XFS_SB_GQUOTINO XFS_SB_MVAL(GQUOTINO)
303#define XFS_SB_QFLAGS XFS_SB_MVAL(QFLAGS)
304#define XFS_SB_SHARED_VN XFS_SB_MVAL(SHARED_VN)
305#define XFS_SB_UNIT XFS_SB_MVAL(UNIT)
306#define XFS_SB_WIDTH XFS_SB_MVAL(WIDTH)
David Chinner92821e22007-05-24 15:26:31 +1000307#define XFS_SB_ICOUNT XFS_SB_MVAL(ICOUNT)
308#define XFS_SB_IFREE XFS_SB_MVAL(IFREE)
309#define XFS_SB_FDBLOCKS XFS_SB_MVAL(FDBLOCKS)
Nathan Scottd8cc8902005-11-02 10:34:53 +1100310#define XFS_SB_FEATURES2 XFS_SB_MVAL(FEATURES2)
David Chinneree1c0902008-03-06 13:45:50 +1100311#define XFS_SB_BAD_FEATURES2 XFS_SB_MVAL(BAD_FEATURES2)
Dave Chinner04a1e6c2013-04-03 16:11:31 +1100312#define XFS_SB_FEATURES_COMPAT XFS_SB_MVAL(FEATURES_COMPAT)
313#define XFS_SB_FEATURES_RO_COMPAT XFS_SB_MVAL(FEATURES_RO_COMPAT)
314#define XFS_SB_FEATURES_INCOMPAT XFS_SB_MVAL(FEATURES_INCOMPAT)
Dave Chinnere721f502013-04-03 16:11:32 +1100315#define XFS_SB_FEATURES_LOG_INCOMPAT XFS_SB_MVAL(FEATURES_LOG_INCOMPAT)
Dave Chinner04a1e6c2013-04-03 16:11:31 +1100316#define XFS_SB_CRC XFS_SB_MVAL(CRC)
317#define XFS_SB_PQUOTINO XFS_SB_MVAL(PQUOTINO)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700318#define XFS_SB_NUM_BITS ((int)XFS_SBS_FIELDCOUNT)
319#define XFS_SB_ALL_BITS ((1LL << XFS_SB_NUM_BITS) - 1)
320#define XFS_SB_MOD_BITS \
321 (XFS_SB_UUID | XFS_SB_ROOTINO | XFS_SB_RBMINO | XFS_SB_RSUMINO | \
322 XFS_SB_VERSIONNUM | XFS_SB_UQUOTINO | XFS_SB_GQUOTINO | \
Nathan Scottd8cc8902005-11-02 10:34:53 +1100323 XFS_SB_QFLAGS | XFS_SB_SHARED_VN | XFS_SB_UNIT | XFS_SB_WIDTH | \
David Chinneree1c0902008-03-06 13:45:50 +1100324 XFS_SB_ICOUNT | XFS_SB_IFREE | XFS_SB_FDBLOCKS | XFS_SB_FEATURES2 | \
Dave Chinner04a1e6c2013-04-03 16:11:31 +1100325 XFS_SB_BAD_FEATURES2 | XFS_SB_FEATURES_COMPAT | \
Dave Chinnere721f502013-04-03 16:11:32 +1100326 XFS_SB_FEATURES_RO_COMPAT | XFS_SB_FEATURES_INCOMPAT | \
327 XFS_SB_FEATURES_LOG_INCOMPAT | XFS_SB_PQUOTINO)
Nathan Scottd8cc8902005-11-02 10:34:53 +1100328
Linus Torvalds1da177e2005-04-16 15:20:36 -0700329
330/*
331 * Misc. Flags - warning - these will be cleared by xfs_repair unless
332 * a feature bit is set when the flag is used.
333 */
334#define XFS_SBF_NOFLAGS 0x00 /* no flags set */
335#define XFS_SBF_READONLY 0x01 /* only read-only mounts allowed */
336
337/*
338 * define max. shared version we can interoperate with
339 */
340#define XFS_SB_MAX_SHARED_VN 0
341
Linus Torvalds1da177e2005-04-16 15:20:36 -0700342#define XFS_SB_VERSION_NUM(sbp) ((sbp)->sb_versionnum & XFS_SB_VERSION_NUMBITS)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700343
Christoph Hellwig5efcbb82008-12-03 12:20:31 +0100344static inline int xfs_sb_good_version(xfs_sb_t *sbp)
345{
346 /* We always support version 1-3 */
347 if (sbp->sb_versionnum >= XFS_SB_VERSION_1 &&
348 sbp->sb_versionnum <= XFS_SB_VERSION_3)
349 return 1;
350
351 /* We support version 4 if all feature bits are supported */
352 if (XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_4) {
353 if ((sbp->sb_versionnum & ~XFS_SB_VERSION_OKREALBITS) ||
354 ((sbp->sb_versionnum & XFS_SB_VERSION_MOREBITSBIT) &&
355 (sbp->sb_features2 & ~XFS_SB_VERSION2_OKREALBITS)))
356 return 0;
357
Christoph Hellwig5efcbb82008-12-03 12:20:31 +0100358 if (sbp->sb_shared_vn > XFS_SB_MAX_SHARED_VN)
359 return 0;
Christoph Hellwig5efcbb82008-12-03 12:20:31 +0100360 return 1;
361 }
Dave Chinner04a1e6c2013-04-03 16:11:31 +1100362 if (XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_5)
363 return 1;
Christoph Hellwig5efcbb82008-12-03 12:20:31 +0100364
365 return 0;
Nathan Scotta844f452005-11-02 14:38:42 +1100366}
Linus Torvalds1da177e2005-04-16 15:20:36 -0700367
David Chinneree1c0902008-03-06 13:45:50 +1100368/*
Eric Sandeene6957ea42008-04-10 12:19:34 +1000369 * Detect a mismatched features2 field. Older kernels read/wrote
370 * this into the wrong slot, so to be safe we keep them in sync.
David Chinneree1c0902008-03-06 13:45:50 +1100371 */
Eric Sandeene6957ea42008-04-10 12:19:34 +1000372static inline int xfs_sb_has_mismatched_features2(xfs_sb_t *sbp)
David Chinneree1c0902008-03-06 13:45:50 +1100373{
Eric Sandeene6957ea42008-04-10 12:19:34 +1000374 return (sbp->sb_bad_features2 != sbp->sb_features2);
David Chinneree1c0902008-03-06 13:45:50 +1100375}
376
Nathan Scotta844f452005-11-02 14:38:42 +1100377static inline unsigned xfs_sb_version_tonew(unsigned v)
378{
Christoph Hellwig5efcbb82008-12-03 12:20:31 +0100379 if (v == XFS_SB_VERSION_1)
380 return XFS_SB_VERSION_4;
381
382 if (v == XFS_SB_VERSION_2)
383 return XFS_SB_VERSION_4 | XFS_SB_VERSION_ATTRBIT;
384
385 return XFS_SB_VERSION_4 | XFS_SB_VERSION_ATTRBIT |
386 XFS_SB_VERSION_NLINKBIT;
Nathan Scotta844f452005-11-02 14:38:42 +1100387}
Linus Torvalds1da177e2005-04-16 15:20:36 -0700388
Nathan Scotta844f452005-11-02 14:38:42 +1100389static inline unsigned xfs_sb_version_toold(unsigned v)
390{
Christoph Hellwig5efcbb82008-12-03 12:20:31 +0100391 if (v & (XFS_SB_VERSION_QUOTABIT | XFS_SB_VERSION_ALIGNBIT))
392 return 0;
393 if (v & XFS_SB_VERSION_NLINKBIT)
394 return XFS_SB_VERSION_3;
395 if (v & XFS_SB_VERSION_ATTRBIT)
396 return XFS_SB_VERSION_2;
397 return XFS_SB_VERSION_1;
Nathan Scotta844f452005-11-02 14:38:42 +1100398}
Linus Torvalds1da177e2005-04-16 15:20:36 -0700399
Nathan Scotta844f452005-11-02 14:38:42 +1100400static inline int xfs_sb_version_hasattr(xfs_sb_t *sbp)
401{
Christoph Hellwig5efcbb82008-12-03 12:20:31 +0100402 return sbp->sb_versionnum == XFS_SB_VERSION_2 ||
403 sbp->sb_versionnum == XFS_SB_VERSION_3 ||
Dave Chinner04a1e6c2013-04-03 16:11:31 +1100404 (XFS_SB_VERSION_NUM(sbp) >= XFS_SB_VERSION_4 &&
Christoph Hellwig5efcbb82008-12-03 12:20:31 +0100405 (sbp->sb_versionnum & XFS_SB_VERSION_ATTRBIT));
Nathan Scotta844f452005-11-02 14:38:42 +1100406}
Linus Torvalds1da177e2005-04-16 15:20:36 -0700407
Nathan Scotta844f452005-11-02 14:38:42 +1100408static inline void xfs_sb_version_addattr(xfs_sb_t *sbp)
409{
Christoph Hellwig5efcbb82008-12-03 12:20:31 +0100410 if (sbp->sb_versionnum == XFS_SB_VERSION_1)
411 sbp->sb_versionnum = XFS_SB_VERSION_2;
Dave Chinner04a1e6c2013-04-03 16:11:31 +1100412 else if (XFS_SB_VERSION_NUM(sbp) >= XFS_SB_VERSION_4)
Christoph Hellwig5efcbb82008-12-03 12:20:31 +0100413 sbp->sb_versionnum |= XFS_SB_VERSION_ATTRBIT;
414 else
415 sbp->sb_versionnum = XFS_SB_VERSION_4 | XFS_SB_VERSION_ATTRBIT;
Nathan Scotta844f452005-11-02 14:38:42 +1100416}
Linus Torvalds1da177e2005-04-16 15:20:36 -0700417
Nathan Scotta844f452005-11-02 14:38:42 +1100418static inline int xfs_sb_version_hasnlink(xfs_sb_t *sbp)
419{
Christoph Hellwig5efcbb82008-12-03 12:20:31 +0100420 return sbp->sb_versionnum == XFS_SB_VERSION_3 ||
Dave Chinner04a1e6c2013-04-03 16:11:31 +1100421 (XFS_SB_VERSION_NUM(sbp) >= XFS_SB_VERSION_4 &&
Christoph Hellwig5efcbb82008-12-03 12:20:31 +0100422 (sbp->sb_versionnum & XFS_SB_VERSION_NLINKBIT));
Nathan Scotta844f452005-11-02 14:38:42 +1100423}
Linus Torvalds1da177e2005-04-16 15:20:36 -0700424
Nathan Scotta844f452005-11-02 14:38:42 +1100425static inline void xfs_sb_version_addnlink(xfs_sb_t *sbp)
426{
Christoph Hellwig5efcbb82008-12-03 12:20:31 +0100427 if (sbp->sb_versionnum <= XFS_SB_VERSION_2)
428 sbp->sb_versionnum = XFS_SB_VERSION_3;
429 else
430 sbp->sb_versionnum |= XFS_SB_VERSION_NLINKBIT;
Nathan Scotta844f452005-11-02 14:38:42 +1100431}
Linus Torvalds1da177e2005-04-16 15:20:36 -0700432
Nathan Scotta844f452005-11-02 14:38:42 +1100433static inline int xfs_sb_version_hasquota(xfs_sb_t *sbp)
434{
Dave Chinner04a1e6c2013-04-03 16:11:31 +1100435 return XFS_SB_VERSION_NUM(sbp) >= XFS_SB_VERSION_4 &&
Christoph Hellwig5efcbb82008-12-03 12:20:31 +0100436 (sbp->sb_versionnum & XFS_SB_VERSION_QUOTABIT);
Nathan Scotta844f452005-11-02 14:38:42 +1100437}
Linus Torvalds1da177e2005-04-16 15:20:36 -0700438
Nathan Scotta844f452005-11-02 14:38:42 +1100439static inline void xfs_sb_version_addquota(xfs_sb_t *sbp)
440{
Dave Chinner04a1e6c2013-04-03 16:11:31 +1100441 if (XFS_SB_VERSION_NUM(sbp) >= XFS_SB_VERSION_4)
Christoph Hellwig5efcbb82008-12-03 12:20:31 +0100442 sbp->sb_versionnum |= XFS_SB_VERSION_QUOTABIT;
443 else
444 sbp->sb_versionnum = xfs_sb_version_tonew(sbp->sb_versionnum) |
445 XFS_SB_VERSION_QUOTABIT;
Nathan Scotta844f452005-11-02 14:38:42 +1100446}
Linus Torvalds1da177e2005-04-16 15:20:36 -0700447
Nathan Scotta844f452005-11-02 14:38:42 +1100448static inline int xfs_sb_version_hasalign(xfs_sb_t *sbp)
449{
Dave Chinner04a1e6c2013-04-03 16:11:31 +1100450 return (XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_5) ||
451 (XFS_SB_VERSION_NUM(sbp) >= XFS_SB_VERSION_4 &&
452 (sbp->sb_versionnum & XFS_SB_VERSION_ALIGNBIT));
Nathan Scotta844f452005-11-02 14:38:42 +1100453}
Linus Torvalds1da177e2005-04-16 15:20:36 -0700454
Nathan Scotta844f452005-11-02 14:38:42 +1100455static inline int xfs_sb_version_hasdalign(xfs_sb_t *sbp)
456{
Dave Chinner04a1e6c2013-04-03 16:11:31 +1100457 return XFS_SB_VERSION_NUM(sbp) >= XFS_SB_VERSION_4 &&
Christoph Hellwig5efcbb82008-12-03 12:20:31 +0100458 (sbp->sb_versionnum & XFS_SB_VERSION_DALIGNBIT);
Nathan Scotta844f452005-11-02 14:38:42 +1100459}
Linus Torvalds1da177e2005-04-16 15:20:36 -0700460
Nathan Scotta844f452005-11-02 14:38:42 +1100461static inline int xfs_sb_version_hasshared(xfs_sb_t *sbp)
462{
Christoph Hellwig5efcbb82008-12-03 12:20:31 +0100463 return XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_4 &&
464 (sbp->sb_versionnum & XFS_SB_VERSION_SHAREDBIT);
Nathan Scotta844f452005-11-02 14:38:42 +1100465}
Linus Torvalds1da177e2005-04-16 15:20:36 -0700466
Nathan Scotta844f452005-11-02 14:38:42 +1100467static inline int xfs_sb_version_hasdirv2(xfs_sb_t *sbp)
468{
Dave Chinner04a1e6c2013-04-03 16:11:31 +1100469 return (XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_5) ||
470 (XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_4 &&
471 (sbp->sb_versionnum & XFS_SB_VERSION_DIRV2BIT));
Nathan Scotta844f452005-11-02 14:38:42 +1100472}
Linus Torvalds1da177e2005-04-16 15:20:36 -0700473
Nathan Scotta844f452005-11-02 14:38:42 +1100474static inline int xfs_sb_version_haslogv2(xfs_sb_t *sbp)
475{
Dave Chinner04a1e6c2013-04-03 16:11:31 +1100476 return (XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_5) ||
477 (XFS_SB_VERSION_NUM(sbp) >= XFS_SB_VERSION_4 &&
478 (sbp->sb_versionnum & XFS_SB_VERSION_LOGV2BIT));
Nathan Scotta844f452005-11-02 14:38:42 +1100479}
Linus Torvalds1da177e2005-04-16 15:20:36 -0700480
Nathan Scotta844f452005-11-02 14:38:42 +1100481static inline int xfs_sb_version_hasextflgbit(xfs_sb_t *sbp)
482{
Dave Chinner04a1e6c2013-04-03 16:11:31 +1100483 return (XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_5) ||
484 (XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_4 &&
485 (sbp->sb_versionnum & XFS_SB_VERSION_EXTFLGBIT));
Nathan Scotta844f452005-11-02 14:38:42 +1100486}
Linus Torvalds1da177e2005-04-16 15:20:36 -0700487
Nathan Scotta844f452005-11-02 14:38:42 +1100488static inline int xfs_sb_version_hassector(xfs_sb_t *sbp)
489{
Dave Chinner04a1e6c2013-04-03 16:11:31 +1100490 return XFS_SB_VERSION_NUM(sbp) >= XFS_SB_VERSION_4 &&
Christoph Hellwig5efcbb82008-12-03 12:20:31 +0100491 (sbp->sb_versionnum & XFS_SB_VERSION_SECTORBIT);
Nathan Scotta844f452005-11-02 14:38:42 +1100492}
Linus Torvalds1da177e2005-04-16 15:20:36 -0700493
Barry Naujok189f4bf2008-05-21 16:58:55 +1000494static inline int xfs_sb_version_hasasciici(xfs_sb_t *sbp)
495{
Dave Chinner04a1e6c2013-04-03 16:11:31 +1100496 return XFS_SB_VERSION_NUM(sbp) >= XFS_SB_VERSION_4 &&
Barry Naujok189f4bf2008-05-21 16:58:55 +1000497 (sbp->sb_versionnum & XFS_SB_VERSION_BORGBIT);
498}
499
Nathan Scotta844f452005-11-02 14:38:42 +1100500static inline int xfs_sb_version_hasmorebits(xfs_sb_t *sbp)
501{
Dave Chinner04a1e6c2013-04-03 16:11:31 +1100502 return (XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_5) ||
503 (XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_4 &&
504 (sbp->sb_versionnum & XFS_SB_VERSION_MOREBITSBIT));
Nathan Scotta844f452005-11-02 14:38:42 +1100505}
Linus Torvalds1da177e2005-04-16 15:20:36 -0700506
507/*
508 * sb_features2 bit version macros.
509 *
Nathan Scottd8cc8902005-11-02 10:34:53 +1100510 * For example, for a bit defined as XFS_SB_VERSION2_FUNBIT, has a macro:
Linus Torvalds1da177e2005-04-16 15:20:36 -0700511 *
Nathan Scottd8cc8902005-11-02 10:34:53 +1100512 * SB_VERSION_HASFUNBIT(xfs_sb_t *sbp)
Eric Sandeen62118702008-03-06 13:44:28 +1100513 * ((xfs_sb_version_hasmorebits(sbp) &&
Nathan Scottd8cc8902005-11-02 10:34:53 +1100514 * ((sbp)->sb_features2 & XFS_SB_VERSION2_FUNBIT)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700515 */
516
David Chinner92821e22007-05-24 15:26:31 +1000517static inline int xfs_sb_version_haslazysbcount(xfs_sb_t *sbp)
518{
Dave Chinner04a1e6c2013-04-03 16:11:31 +1100519 return (XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_5) ||
520 (xfs_sb_version_hasmorebits(sbp) &&
521 (sbp->sb_features2 & XFS_SB_VERSION2_LAZYSBCOUNTBIT));
David Chinner92821e22007-05-24 15:26:31 +1000522}
523
Nathan Scotta844f452005-11-02 14:38:42 +1100524static inline int xfs_sb_version_hasattr2(xfs_sb_t *sbp)
525{
Dave Chinner04a1e6c2013-04-03 16:11:31 +1100526 return (XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_5) ||
527 (xfs_sb_version_hasmorebits(sbp) &&
528 (sbp->sb_features2 & XFS_SB_VERSION2_ATTR2BIT));
Nathan Scotta844f452005-11-02 14:38:42 +1100529}
530
Nathan Scotta844f452005-11-02 14:38:42 +1100531static inline void xfs_sb_version_addattr2(xfs_sb_t *sbp)
532{
Christoph Hellwig5efcbb82008-12-03 12:20:31 +0100533 sbp->sb_versionnum |= XFS_SB_VERSION_MOREBITSBIT;
534 sbp->sb_features2 |= XFS_SB_VERSION2_ATTR2BIT;
Nathan Scotta844f452005-11-02 14:38:42 +1100535}
536
Tim Shimmin7c12f292008-04-30 18:15:28 +1000537static inline void xfs_sb_version_removeattr2(xfs_sb_t *sbp)
538{
539 sbp->sb_features2 &= ~XFS_SB_VERSION2_ATTR2BIT;
540 if (!sbp->sb_features2)
541 sbp->sb_versionnum &= ~XFS_SB_VERSION_MOREBITSBIT;
542}
543
Arkadiusz Mi?kiewicz67430992010-09-26 06:10:18 +0000544static inline int xfs_sb_version_hasprojid32bit(xfs_sb_t *sbp)
545{
Dave Chinner04a1e6c2013-04-03 16:11:31 +1100546 return (XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_5) ||
547 (xfs_sb_version_hasmorebits(sbp) &&
548 (sbp->sb_features2 & XFS_SB_VERSION2_PROJID32BIT));
Arkadiusz Mi?kiewicz67430992010-09-26 06:10:18 +0000549}
550
Dave Chinnerd386b322013-08-12 20:49:31 +1000551static inline void xfs_sb_version_addprojid32bit(xfs_sb_t *sbp)
552{
553 sbp->sb_versionnum |= XFS_SB_VERSION_MOREBITSBIT;
554 sbp->sb_features2 |= XFS_SB_VERSION2_PROJID32BIT;
555 sbp->sb_bad_features2 |= XFS_SB_VERSION2_PROJID32BIT;
556}
557
Dave Chinnere721f502013-04-03 16:11:32 +1100558/*
559 * Extended v5 superblock feature masks. These are to be used for new v5
560 * superblock features only.
561 *
562 * Compat features are new features that old kernels will not notice or affect
563 * and so can mount read-write without issues.
564 *
565 * RO-Compat (read only) are features that old kernels can read but will break
566 * if they write. Hence only read-only mounts of such filesystems are allowed on
567 * kernels that don't support the feature bit.
568 *
569 * InCompat features are features which old kernels will not understand and so
570 * must not mount.
571 *
572 * Log-InCompat features are for changes to log formats or new transactions that
573 * can't be replayed on older kernels. The fields are set when the filesystem is
574 * mounted, and a clean unmount clears the fields.
575 */
576#define XFS_SB_FEAT_COMPAT_ALL 0
577#define XFS_SB_FEAT_COMPAT_UNKNOWN ~XFS_SB_FEAT_COMPAT_ALL
578static inline bool
579xfs_sb_has_compat_feature(
580 struct xfs_sb *sbp,
581 __uint32_t feature)
582{
583 return (sbp->sb_features_compat & feature) != 0;
584}
585
586#define XFS_SB_FEAT_RO_COMPAT_ALL 0
587#define XFS_SB_FEAT_RO_COMPAT_UNKNOWN ~XFS_SB_FEAT_RO_COMPAT_ALL
588static inline bool
589xfs_sb_has_ro_compat_feature(
590 struct xfs_sb *sbp,
591 __uint32_t feature)
592{
593 return (sbp->sb_features_ro_compat & feature) != 0;
594}
595
Dave Chinner0cb97762013-08-12 20:50:09 +1000596#define XFS_SB_FEAT_INCOMPAT_FTYPE (1 << 0) /* filetype in dirent */
Dave Chinnere721f502013-04-03 16:11:32 +1100597#define XFS_SB_FEAT_INCOMPAT_ALL 0
Dave Chinner0cb97762013-08-12 20:50:09 +1000598
Dave Chinnere721f502013-04-03 16:11:32 +1100599#define XFS_SB_FEAT_INCOMPAT_UNKNOWN ~XFS_SB_FEAT_INCOMPAT_ALL
600static inline bool
601xfs_sb_has_incompat_feature(
602 struct xfs_sb *sbp,
603 __uint32_t feature)
604{
605 return (sbp->sb_features_incompat & feature) != 0;
606}
607
608#define XFS_SB_FEAT_INCOMPAT_LOG_ALL 0
609#define XFS_SB_FEAT_INCOMPAT_LOG_UNKNOWN ~XFS_SB_FEAT_INCOMPAT_LOG_ALL
610static inline bool
611xfs_sb_has_incompat_log_feature(
612 struct xfs_sb *sbp,
613 __uint32_t feature)
614{
615 return (sbp->sb_features_log_incompat & feature) != 0;
616}
617
Dave Chinner0cb97762013-08-12 20:50:09 +1000618/*
619 * V5 superblock specific feature checks
620 */
621static inline int xfs_sb_version_hascrc(xfs_sb_t *sbp)
622{
623 return XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_5;
624}
625
Chandra Seetharamand892d582013-07-19 17:36:02 -0500626static inline int xfs_sb_version_has_pquotino(xfs_sb_t *sbp)
Chandra Seetharaman9cad19d2013-06-27 17:25:04 -0500627{
Chandra Seetharamand892d582013-07-19 17:36:02 -0500628 return XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_5;
Chandra Seetharaman9cad19d2013-06-27 17:25:04 -0500629}
630
Dave Chinner0cb97762013-08-12 20:50:09 +1000631static inline int xfs_sb_version_hasftype(struct xfs_sb *sbp)
632{
633 return XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_5 &&
634 xfs_sb_has_incompat_feature(sbp, XFS_SB_FEAT_INCOMPAT_FTYPE);
635}
636
Linus Torvalds1da177e2005-04-16 15:20:36 -0700637/*
638 * end of superblock version macros
639 */
640
Chandra Seetharamand892d582013-07-19 17:36:02 -0500641static inline bool
642xfs_is_quota_inode(struct xfs_sb *sbp, xfs_ino_t ino)
643{
644 return (ino == sbp->sb_uquotino ||
645 ino == sbp->sb_gquotino ||
646 ino == sbp->sb_pquotino);
647}
648
Nathan Scotta844f452005-11-02 14:38:42 +1100649#define XFS_SB_DADDR ((xfs_daddr_t)0) /* daddr in filesystem/ag */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700650#define XFS_SB_BLOCK(mp) XFS_HDR_BLOCK(mp, XFS_SB_DADDR)
Chandra Seetharaman62926042011-07-22 23:40:15 +0000651#define XFS_BUF_TO_SBP(bp) ((xfs_dsb_t *)((bp)->b_addr))
Nathan Scotta844f452005-11-02 14:38:42 +1100652
653#define XFS_HDR_BLOCK(mp,d) ((xfs_agblock_t)XFS_BB_TO_FSBT(mp,d))
654#define XFS_DADDR_TO_FSB(mp,d) XFS_AGB_TO_FSB(mp, \
Eric Sandeenb6e32222009-01-14 23:22:07 -0600655 xfs_daddr_to_agno(mp,d), xfs_daddr_to_agbno(mp,d))
Nathan Scotta844f452005-11-02 14:38:42 +1100656#define XFS_FSB_TO_DADDR(mp,fsbno) XFS_AGB_TO_DADDR(mp, \
657 XFS_FSB_TO_AGNO(mp,fsbno), XFS_FSB_TO_AGBNO(mp,fsbno))
Linus Torvalds1da177e2005-04-16 15:20:36 -0700658
659/*
660 * File system sector to basic block conversions.
661 */
662#define XFS_FSS_TO_BB(mp,sec) ((sec) << (mp)->m_sectbb_log)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700663
664/*
665 * File system block to basic block conversions.
666 */
667#define XFS_FSB_TO_BB(mp,fsbno) ((fsbno) << (mp)->m_blkbb_log)
668#define XFS_BB_TO_FSB(mp,bb) \
669 (((bb) + (XFS_FSB_TO_BB(mp,1) - 1)) >> (mp)->m_blkbb_log)
670#define XFS_BB_TO_FSBT(mp,bb) ((bb) >> (mp)->m_blkbb_log)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700671
672/*
673 * File system block to byte conversions.
674 */
675#define XFS_FSB_TO_B(mp,fsbno) ((xfs_fsize_t)(fsbno) << (mp)->m_sb.sb_blocklog)
676#define XFS_B_TO_FSB(mp,b) \
677 ((((__uint64_t)(b)) + (mp)->m_blockmask) >> (mp)->m_sb.sb_blocklog)
678#define XFS_B_TO_FSBT(mp,b) (((__uint64_t)(b)) >> (mp)->m_sb.sb_blocklog)
679#define XFS_B_FSB_OFFSET(mp,b) ((b) & (mp)->m_blockmask)
680
Dave Chinnerff550682013-08-12 20:49:41 +1000681/*
682 * perag get/put wrappers for ref counting
683 */
684extern struct xfs_perag *xfs_perag_get(struct xfs_mount *, xfs_agnumber_t);
685extern struct xfs_perag *xfs_perag_get_tag(struct xfs_mount *, xfs_agnumber_t,
686 int tag);
687extern void xfs_perag_put(struct xfs_perag *pag);
688extern int xfs_initialize_perag_data(struct xfs_mount *, xfs_agnumber_t);
689
690extern void xfs_sb_calc_crc(struct xfs_buf *);
691extern void xfs_mod_sb(struct xfs_trans *, __int64_t);
692extern void xfs_sb_mount_common(struct xfs_mount *, struct xfs_sb *);
693extern void xfs_sb_from_disk(struct xfs_sb *, struct xfs_dsb *);
694extern void xfs_sb_to_disk(struct xfs_dsb *, struct xfs_sb *, __int64_t);
695extern void xfs_sb_quota_from_disk(struct xfs_sb *sbp);
696
697extern const struct xfs_buf_ops xfs_sb_buf_ops;
698extern const struct xfs_buf_ops xfs_sb_quiet_buf_ops;
699
Linus Torvalds1da177e2005-04-16 15:20:36 -0700700#endif /* __XFS_SB_H__ */