1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18#ifndef _H_JFS_DTREE
19#define _H_JFS_DTREE
20
21
22
23
24
25#include "jfs_btree.h"
26
27typedef union {
28 struct {
29 tid_t tid;
30 struct inode *ip;
31 u32 ino;
32 } leaf;
33 pxd_t xd;
34} ddata_t;
35
36
37
38
39
40
41
42
43
44
45
46
47struct dtslot {
48 s8 next;
49 s8 cnt;
50 __le16 name[15];
51};
52
53
54#define DATASLOTSIZE 16
55#define L2DATASLOTSIZE 4
56#define DTSLOTSIZE 32
57#define L2DTSLOTSIZE 5
58#define DTSLOTHDRSIZE 2
59#define DTSLOTDATASIZE 30
60#define DTSLOTDATALEN 15
61
62
63
64
65struct idtentry {
66 pxd_t xd;
67
68 s8 next;
69 u8 namlen;
70 __le16 name[11];
71};
72
73#define DTIHDRSIZE 10
74#define DTIHDRDATALEN 11
75
76
77#define NDTINTERNAL(klen) (DIV_ROUND_UP((4 + (klen)), 15))
78
79
80
81
82
83
84
85struct ldtentry {
86 __le32 inumber;
87 s8 next;
88 u8 namlen;
89 __le16 name[11];
90 __le32 index;
91};
92
93#define DTLHDRSIZE 6
94#define DTLHDRDATALEN_LEGACY 13
95#define DTLHDRDATALEN 11
96
97
98
99
100
101
102
103
104#define DO_INDEX(INODE) (JFS_SBI((INODE)->i_sb)->mntflag & JFS_DIR_INDEX)
105
106
107
108
109#define MAX_INLINE_DIRTABLE_ENTRY 13
110
111struct dir_table_slot {
112 u8 rsrvd;
113 u8 flag;
114 u8 slot;
115 u8 addr1;
116 __le32 addr2;
117
118};
119
120
121
122
123#define DIR_INDEX_VALID 1
124#define DIR_INDEX_FREE 0
125
126#define DTSaddress(dir_table_slot, address64)\
127{\
128 (dir_table_slot)->addr1 = ((u64)address64) >> 32;\
129 (dir_table_slot)->addr2 = __cpu_to_le32((address64) & 0xffffffff);\
130}
131
132#define addressDTS(dts)\
133 ( ((s64)((dts)->addr1)) << 32 | __le32_to_cpu((dts)->addr2) )
134
135
136#define NDTLEAF_LEGACY(klen) (DIV_ROUND_UP((2 + (klen)), 15))
137#define NDTLEAF NDTINTERNAL
138
139
140
141
142
143
144
145typedef union {
146 struct {
147 struct dasd DASD;
148
149 u8 flag;
150 u8 nextindex;
151 s8 freecnt;
152 s8 freelist;
153
154 __le32 idotdot;
155
156 s8 stbl[8];
157 } header;
158
159 struct dtslot slot[9];
160} dtroot_t;
161
162#define PARENT(IP) \
163 (le32_to_cpu(JFS_IP(IP)->i_dtroot.header.idotdot))
164
165#define DTROOTMAXSLOT 9
166
167#define dtEmpty(IP) (JFS_IP(IP)->i_dtroot.header.nextindex == 0)
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193typedef union {
194 struct {
195 __le64 next;
196 __le64 prev;
197
198 u8 flag;
199 u8 nextindex;
200 s8 freecnt;
201 s8 freelist;
202
203 u8 maxslot;
204 u8 stblindex;
205 u8 rsrvd[2];
206
207 pxd_t self;
208 } header;
209
210 struct dtslot slot[128];
211} dtpage_t;
212
213#define DTPAGEMAXSLOT 128
214
215#define DT8THPGNODEBYTES 512
216#define DT8THPGNODETSLOTS 1
217#define DT8THPGNODESLOTS 16
218
219#define DTQTRPGNODEBYTES 1024
220#define DTQTRPGNODETSLOTS 1
221#define DTQTRPGNODESLOTS 32
222
223#define DTHALFPGNODEBYTES 2048
224#define DTHALFPGNODETSLOTS 2
225#define DTHALFPGNODESLOTS 64
226
227#define DTFULLPGNODEBYTES 4096
228#define DTFULLPGNODETSLOTS 4
229#define DTFULLPGNODESLOTS 128
230
231#define DTENTRYSTART 1
232
233
234#define DT_GETSTBL(p) ( ((p)->header.flag & BT_ROOT) ?\
235 ((dtroot_t *)(p))->header.stbl : \
236 (s8 *)&(p)->slot[(p)->header.stblindex] )
237
238
239
240
241#define JFS_CREATE 1
242#define JFS_LOOKUP 2
243#define JFS_REMOVE 3
244#define JFS_RENAME 4
245
246
247
248
249#define DIREND INT_MAX
250
251
252
253
254extern void dtInitRoot(tid_t tid, struct inode *ip, u32 idotdot);
255
256extern int dtSearch(struct inode *ip, struct component_name * key,
257 ino_t * data, struct btstack * btstack, int flag);
258
259extern int dtInsert(tid_t tid, struct inode *ip, struct component_name * key,
260 ino_t * ino, struct btstack * btstack);
261
262extern int dtDelete(tid_t tid, struct inode *ip, struct component_name * key,
263 ino_t * data, int flag);
264
265extern int dtModify(tid_t tid, struct inode *ip, struct component_name * key,
266 ino_t * orig_ino, ino_t new_ino, int flag);
267
268extern int jfs_readdir(struct file *file, struct dir_context *ctx);
269#endif
270