aboutsummaryrefslogtreecommitdiffstats
path: root/fs/xfs/xfs_ag.h
diff options
context:
space:
mode:
Diffstat (limited to 'fs/xfs/xfs_ag.h')
-rw-r--r--fs/xfs/xfs_ag.h242
1 files changed, 64 insertions, 178 deletions
diff --git a/fs/xfs/xfs_ag.h b/fs/xfs/xfs_ag.h
index 96b70f7fba39..a96e2ffce0cc 100644
--- a/fs/xfs/xfs_ag.h
+++ b/fs/xfs/xfs_ag.h
@@ -1,33 +1,19 @@
1/* 1/*
2 * Copyright (c) 2000-2003 Silicon Graphics, Inc. All Rights Reserved. 2 * Copyright (c) 2000-2003,2005 Silicon Graphics, Inc.
3 * All Rights Reserved.
3 * 4 *
4 * This program is free software; you can redistribute it and/or modify it 5 * This program is free software; you can redistribute it and/or
5 * under the terms of version 2 of the GNU General Public License as 6 * modify it under the terms of the GNU General Public License as
6 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
7 * 8 *
8 * This program is distributed in the hope that it would be useful, but 9 * This program is distributed in the hope that it would be useful,
9 * WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
11 * 13 *
12 * Further, this software is distributed without any warranty that it is 14 * You should have received a copy of the GNU General Public License
13 * free of the rightful claim of any third person regarding infringement 15 * along with this program; if not, write the Free Software Foundation,
14 * or the like. Any license provided herein, whether implied or 16 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
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, write the Free Software Foundation, Inc., 59
21 * Temple Place - Suite 330, Boston MA 02111-1307, USA.
22 *
23 * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
24 * Mountain View, CA 94043, or:
25 *
26 * http://www.sgi.com
27 *
28 * For further information regarding this notice, see:
29 *
30 * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
31 */ 17 */
32#ifndef __XFS_AG_H__ 18#ifndef __XFS_AG_H__
33#define __XFS_AG_H__ 19#define __XFS_AG_H__
@@ -46,18 +32,9 @@ struct xfs_trans;
46#define XFS_AGI_MAGIC 0x58414749 /* 'XAGI' */ 32#define XFS_AGI_MAGIC 0x58414749 /* 'XAGI' */
47#define XFS_AGF_VERSION 1 33#define XFS_AGF_VERSION 1
48#define XFS_AGI_VERSION 1 34#define XFS_AGI_VERSION 1
49#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_AGF_GOOD_VERSION) 35
50int xfs_agf_good_version(unsigned v); 36#define XFS_AGF_GOOD_VERSION(v) ((v) == XFS_AGF_VERSION)
51#define XFS_AGF_GOOD_VERSION(v) xfs_agf_good_version(v) 37#define XFS_AGI_GOOD_VERSION(v) ((v) == XFS_AGI_VERSION)
52#else
53#define XFS_AGF_GOOD_VERSION(v) ((v) == XFS_AGF_VERSION)
54#endif
55#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_AGI_GOOD_VERSION)
56int xfs_agi_good_version(unsigned v);
57#define XFS_AGI_GOOD_VERSION(v) xfs_agi_good_version(v)
58#else
59#define XFS_AGI_GOOD_VERSION(v) ((v) == XFS_AGI_VERSION)
60#endif
61 38
62/* 39/*
63 * Btree number 0 is bno, 1 is cnt. This value gives the size of the 40 * Btree number 0 is bno, 1 is cnt. This value gives the size of the
@@ -71,27 +48,26 @@ int xfs_agi_good_version(unsigned v);
71 * are > 64k, our value cannot be confused for an EFS superblock's. 48 * are > 64k, our value cannot be confused for an EFS superblock's.
72 */ 49 */
73 50
74typedef struct xfs_agf 51typedef struct xfs_agf {
75{
76 /* 52 /*
77 * Common allocation group header information 53 * Common allocation group header information
78 */ 54 */
79 __uint32_t agf_magicnum; /* magic number == XFS_AGF_MAGIC */ 55 __be32 agf_magicnum; /* magic number == XFS_AGF_MAGIC */
80 __uint32_t agf_versionnum; /* header version == XFS_AGF_VERSION */ 56 __be32 agf_versionnum; /* header version == XFS_AGF_VERSION */
81 xfs_agnumber_t agf_seqno; /* sequence # starting from 0 */ 57 __be32 agf_seqno; /* sequence # starting from 0 */
82 xfs_agblock_t agf_length; /* size in blocks of a.g. */ 58 __be32 agf_length; /* size in blocks of a.g. */
83 /* 59 /*
84 * Freespace information 60 * Freespace information
85 */ 61 */
86 xfs_agblock_t agf_roots[XFS_BTNUM_AGF]; /* root blocks */ 62 __be32 agf_roots[XFS_BTNUM_AGF]; /* root blocks */
87 __uint32_t agf_spare0; /* spare field */ 63 __be32 agf_spare0; /* spare field */
88 __uint32_t agf_levels[XFS_BTNUM_AGF]; /* btree levels */ 64 __be32 agf_levels[XFS_BTNUM_AGF]; /* btree levels */
89 __uint32_t agf_spare1; /* spare field */ 65 __be32 agf_spare1; /* spare field */
90 __uint32_t agf_flfirst; /* first freelist block's index */ 66 __be32 agf_flfirst; /* first freelist block's index */
91 __uint32_t agf_fllast; /* last freelist block's index */ 67 __be32 agf_fllast; /* last freelist block's index */
92 __uint32_t agf_flcount; /* count of blocks in freelist */ 68 __be32 agf_flcount; /* count of blocks in freelist */
93 xfs_extlen_t agf_freeblks; /* total free blocks */ 69 __be32 agf_freeblks; /* total free blocks */
94 xfs_extlen_t agf_longest; /* longest free space */ 70 __be32 agf_longest; /* longest free space */
95} xfs_agf_t; 71} xfs_agf_t;
96 72
97#define XFS_AGF_MAGICNUM 0x00000001 73#define XFS_AGF_MAGICNUM 0x00000001
@@ -110,43 +86,39 @@ typedef struct xfs_agf
110 86
111/* disk block (xfs_daddr_t) in the AG */ 87/* disk block (xfs_daddr_t) in the AG */
112#define XFS_AGF_DADDR(mp) ((xfs_daddr_t)(1 << (mp)->m_sectbb_log)) 88#define XFS_AGF_DADDR(mp) ((xfs_daddr_t)(1 << (mp)->m_sectbb_log))
113#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_AGF_BLOCK) 89#define XFS_AGF_BLOCK(mp) XFS_HDR_BLOCK(mp, XFS_AGF_DADDR(mp))
114xfs_agblock_t xfs_agf_block(struct xfs_mount *mp); 90#define XFS_BUF_TO_AGF(bp) ((xfs_agf_t *)XFS_BUF_PTR(bp))
115#define XFS_AGF_BLOCK(mp) xfs_agf_block(mp) 91
116#else
117#define XFS_AGF_BLOCK(mp) XFS_HDR_BLOCK(mp, XFS_AGF_DADDR(mp))
118#endif
119 92
120/* 93/*
121 * Size of the unlinked inode hash table in the agi. 94 * Size of the unlinked inode hash table in the agi.
122 */ 95 */
123#define XFS_AGI_UNLINKED_BUCKETS 64 96#define XFS_AGI_UNLINKED_BUCKETS 64
124 97
125typedef struct xfs_agi 98typedef struct xfs_agi {
126{
127 /* 99 /*
128 * Common allocation group header information 100 * Common allocation group header information
129 */ 101 */
130 __uint32_t agi_magicnum; /* magic number == XFS_AGI_MAGIC */ 102 __be32 agi_magicnum; /* magic number == XFS_AGI_MAGIC */
131 __uint32_t agi_versionnum; /* header version == XFS_AGI_VERSION */ 103 __be32 agi_versionnum; /* header version == XFS_AGI_VERSION */
132 xfs_agnumber_t agi_seqno; /* sequence # starting from 0 */ 104 __be32 agi_seqno; /* sequence # starting from 0 */
133 xfs_agblock_t agi_length; /* size in blocks of a.g. */ 105 __be32 agi_length; /* size in blocks of a.g. */
134 /* 106 /*
135 * Inode information 107 * Inode information
136 * Inodes are mapped by interpreting the inode number, so no 108 * Inodes are mapped by interpreting the inode number, so no
137 * mapping data is needed here. 109 * mapping data is needed here.
138 */ 110 */
139 xfs_agino_t agi_count; /* count of allocated inodes */ 111 __be32 agi_count; /* count of allocated inodes */
140 xfs_agblock_t agi_root; /* root of inode btree */ 112 __be32 agi_root; /* root of inode btree */
141 __uint32_t agi_level; /* levels in inode btree */ 113 __be32 agi_level; /* levels in inode btree */
142 xfs_agino_t agi_freecount; /* number of free inodes */ 114 __be32 agi_freecount; /* number of free inodes */
143 xfs_agino_t agi_newino; /* new inode just allocated */ 115 __be32 agi_newino; /* new inode just allocated */
144 xfs_agino_t agi_dirino; /* last directory inode chunk */ 116 __be32 agi_dirino; /* last directory inode chunk */
145 /* 117 /*
146 * Hash table of inodes which have been unlinked but are 118 * Hash table of inodes which have been unlinked but are
147 * still being referenced. 119 * still being referenced.
148 */ 120 */
149 xfs_agino_t agi_unlinked[XFS_AGI_UNLINKED_BUCKETS]; 121 __be32 agi_unlinked[XFS_AGI_UNLINKED_BUCKETS];
150} xfs_agi_t; 122} xfs_agi_t;
151 123
152#define XFS_AGI_MAGICNUM 0x00000001 124#define XFS_AGI_MAGICNUM 0x00000001
@@ -165,25 +137,17 @@ typedef struct xfs_agi
165 137
166/* disk block (xfs_daddr_t) in the AG */ 138/* disk block (xfs_daddr_t) in the AG */
167#define XFS_AGI_DADDR(mp) ((xfs_daddr_t)(2 << (mp)->m_sectbb_log)) 139#define XFS_AGI_DADDR(mp) ((xfs_daddr_t)(2 << (mp)->m_sectbb_log))
168#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_AGI_BLOCK) 140#define XFS_AGI_BLOCK(mp) XFS_HDR_BLOCK(mp, XFS_AGI_DADDR(mp))
169xfs_agblock_t xfs_agi_block(struct xfs_mount *mp); 141#define XFS_BUF_TO_AGI(bp) ((xfs_agi_t *)XFS_BUF_PTR(bp))
170#define XFS_AGI_BLOCK(mp) xfs_agi_block(mp)
171#else
172#define XFS_AGI_BLOCK(mp) XFS_HDR_BLOCK(mp, XFS_AGI_DADDR(mp))
173#endif
174 142
175/* 143/*
176 * The third a.g. block contains the a.g. freelist, an array 144 * The third a.g. block contains the a.g. freelist, an array
177 * of block pointers to blocks owned by the allocation btree code. 145 * of block pointers to blocks owned by the allocation btree code.
178 */ 146 */
179#define XFS_AGFL_DADDR(mp) ((xfs_daddr_t)(3 << (mp)->m_sectbb_log)) 147#define XFS_AGFL_DADDR(mp) ((xfs_daddr_t)(3 << (mp)->m_sectbb_log))
180#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_AGFL_BLOCK) 148#define XFS_AGFL_BLOCK(mp) XFS_HDR_BLOCK(mp, XFS_AGFL_DADDR(mp))
181xfs_agblock_t xfs_agfl_block(struct xfs_mount *mp);
182#define XFS_AGFL_BLOCK(mp) xfs_agfl_block(mp)
183#else
184#define XFS_AGFL_BLOCK(mp) XFS_HDR_BLOCK(mp, XFS_AGFL_DADDR(mp))
185#endif
186#define XFS_AGFL_SIZE(mp) ((mp)->m_sb.sb_sectsize / sizeof(xfs_agblock_t)) 149#define XFS_AGFL_SIZE(mp) ((mp)->m_sb.sb_sectsize / sizeof(xfs_agblock_t))
150#define XFS_BUF_TO_AGFL(bp) ((xfs_agfl_t *)XFS_BUF_PTR(bp))
187 151
188typedef struct xfs_agfl { 152typedef struct xfs_agfl {
189 xfs_agblock_t agfl_bno[1]; /* actually XFS_AGFL_SIZE(mp) */ 153 xfs_agblock_t agfl_bno[1]; /* actually XFS_AGFL_SIZE(mp) */
@@ -230,116 +194,38 @@ typedef struct xfs_perag
230 xfs_perag_busy_t *pagb_list; /* unstable blocks */ 194 xfs_perag_busy_t *pagb_list; /* unstable blocks */
231} xfs_perag_t; 195} xfs_perag_t;
232 196
233#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_AG_MAXLEVELS) 197#define XFS_AG_MAXLEVELS(mp) ((mp)->m_ag_maxlevels)
234int xfs_ag_maxlevels(struct xfs_mount *mp);
235#define XFS_AG_MAXLEVELS(mp) xfs_ag_maxlevels(mp)
236#else
237#define XFS_AG_MAXLEVELS(mp) ((mp)->m_ag_maxlevels)
238#endif
239#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_MIN_FREELIST)
240int xfs_min_freelist(xfs_agf_t *a, struct xfs_mount *mp);
241#define XFS_MIN_FREELIST(a,mp) xfs_min_freelist(a,mp)
242#else
243#define XFS_MIN_FREELIST(a,mp) \
244 XFS_MIN_FREELIST_RAW( \
245 INT_GET((a)->agf_levels[XFS_BTNUM_BNOi], ARCH_CONVERT), \
246 INT_GET((a)->agf_levels[XFS_BTNUM_CNTi], ARCH_CONVERT), mp)
247#endif
248#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_MIN_FREELIST_PAG)
249int xfs_min_freelist_pag(xfs_perag_t *pag, struct xfs_mount *mp);
250#define XFS_MIN_FREELIST_PAG(pag,mp) xfs_min_freelist_pag(pag,mp)
251#else
252#define XFS_MIN_FREELIST_PAG(pag,mp) \
253 XFS_MIN_FREELIST_RAW((uint_t)(pag)->pagf_levels[XFS_BTNUM_BNOi], \
254 (uint_t)(pag)->pagf_levels[XFS_BTNUM_CNTi], mp)
255#endif
256#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_MIN_FREELIST_RAW)
257int xfs_min_freelist_raw(int bl, int cl, struct xfs_mount *mp);
258#define XFS_MIN_FREELIST_RAW(bl,cl,mp) xfs_min_freelist_raw(bl,cl,mp)
259#else
260#define XFS_MIN_FREELIST_RAW(bl,cl,mp) \ 198#define XFS_MIN_FREELIST_RAW(bl,cl,mp) \
261 (MIN(bl + 1, XFS_AG_MAXLEVELS(mp)) + \ 199 (MIN(bl + 1, XFS_AG_MAXLEVELS(mp)) + MIN(cl + 1, XFS_AG_MAXLEVELS(mp)))
262 MIN(cl + 1, XFS_AG_MAXLEVELS(mp))) 200#define XFS_MIN_FREELIST(a,mp) \
263#endif 201 (XFS_MIN_FREELIST_RAW( \
202 be32_to_cpu((a)->agf_levels[XFS_BTNUM_BNOi]), \
203 be32_to_cpu((a)->agf_levels[XFS_BTNUM_CNTi]), mp))
204#define XFS_MIN_FREELIST_PAG(pag,mp) \
205 (XFS_MIN_FREELIST_RAW( \
206 (uint_t)(pag)->pagf_levels[XFS_BTNUM_BNOi], \
207 (uint_t)(pag)->pagf_levels[XFS_BTNUM_CNTi], mp))
264 208
265#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_AGB_TO_FSB) 209#define XFS_AGB_TO_FSB(mp,agno,agbno) \
266xfs_fsblock_t xfs_agb_to_fsb(struct xfs_mount *mp, xfs_agnumber_t agno,
267 xfs_agblock_t agbno);
268#define XFS_AGB_TO_FSB(mp,agno,agbno) xfs_agb_to_fsb(mp,agno,agbno)
269#else
270#define XFS_AGB_TO_FSB(mp,agno,agbno) \
271 (((xfs_fsblock_t)(agno) << (mp)->m_sb.sb_agblklog) | (agbno)) 210 (((xfs_fsblock_t)(agno) << (mp)->m_sb.sb_agblklog) | (agbno))
272#endif 211#define XFS_FSB_TO_AGNO(mp,fsbno) \
273#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_FSB_TO_AGNO)
274xfs_agnumber_t xfs_fsb_to_agno(struct xfs_mount *mp, xfs_fsblock_t fsbno);
275#define XFS_FSB_TO_AGNO(mp,fsbno) xfs_fsb_to_agno(mp,fsbno)
276#else
277#define XFS_FSB_TO_AGNO(mp,fsbno) \
278 ((xfs_agnumber_t)((fsbno) >> (mp)->m_sb.sb_agblklog)) 212 ((xfs_agnumber_t)((fsbno) >> (mp)->m_sb.sb_agblklog))
279#endif 213#define XFS_FSB_TO_AGBNO(mp,fsbno) \
280#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_FSB_TO_AGBNO)
281xfs_agblock_t xfs_fsb_to_agbno(struct xfs_mount *mp, xfs_fsblock_t fsbno);
282#define XFS_FSB_TO_AGBNO(mp,fsbno) xfs_fsb_to_agbno(mp,fsbno)
283#else
284#define XFS_FSB_TO_AGBNO(mp,fsbno) \
285 ((xfs_agblock_t)((fsbno) & XFS_MASK32LO((mp)->m_sb.sb_agblklog))) 214 ((xfs_agblock_t)((fsbno) & XFS_MASK32LO((mp)->m_sb.sb_agblklog)))
286#endif 215#define XFS_AGB_TO_DADDR(mp,agno,agbno) \
287 216 ((xfs_daddr_t)XFS_FSB_TO_BB(mp, \
288#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_AGB_TO_DADDR) 217 (xfs_fsblock_t)(agno) * (mp)->m_sb.sb_agblocks + (agbno)))
289xfs_daddr_t xfs_agb_to_daddr(struct xfs_mount *mp, xfs_agnumber_t agno, 218#define XFS_AG_DADDR(mp,agno,d) (XFS_AGB_TO_DADDR(mp, agno, 0) + (d))
290 xfs_agblock_t agbno);
291#define XFS_AGB_TO_DADDR(mp,agno,agbno) xfs_agb_to_daddr(mp,agno,agbno)
292#else
293#define XFS_AGB_TO_DADDR(mp,agno,agbno) \
294 ((xfs_daddr_t)(XFS_FSB_TO_BB(mp, \
295 (xfs_fsblock_t)(agno) * (mp)->m_sb.sb_agblocks + (agbno))))
296#endif
297/*
298 * XFS_DADDR_TO_AGNO and XFS_DADDR_TO_AGBNO moved to xfs_mount.h
299 * to avoid header file ordering change
300 */
301
302#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_AG_DADDR)
303xfs_daddr_t xfs_ag_daddr(struct xfs_mount *mp, xfs_agnumber_t agno,
304 xfs_daddr_t d);
305#define XFS_AG_DADDR(mp,agno,d) xfs_ag_daddr(mp,agno,d)
306#else
307#define XFS_AG_DADDR(mp,agno,d) (XFS_AGB_TO_DADDR(mp, agno, 0) + (d))
308#endif
309
310#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_BUF_TO_AGF)
311xfs_agf_t *xfs_buf_to_agf(struct xfs_buf *bp);
312#define XFS_BUF_TO_AGF(bp) xfs_buf_to_agf(bp)
313#else
314#define XFS_BUF_TO_AGF(bp) ((xfs_agf_t *)XFS_BUF_PTR(bp))
315#endif
316#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_BUF_TO_AGI)
317xfs_agi_t *xfs_buf_to_agi(struct xfs_buf *bp);
318#define XFS_BUF_TO_AGI(bp) xfs_buf_to_agi(bp)
319#else
320#define XFS_BUF_TO_AGI(bp) ((xfs_agi_t *)XFS_BUF_PTR(bp))
321#endif
322#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_BUF_TO_AGFL)
323xfs_agfl_t *xfs_buf_to_agfl(struct xfs_buf *bp);
324#define XFS_BUF_TO_AGFL(bp) xfs_buf_to_agfl(bp)
325#else
326#define XFS_BUF_TO_AGFL(bp) ((xfs_agfl_t *)XFS_BUF_PTR(bp))
327#endif
328 219
329/* 220/*
330 * For checking for bad ranges of xfs_daddr_t's, covering multiple 221 * For checking for bad ranges of xfs_daddr_t's, covering multiple
331 * allocation groups or a single xfs_daddr_t that's a superblock copy. 222 * allocation groups or a single xfs_daddr_t that's a superblock copy.
332 */ 223 */
333#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_AG_CHECK_DADDR)
334void xfs_ag_check_daddr(struct xfs_mount *mp, xfs_daddr_t d, xfs_extlen_t len);
335#define XFS_AG_CHECK_DADDR(mp,d,len) xfs_ag_check_daddr(mp,d,len)
336#else
337#define XFS_AG_CHECK_DADDR(mp,d,len) \ 224#define XFS_AG_CHECK_DADDR(mp,d,len) \
338 ((len) == 1 ? \ 225 ((len) == 1 ? \
339 ASSERT((d) == XFS_SB_DADDR || \ 226 ASSERT((d) == XFS_SB_DADDR || \
340 XFS_DADDR_TO_AGBNO(mp, d) != XFS_SB_DADDR) : \ 227 XFS_DADDR_TO_AGBNO(mp, d) != XFS_SB_DADDR) : \
341 ASSERT(XFS_DADDR_TO_AGNO(mp, d) == \ 228 ASSERT(XFS_DADDR_TO_AGNO(mp, d) == \
342 XFS_DADDR_TO_AGNO(mp, (d) + (len) - 1))) 229 XFS_DADDR_TO_AGNO(mp, (d) + (len) - 1)))
343#endif
344 230
345#endif /* __XFS_AG_H__ */ 231#endif /* __XFS_AG_H__ */