This source file includes following definitions.
- TREEMAX
1
2
3
4
5 #ifndef _H_JFS_DMAP
6 #define _H_JFS_DMAP
7
8 #include "jfs_txnmgr.h"
9
10 #define BMAPVERSION 1
11 #define TREESIZE (256+64+16+4+1)
12 #define LEAFIND (64+16+4+1)
13 #define LPERDMAP 256
14 #define L2LPERDMAP 8
15 #define DBWORD 32
16 #define L2DBWORD 5
17 #define BUDMIN L2DBWORD
18 #define BPERDMAP (LPERDMAP * DBWORD)
19 #define L2BPERDMAP 13
20 #define CTLTREESIZE (1024+256+64+16+4+1)
21 #define CTLLEAFIND (256+64+16+4+1)
22 #define LPERCTL 1024
23 #define L2LPERCTL 10
24 #define ROOT 0
25 #define NOFREE ((s8) -1)
26 #define MAXAG 128
27 #define L2MAXAG 7
28 #define L2MINAGSZ 25
29 #define BMAPBLKNO 0
30
31
32
33
34 #define L2MAXL0SIZE (L2BPERDMAP + 1 * L2LPERCTL)
35 #define L2MAXL1SIZE (L2BPERDMAP + 2 * L2LPERCTL)
36 #define L2MAXL2SIZE (L2BPERDMAP + 3 * L2LPERCTL)
37
38
39
40
41 #define MAXL0SIZE ((s64)1 << L2MAXL0SIZE)
42 #define MAXL1SIZE ((s64)1 << L2MAXL1SIZE)
43 #define MAXL2SIZE ((s64)1 << L2MAXL2SIZE)
44
45 #define MAXMAPSIZE MAXL2SIZE
46
47
48
49
50
51 static inline signed char TREEMAX(signed char *cp)
52 {
53 signed char tmp1, tmp2;
54
55 tmp1 = max(*(cp+2), *(cp+3));
56 tmp2 = max(*(cp), *(cp+1));
57
58 return max(tmp1, tmp2);
59 }
60
61
62
63
64
65
66
67
68
69
70
71
72 #define BLKTODMAP(b,s) \
73 ((((b) >> 13) + ((b) >> 23) + ((b) >> 33) + 3 + 1) << (s))
74
75
76
77
78
79
80
81
82
83
84
85
86
87 #define BLKTOL0(b,s) \
88 (((((b) >> 23) << 10) + ((b) >> 23) + ((b) >> 33) + 2 + 1) << (s))
89
90
91
92
93
94
95
96
97
98
99
100
101
102 #define BLKTOL1(b,s) \
103 (((((b) >> 33) << 20) + (((b) >> 33) << 10) + ((b) >> 33) + 1 + 1) << (s))
104
105
106
107
108
109 #define BLKTOCTL(b,s,l) \
110 (((l) == 2) ? 1 : ((l) == 1) ? BLKTOL1((b),(s)) : BLKTOL0((b),(s)))
111
112
113
114
115
116 #define BMAPSZTOLEV(size) \
117 (((size) <= MAXL0SIZE) ? 0 : ((size) <= MAXL1SIZE) ? 1 : 2)
118
119
120
121 #define BLKTOAG(b,sbi) ((b) >> ((sbi)->bmap->db_agl2size))
122
123
124
125
126 #define AGTOBLK(a,ip) \
127 ((s64)(a) << (JFS_SBI((ip)->i_sb)->bmap->db_agl2size))
128
129
130
131
132
133
134 struct dmaptree {
135 __le32 nleafs;
136 __le32 l2nleafs;
137 __le32 leafidx;
138 __le32 height;
139 s8 budmin;
140 s8 stree[TREESIZE];
141 u8 pad[2];
142 };
143
144
145
146
147 struct dmap {
148 __le32 nblocks;
149 __le32 nfree;
150 __le64 start;
151 struct dmaptree tree;
152 u8 pad[1672];
153 __le32 wmap[LPERDMAP];
154 __le32 pmap[LPERDMAP];
155 };
156
157
158
159
160
161
162 struct dmapctl {
163 __le32 nleafs;
164 __le32 l2nleafs;
165 __le32 leafidx;
166 __le32 height;
167 s8 budmin;
168 s8 stree[CTLTREESIZE];
169 u8 pad[2714];
170 };
171
172
173
174
175 typedef union dmtree {
176 struct dmaptree t1;
177 struct dmapctl t2;
178 } dmtree_t;
179
180
181 #define dmt_nleafs t1.nleafs
182 #define dmt_l2nleafs t1.l2nleafs
183 #define dmt_leafidx t1.leafidx
184 #define dmt_height t1.height
185 #define dmt_budmin t1.budmin
186 #define dmt_stree t1.stree
187
188
189
190
191 struct dbmap_disk {
192 __le64 dn_mapsize;
193 __le64 dn_nfree;
194 __le32 dn_l2nbperpage;
195 __le32 dn_numag;
196 __le32 dn_maxlevel;
197 __le32 dn_maxag;
198 __le32 dn_agpref;
199 __le32 dn_aglevel;
200 __le32 dn_agheight;
201 __le32 dn_agwidth;
202 __le32 dn_agstart;
203 __le32 dn_agl2size;
204 __le64 dn_agfree[MAXAG];
205 __le64 dn_agsize;
206 s8 dn_maxfreebud;
207 u8 pad[3007];
208 };
209
210 struct dbmap {
211 s64 dn_mapsize;
212 s64 dn_nfree;
213 int dn_l2nbperpage;
214 int dn_numag;
215 int dn_maxlevel;
216 int dn_maxag;
217 int dn_agpref;
218 int dn_aglevel;
219 int dn_agheight;
220 int dn_agwidth;
221 int dn_agstart;
222 int dn_agl2size;
223 s64 dn_agfree[MAXAG];
224 s64 dn_agsize;
225 signed char dn_maxfreebud;
226 };
227
228
229
230 struct bmap {
231 struct dbmap db_bmap;
232 struct inode *db_ipbmap;
233 struct mutex db_bmaplock;
234 atomic_t db_active[MAXAG];
235 u32 *db_DBmap;
236 };
237
238
239 #define db_mapsize db_bmap.dn_mapsize
240 #define db_nfree db_bmap.dn_nfree
241 #define db_agfree db_bmap.dn_agfree
242 #define db_agsize db_bmap.dn_agsize
243 #define db_agl2size db_bmap.dn_agl2size
244 #define db_agwidth db_bmap.dn_agwidth
245 #define db_agheight db_bmap.dn_agheight
246 #define db_agstart db_bmap.dn_agstart
247 #define db_numag db_bmap.dn_numag
248 #define db_maxlevel db_bmap.dn_maxlevel
249 #define db_aglevel db_bmap.dn_aglevel
250 #define db_agpref db_bmap.dn_agpref
251 #define db_maxag db_bmap.dn_maxag
252 #define db_maxfreebud db_bmap.dn_maxfreebud
253 #define db_l2nbperpage db_bmap.dn_l2nbperpage
254
255
256
257
258
259
260
261
262 #define BLKSTOL2(d) (blkstol2(d))
263
264
265 #define NLSTOL2BSZ(n) (31 - cntlz((n)) + BUDMIN)
266
267
268 #define LITOL2BSZ(n,m,b) ((((n) == 0) ? (m) : cnttz((n))) + (b))
269
270
271 #define BLKTOCTLLEAF(b,m) \
272 (((b) & (((s64)1 << ((m) + L2LPERCTL)) - 1)) >> (m))
273
274
275 #define BUDSIZE(s,m) (1 << ((s) - (m)))
276
277
278
279
280 extern int dbMount(struct inode *ipbmap);
281
282 extern int dbUnmount(struct inode *ipbmap, int mounterror);
283
284 extern int dbFree(struct inode *ipbmap, s64 blkno, s64 nblocks);
285
286 extern int dbUpdatePMap(struct inode *ipbmap,
287 int free, s64 blkno, s64 nblocks, struct tblock * tblk);
288
289 extern int dbNextAG(struct inode *ipbmap);
290
291 extern int dbAlloc(struct inode *ipbmap, s64 hint, s64 nblocks, s64 * results);
292
293 extern int dbReAlloc(struct inode *ipbmap,
294 s64 blkno, s64 nblocks, s64 addnblocks, s64 * results);
295
296 extern int dbSync(struct inode *ipbmap);
297 extern int dbAllocBottomUp(struct inode *ip, s64 blkno, s64 nblocks);
298 extern int dbExtendFS(struct inode *ipbmap, s64 blkno, s64 nblocks);
299 extern void dbFinalizeBmap(struct inode *ipbmap);
300 extern s64 dbMapFileSizeToMapSize(struct inode *ipbmap);
301 extern s64 dbDiscardAG(struct inode *ip, int agno, s64 minlen);
302
303 #endif