diff options
Diffstat (limited to 'fs/xfs/xfs_dir2_leaf.h')
-rw-r--r-- | fs/xfs/xfs_dir2_leaf.h | 281 |
1 files changed, 0 insertions, 281 deletions
diff --git a/fs/xfs/xfs_dir2_leaf.h b/fs/xfs/xfs_dir2_leaf.h deleted file mode 100644 index 140281adc7e5..000000000000 --- a/fs/xfs/xfs_dir2_leaf.h +++ /dev/null | |||
@@ -1,281 +0,0 @@ | |||
1 | /* | ||
2 | * Copyright (c) 2000-2001,2005 Silicon Graphics, Inc. | ||
3 | * All Rights Reserved. | ||
4 | * | ||
5 | * This program is free software; you can redistribute it and/or | ||
6 | * modify it under the terms of the GNU General Public License as | ||
7 | * published by the Free Software Foundation. | ||
8 | * | ||
9 | * 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. | ||
13 | * | ||
14 | * 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 | ||
17 | */ | ||
18 | #ifndef __XFS_DIR2_LEAF_H__ | ||
19 | #define __XFS_DIR2_LEAF_H__ | ||
20 | |||
21 | /* | ||
22 | * Directory format 2, leaf block structures. | ||
23 | * | ||
24 | * A pure data block looks like the following drawing on disk: | ||
25 | * | ||
26 | * +---------------------------+ | ||
27 | * | xfs_dir2_leaf_hdr_t | | ||
28 | * +---------------------------+ | ||
29 | * | xfs_dir2_leaf_entry_t | | ||
30 | * | xfs_dir2_leaf_entry_t | | ||
31 | * | xfs_dir2_leaf_entry_t | | ||
32 | * | xfs_dir2_leaf_entry_t | | ||
33 | * | ... | | ||
34 | * +---------------------------+ | ||
35 | * | xfs_dir2_data_off_t | | ||
36 | * | xfs_dir2_data_off_t | | ||
37 | * | xfs_dir2_data_off_t | | ||
38 | * | ... | | ||
39 | * +---------------------------+ | ||
40 | * | xfs_dir2_leaf_tail_t | | ||
41 | * +---------------------------+ | ||
42 | * | ||
43 | * The bests (xfs_dir2_data_off_t members) and tail are at the end of the | ||
44 | * block for single-leaf only (magic = XFS_DIR2_LEAF1_MAGIC not | ||
45 | * XFS_DIR2_LEAFN_MAGIC). | ||
46 | * | ||
47 | * As all the entries are variable size structures the accessors in this | ||
48 | * file should be used to iterate over them. | ||
49 | */ | ||
50 | |||
51 | struct uio; | ||
52 | struct xfs_dabuf; | ||
53 | struct xfs_da_args; | ||
54 | struct xfs_inode; | ||
55 | struct xfs_mount; | ||
56 | struct xfs_trans; | ||
57 | |||
58 | /* | ||
59 | * Offset of the leaf/node space. First block in this space | ||
60 | * is the btree root. | ||
61 | */ | ||
62 | #define XFS_DIR2_LEAF_SPACE 1 | ||
63 | #define XFS_DIR2_LEAF_OFFSET (XFS_DIR2_LEAF_SPACE * XFS_DIR2_SPACE_SIZE) | ||
64 | #define XFS_DIR2_LEAF_FIRSTDB(mp) \ | ||
65 | xfs_dir2_byte_to_db(mp, XFS_DIR2_LEAF_OFFSET) | ||
66 | |||
67 | /* | ||
68 | * Offset in data space of a data entry. | ||
69 | */ | ||
70 | typedef __uint32_t xfs_dir2_dataptr_t; | ||
71 | #define XFS_DIR2_MAX_DATAPTR ((xfs_dir2_dataptr_t)0xffffffff) | ||
72 | #define XFS_DIR2_NULL_DATAPTR ((xfs_dir2_dataptr_t)0) | ||
73 | |||
74 | /* | ||
75 | * Leaf block header. | ||
76 | */ | ||
77 | typedef struct xfs_dir2_leaf_hdr { | ||
78 | xfs_da_blkinfo_t info; /* header for da routines */ | ||
79 | __be16 count; /* count of entries */ | ||
80 | __be16 stale; /* count of stale entries */ | ||
81 | } xfs_dir2_leaf_hdr_t; | ||
82 | |||
83 | /* | ||
84 | * Leaf block entry. | ||
85 | */ | ||
86 | typedef struct xfs_dir2_leaf_entry { | ||
87 | __be32 hashval; /* hash value of name */ | ||
88 | __be32 address; /* address of data entry */ | ||
89 | } xfs_dir2_leaf_entry_t; | ||
90 | |||
91 | /* | ||
92 | * Leaf block tail. | ||
93 | */ | ||
94 | typedef struct xfs_dir2_leaf_tail { | ||
95 | __be32 bestcount; | ||
96 | } xfs_dir2_leaf_tail_t; | ||
97 | |||
98 | /* | ||
99 | * Leaf block. | ||
100 | */ | ||
101 | typedef struct xfs_dir2_leaf { | ||
102 | xfs_dir2_leaf_hdr_t hdr; /* leaf header */ | ||
103 | xfs_dir2_leaf_entry_t ents[]; /* entries */ | ||
104 | } xfs_dir2_leaf_t; | ||
105 | |||
106 | /* | ||
107 | * DB blocks here are logical directory block numbers, not filesystem blocks. | ||
108 | */ | ||
109 | |||
110 | static inline int xfs_dir2_max_leaf_ents(struct xfs_mount *mp) | ||
111 | { | ||
112 | return (int)(((mp)->m_dirblksize - (uint)sizeof(xfs_dir2_leaf_hdr_t)) / | ||
113 | (uint)sizeof(xfs_dir2_leaf_entry_t)); | ||
114 | } | ||
115 | |||
116 | /* | ||
117 | * Get address of the bestcount field in the single-leaf block. | ||
118 | */ | ||
119 | static inline xfs_dir2_leaf_tail_t * | ||
120 | xfs_dir2_leaf_tail_p(struct xfs_mount *mp, xfs_dir2_leaf_t *lp) | ||
121 | { | ||
122 | return (xfs_dir2_leaf_tail_t *) | ||
123 | ((char *)(lp) + (mp)->m_dirblksize - | ||
124 | (uint)sizeof(xfs_dir2_leaf_tail_t)); | ||
125 | } | ||
126 | |||
127 | /* | ||
128 | * Get address of the bests array in the single-leaf block. | ||
129 | */ | ||
130 | static inline __be16 * | ||
131 | xfs_dir2_leaf_bests_p(xfs_dir2_leaf_tail_t *ltp) | ||
132 | { | ||
133 | return (__be16 *)ltp - be32_to_cpu(ltp->bestcount); | ||
134 | } | ||
135 | |||
136 | /* | ||
137 | * Convert dataptr to byte in file space | ||
138 | */ | ||
139 | static inline xfs_dir2_off_t | ||
140 | xfs_dir2_dataptr_to_byte(struct xfs_mount *mp, xfs_dir2_dataptr_t dp) | ||
141 | { | ||
142 | return (xfs_dir2_off_t)(dp) << XFS_DIR2_DATA_ALIGN_LOG; | ||
143 | } | ||
144 | |||
145 | /* | ||
146 | * Convert byte in file space to dataptr. It had better be aligned. | ||
147 | */ | ||
148 | static inline xfs_dir2_dataptr_t | ||
149 | xfs_dir2_byte_to_dataptr(struct xfs_mount *mp, xfs_dir2_off_t by) | ||
150 | { | ||
151 | return (xfs_dir2_dataptr_t)((by) >> XFS_DIR2_DATA_ALIGN_LOG); | ||
152 | } | ||
153 | |||
154 | /* | ||
155 | * Convert byte in space to (DB) block | ||
156 | */ | ||
157 | static inline xfs_dir2_db_t | ||
158 | xfs_dir2_byte_to_db(struct xfs_mount *mp, xfs_dir2_off_t by) | ||
159 | { | ||
160 | return (xfs_dir2_db_t)((by) >> \ | ||
161 | ((mp)->m_sb.sb_blocklog + (mp)->m_sb.sb_dirblklog)); | ||
162 | } | ||
163 | |||
164 | /* | ||
165 | * Convert dataptr to a block number | ||
166 | */ | ||
167 | static inline xfs_dir2_db_t | ||
168 | xfs_dir2_dataptr_to_db(struct xfs_mount *mp, xfs_dir2_dataptr_t dp) | ||
169 | { | ||
170 | return xfs_dir2_byte_to_db(mp, xfs_dir2_dataptr_to_byte(mp, dp)); | ||
171 | } | ||
172 | |||
173 | /* | ||
174 | * Convert byte in space to offset in a block | ||
175 | */ | ||
176 | static inline xfs_dir2_data_aoff_t | ||
177 | xfs_dir2_byte_to_off(struct xfs_mount *mp, xfs_dir2_off_t by) | ||
178 | { | ||
179 | return (xfs_dir2_data_aoff_t)((by) & \ | ||
180 | ((1 << ((mp)->m_sb.sb_blocklog + (mp)->m_sb.sb_dirblklog)) - 1)); | ||
181 | } | ||
182 | |||
183 | /* | ||
184 | * Convert dataptr to a byte offset in a block | ||
185 | */ | ||
186 | static inline xfs_dir2_data_aoff_t | ||
187 | xfs_dir2_dataptr_to_off(struct xfs_mount *mp, xfs_dir2_dataptr_t dp) | ||
188 | { | ||
189 | return xfs_dir2_byte_to_off(mp, xfs_dir2_dataptr_to_byte(mp, dp)); | ||
190 | } | ||
191 | |||
192 | /* | ||
193 | * Convert block and offset to byte in space | ||
194 | */ | ||
195 | static inline xfs_dir2_off_t | ||
196 | xfs_dir2_db_off_to_byte(struct xfs_mount *mp, xfs_dir2_db_t db, | ||
197 | xfs_dir2_data_aoff_t o) | ||
198 | { | ||
199 | return ((xfs_dir2_off_t)(db) << \ | ||
200 | ((mp)->m_sb.sb_blocklog + (mp)->m_sb.sb_dirblklog)) + (o); | ||
201 | } | ||
202 | |||
203 | /* | ||
204 | * Convert block (DB) to block (dablk) | ||
205 | */ | ||
206 | static inline xfs_dablk_t | ||
207 | xfs_dir2_db_to_da(struct xfs_mount *mp, xfs_dir2_db_t db) | ||
208 | { | ||
209 | return (xfs_dablk_t)((db) << (mp)->m_sb.sb_dirblklog); | ||
210 | } | ||
211 | |||
212 | /* | ||
213 | * Convert byte in space to (DA) block | ||
214 | */ | ||
215 | static inline xfs_dablk_t | ||
216 | xfs_dir2_byte_to_da(struct xfs_mount *mp, xfs_dir2_off_t by) | ||
217 | { | ||
218 | return xfs_dir2_db_to_da(mp, xfs_dir2_byte_to_db(mp, by)); | ||
219 | } | ||
220 | |||
221 | /* | ||
222 | * Convert block and offset to dataptr | ||
223 | */ | ||
224 | static inline xfs_dir2_dataptr_t | ||
225 | xfs_dir2_db_off_to_dataptr(struct xfs_mount *mp, xfs_dir2_db_t db, | ||
226 | xfs_dir2_data_aoff_t o) | ||
227 | { | ||
228 | return xfs_dir2_byte_to_dataptr(mp, xfs_dir2_db_off_to_byte(mp, db, o)); | ||
229 | } | ||
230 | |||
231 | /* | ||
232 | * Convert block (dablk) to block (DB) | ||
233 | */ | ||
234 | static inline xfs_dir2_db_t | ||
235 | xfs_dir2_da_to_db(struct xfs_mount *mp, xfs_dablk_t da) | ||
236 | { | ||
237 | return (xfs_dir2_db_t)((da) >> (mp)->m_sb.sb_dirblklog); | ||
238 | } | ||
239 | |||
240 | /* | ||
241 | * Convert block (dablk) to byte offset in space | ||
242 | */ | ||
243 | static inline xfs_dir2_off_t | ||
244 | xfs_dir2_da_to_byte(struct xfs_mount *mp, xfs_dablk_t da) | ||
245 | { | ||
246 | return xfs_dir2_db_off_to_byte(mp, xfs_dir2_da_to_db(mp, da), 0); | ||
247 | } | ||
248 | |||
249 | /* | ||
250 | * Function declarations. | ||
251 | */ | ||
252 | extern int xfs_dir2_block_to_leaf(struct xfs_da_args *args, | ||
253 | struct xfs_dabuf *dbp); | ||
254 | extern int xfs_dir2_leaf_addname(struct xfs_da_args *args); | ||
255 | extern void xfs_dir2_leaf_compact(struct xfs_da_args *args, | ||
256 | struct xfs_dabuf *bp); | ||
257 | extern void xfs_dir2_leaf_compact_x1(struct xfs_dabuf *bp, int *indexp, | ||
258 | int *lowstalep, int *highstalep, | ||
259 | int *lowlogp, int *highlogp); | ||
260 | extern int xfs_dir2_leaf_getdents(struct xfs_inode *dp, void *dirent, | ||
261 | size_t bufsize, xfs_off_t *offset, | ||
262 | filldir_t filldir); | ||
263 | extern int xfs_dir2_leaf_init(struct xfs_da_args *args, xfs_dir2_db_t bno, | ||
264 | struct xfs_dabuf **bpp, int magic); | ||
265 | extern void xfs_dir2_leaf_log_ents(struct xfs_trans *tp, struct xfs_dabuf *bp, | ||
266 | int first, int last); | ||
267 | extern void xfs_dir2_leaf_log_header(struct xfs_trans *tp, | ||
268 | struct xfs_dabuf *bp); | ||
269 | extern int xfs_dir2_leaf_lookup(struct xfs_da_args *args); | ||
270 | extern int xfs_dir2_leaf_removename(struct xfs_da_args *args); | ||
271 | extern int xfs_dir2_leaf_replace(struct xfs_da_args *args); | ||
272 | extern int xfs_dir2_leaf_search_hash(struct xfs_da_args *args, | ||
273 | struct xfs_dabuf *lbp); | ||
274 | extern int xfs_dir2_leaf_trim_data(struct xfs_da_args *args, | ||
275 | struct xfs_dabuf *lbp, xfs_dir2_db_t db); | ||
276 | extern xfs_dir2_leaf_entry_t *xfs_dir2_leaf_find_entry(xfs_dir2_leaf_t *, int, | ||
277 | int, int, int, | ||
278 | int *, int *); | ||
279 | extern int xfs_dir2_node_to_leaf(struct xfs_da_state *state); | ||
280 | |||
281 | #endif /* __XFS_DIR2_LEAF_H__ */ | ||