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