diff options
-rw-r--r-- | fs/xfs/libxfs/xfs_dir2.h | 134 | ||||
-rw-r--r-- | fs/xfs/libxfs/xfs_dir2_priv.h | 134 | ||||
-rw-r--r-- | fs/xfs/xfs_export.c | 1 | ||||
-rw-r--r-- | fs/xfs/xfs_log_recover.c | 1 | ||||
-rw-r--r-- | fs/xfs/xfs_mount.c | 1 |
5 files changed, 137 insertions, 134 deletions
diff --git a/fs/xfs/libxfs/xfs_dir2.h b/fs/xfs/libxfs/xfs_dir2.h index 874720dbd865..e55353651f5b 100644 --- a/fs/xfs/libxfs/xfs_dir2.h +++ b/fs/xfs/libxfs/xfs_dir2.h | |||
@@ -183,4 +183,138 @@ extern const struct xfs_buf_ops xfs_dir3_leaf1_buf_ops; | |||
183 | extern const struct xfs_buf_ops xfs_dir3_free_buf_ops; | 183 | extern const struct xfs_buf_ops xfs_dir3_free_buf_ops; |
184 | extern const struct xfs_buf_ops xfs_dir3_data_buf_ops; | 184 | extern const struct xfs_buf_ops xfs_dir3_data_buf_ops; |
185 | 185 | ||
186 | /* | ||
187 | * Directory offset/block conversion functions. | ||
188 | * | ||
189 | * DB blocks here are logical directory block numbers, not filesystem blocks. | ||
190 | */ | ||
191 | |||
192 | /* | ||
193 | * Convert dataptr to byte in file space | ||
194 | */ | ||
195 | static inline xfs_dir2_off_t | ||
196 | xfs_dir2_dataptr_to_byte(xfs_dir2_dataptr_t dp) | ||
197 | { | ||
198 | return (xfs_dir2_off_t)dp << XFS_DIR2_DATA_ALIGN_LOG; | ||
199 | } | ||
200 | |||
201 | /* | ||
202 | * Convert byte in file space to dataptr. It had better be aligned. | ||
203 | */ | ||
204 | static inline xfs_dir2_dataptr_t | ||
205 | xfs_dir2_byte_to_dataptr(xfs_dir2_off_t by) | ||
206 | { | ||
207 | return (xfs_dir2_dataptr_t)(by >> XFS_DIR2_DATA_ALIGN_LOG); | ||
208 | } | ||
209 | |||
210 | /* | ||
211 | * Convert byte in space to (DB) block | ||
212 | */ | ||
213 | static inline xfs_dir2_db_t | ||
214 | xfs_dir2_byte_to_db(struct xfs_da_geometry *geo, xfs_dir2_off_t by) | ||
215 | { | ||
216 | return (xfs_dir2_db_t)(by >> geo->blklog); | ||
217 | } | ||
218 | |||
219 | /* | ||
220 | * Convert dataptr to a block number | ||
221 | */ | ||
222 | static inline xfs_dir2_db_t | ||
223 | xfs_dir2_dataptr_to_db(struct xfs_da_geometry *geo, xfs_dir2_dataptr_t dp) | ||
224 | { | ||
225 | return xfs_dir2_byte_to_db(geo, xfs_dir2_dataptr_to_byte(dp)); | ||
226 | } | ||
227 | |||
228 | /* | ||
229 | * Convert byte in space to offset in a block | ||
230 | */ | ||
231 | static inline xfs_dir2_data_aoff_t | ||
232 | xfs_dir2_byte_to_off(struct xfs_da_geometry *geo, xfs_dir2_off_t by) | ||
233 | { | ||
234 | return (xfs_dir2_data_aoff_t)(by & (geo->blksize - 1)); | ||
235 | } | ||
236 | |||
237 | /* | ||
238 | * Convert dataptr to a byte offset in a block | ||
239 | */ | ||
240 | static inline xfs_dir2_data_aoff_t | ||
241 | xfs_dir2_dataptr_to_off(struct xfs_da_geometry *geo, xfs_dir2_dataptr_t dp) | ||
242 | { | ||
243 | return xfs_dir2_byte_to_off(geo, xfs_dir2_dataptr_to_byte(dp)); | ||
244 | } | ||
245 | |||
246 | /* | ||
247 | * Convert block and offset to byte in space | ||
248 | */ | ||
249 | static inline xfs_dir2_off_t | ||
250 | xfs_dir2_db_off_to_byte(struct xfs_da_geometry *geo, xfs_dir2_db_t db, | ||
251 | xfs_dir2_data_aoff_t o) | ||
252 | { | ||
253 | return ((xfs_dir2_off_t)db << geo->blklog) + o; | ||
254 | } | ||
255 | |||
256 | /* | ||
257 | * Convert block (DB) to block (dablk) | ||
258 | */ | ||
259 | static inline xfs_dablk_t | ||
260 | xfs_dir2_db_to_da(struct xfs_da_geometry *geo, xfs_dir2_db_t db) | ||
261 | { | ||
262 | return (xfs_dablk_t)(db << (geo->blklog - geo->fsblog)); | ||
263 | } | ||
264 | |||
265 | /* | ||
266 | * Convert byte in space to (DA) block | ||
267 | */ | ||
268 | static inline xfs_dablk_t | ||
269 | xfs_dir2_byte_to_da(struct xfs_da_geometry *geo, xfs_dir2_off_t by) | ||
270 | { | ||
271 | return xfs_dir2_db_to_da(geo, xfs_dir2_byte_to_db(geo, by)); | ||
272 | } | ||
273 | |||
274 | /* | ||
275 | * Convert block and offset to dataptr | ||
276 | */ | ||
277 | static inline xfs_dir2_dataptr_t | ||
278 | xfs_dir2_db_off_to_dataptr(struct xfs_da_geometry *geo, xfs_dir2_db_t db, | ||
279 | xfs_dir2_data_aoff_t o) | ||
280 | { | ||
281 | return xfs_dir2_byte_to_dataptr(xfs_dir2_db_off_to_byte(geo, db, o)); | ||
282 | } | ||
283 | |||
284 | /* | ||
285 | * Convert block (dablk) to block (DB) | ||
286 | */ | ||
287 | static inline xfs_dir2_db_t | ||
288 | xfs_dir2_da_to_db(struct xfs_da_geometry *geo, xfs_dablk_t da) | ||
289 | { | ||
290 | return (xfs_dir2_db_t)(da >> (geo->blklog - geo->fsblog)); | ||
291 | } | ||
292 | |||
293 | /* | ||
294 | * Convert block (dablk) to byte offset in space | ||
295 | */ | ||
296 | static inline xfs_dir2_off_t | ||
297 | xfs_dir2_da_to_byte(struct xfs_da_geometry *geo, xfs_dablk_t da) | ||
298 | { | ||
299 | return xfs_dir2_db_off_to_byte(geo, xfs_dir2_da_to_db(geo, da), 0); | ||
300 | } | ||
301 | |||
302 | /* | ||
303 | * Directory tail pointer accessor functions. Based on block geometry. | ||
304 | */ | ||
305 | static inline struct xfs_dir2_block_tail * | ||
306 | xfs_dir2_block_tail_p(struct xfs_da_geometry *geo, struct xfs_dir2_data_hdr *hdr) | ||
307 | { | ||
308 | return ((struct xfs_dir2_block_tail *) | ||
309 | ((char *)hdr + geo->blksize)) - 1; | ||
310 | } | ||
311 | |||
312 | static inline struct xfs_dir2_leaf_tail * | ||
313 | xfs_dir2_leaf_tail_p(struct xfs_da_geometry *geo, struct xfs_dir2_leaf *lp) | ||
314 | { | ||
315 | return (struct xfs_dir2_leaf_tail *) | ||
316 | ((char *)lp + geo->blksize - | ||
317 | sizeof(struct xfs_dir2_leaf_tail)); | ||
318 | } | ||
319 | |||
186 | #endif /* __XFS_DIR2_H__ */ | 320 | #endif /* __XFS_DIR2_H__ */ |
diff --git a/fs/xfs/libxfs/xfs_dir2_priv.h b/fs/xfs/libxfs/xfs_dir2_priv.h index 27096ba91dde..ef9f6ead96a4 100644 --- a/fs/xfs/libxfs/xfs_dir2_priv.h +++ b/fs/xfs/libxfs/xfs_dir2_priv.h | |||
@@ -20,140 +20,6 @@ | |||
20 | 20 | ||
21 | struct dir_context; | 21 | struct dir_context; |
22 | 22 | ||
23 | /* | ||
24 | * Directory offset/block conversion functions. | ||
25 | * | ||
26 | * DB blocks here are logical directory block numbers, not filesystem blocks. | ||
27 | */ | ||
28 | |||
29 | /* | ||
30 | * Convert dataptr to byte in file space | ||
31 | */ | ||
32 | static inline xfs_dir2_off_t | ||
33 | xfs_dir2_dataptr_to_byte(xfs_dir2_dataptr_t dp) | ||
34 | { | ||
35 | return (xfs_dir2_off_t)dp << XFS_DIR2_DATA_ALIGN_LOG; | ||
36 | } | ||
37 | |||
38 | /* | ||
39 | * Convert byte in file space to dataptr. It had better be aligned. | ||
40 | */ | ||
41 | static inline xfs_dir2_dataptr_t | ||
42 | xfs_dir2_byte_to_dataptr(xfs_dir2_off_t by) | ||
43 | { | ||
44 | return (xfs_dir2_dataptr_t)(by >> XFS_DIR2_DATA_ALIGN_LOG); | ||
45 | } | ||
46 | |||
47 | /* | ||
48 | * Convert byte in space to (DB) block | ||
49 | */ | ||
50 | static inline xfs_dir2_db_t | ||
51 | xfs_dir2_byte_to_db(struct xfs_da_geometry *geo, xfs_dir2_off_t by) | ||
52 | { | ||
53 | return (xfs_dir2_db_t)(by >> geo->blklog); | ||
54 | } | ||
55 | |||
56 | /* | ||
57 | * Convert dataptr to a block number | ||
58 | */ | ||
59 | static inline xfs_dir2_db_t | ||
60 | xfs_dir2_dataptr_to_db(struct xfs_da_geometry *geo, xfs_dir2_dataptr_t dp) | ||
61 | { | ||
62 | return xfs_dir2_byte_to_db(geo, xfs_dir2_dataptr_to_byte(dp)); | ||
63 | } | ||
64 | |||
65 | /* | ||
66 | * Convert byte in space to offset in a block | ||
67 | */ | ||
68 | static inline xfs_dir2_data_aoff_t | ||
69 | xfs_dir2_byte_to_off(struct xfs_da_geometry *geo, xfs_dir2_off_t by) | ||
70 | { | ||
71 | return (xfs_dir2_data_aoff_t)(by & (geo->blksize - 1)); | ||
72 | } | ||
73 | |||
74 | /* | ||
75 | * Convert dataptr to a byte offset in a block | ||
76 | */ | ||
77 | static inline xfs_dir2_data_aoff_t | ||
78 | xfs_dir2_dataptr_to_off(struct xfs_da_geometry *geo, xfs_dir2_dataptr_t dp) | ||
79 | { | ||
80 | return xfs_dir2_byte_to_off(geo, xfs_dir2_dataptr_to_byte(dp)); | ||
81 | } | ||
82 | |||
83 | /* | ||
84 | * Convert block and offset to byte in space | ||
85 | */ | ||
86 | static inline xfs_dir2_off_t | ||
87 | xfs_dir2_db_off_to_byte(struct xfs_da_geometry *geo, xfs_dir2_db_t db, | ||
88 | xfs_dir2_data_aoff_t o) | ||
89 | { | ||
90 | return ((xfs_dir2_off_t)db << geo->blklog) + o; | ||
91 | } | ||
92 | |||
93 | /* | ||
94 | * Convert block (DB) to block (dablk) | ||
95 | */ | ||
96 | static inline xfs_dablk_t | ||
97 | xfs_dir2_db_to_da(struct xfs_da_geometry *geo, xfs_dir2_db_t db) | ||
98 | { | ||
99 | return (xfs_dablk_t)(db << (geo->blklog - geo->fsblog)); | ||
100 | } | ||
101 | |||
102 | /* | ||
103 | * Convert byte in space to (DA) block | ||
104 | */ | ||
105 | static inline xfs_dablk_t | ||
106 | xfs_dir2_byte_to_da(struct xfs_da_geometry *geo, xfs_dir2_off_t by) | ||
107 | { | ||
108 | return xfs_dir2_db_to_da(geo, xfs_dir2_byte_to_db(geo, by)); | ||
109 | } | ||
110 | |||
111 | /* | ||
112 | * Convert block and offset to dataptr | ||
113 | */ | ||
114 | static inline xfs_dir2_dataptr_t | ||
115 | xfs_dir2_db_off_to_dataptr(struct xfs_da_geometry *geo, xfs_dir2_db_t db, | ||
116 | xfs_dir2_data_aoff_t o) | ||
117 | { | ||
118 | return xfs_dir2_byte_to_dataptr(xfs_dir2_db_off_to_byte(geo, db, o)); | ||
119 | } | ||
120 | |||
121 | /* | ||
122 | * Convert block (dablk) to block (DB) | ||
123 | */ | ||
124 | static inline xfs_dir2_db_t | ||
125 | xfs_dir2_da_to_db(struct xfs_da_geometry *geo, xfs_dablk_t da) | ||
126 | { | ||
127 | return (xfs_dir2_db_t)(da >> (geo->blklog - geo->fsblog)); | ||
128 | } | ||
129 | |||
130 | /* | ||
131 | * Convert block (dablk) to byte offset in space | ||
132 | */ | ||
133 | static inline xfs_dir2_off_t | ||
134 | xfs_dir2_da_to_byte(struct xfs_da_geometry *geo, xfs_dablk_t da) | ||
135 | { | ||
136 | return xfs_dir2_db_off_to_byte(geo, xfs_dir2_da_to_db(geo, da), 0); | ||
137 | } | ||
138 | |||
139 | /* | ||
140 | * Directory tail pointer accessor functions. Based on block geometry. | ||
141 | */ | ||
142 | static inline struct xfs_dir2_block_tail * | ||
143 | xfs_dir2_block_tail_p(struct xfs_da_geometry *geo, struct xfs_dir2_data_hdr *hdr) | ||
144 | { | ||
145 | return ((struct xfs_dir2_block_tail *) | ||
146 | ((char *)hdr + geo->blksize)) - 1; | ||
147 | } | ||
148 | |||
149 | static inline struct xfs_dir2_leaf_tail * | ||
150 | xfs_dir2_leaf_tail_p(struct xfs_da_geometry *geo, struct xfs_dir2_leaf *lp) | ||
151 | { | ||
152 | return (struct xfs_dir2_leaf_tail *) | ||
153 | ((char *)lp + geo->blksize - | ||
154 | sizeof(struct xfs_dir2_leaf_tail)); | ||
155 | } | ||
156 | |||
157 | /* xfs_dir2.c */ | 23 | /* xfs_dir2.c */ |
158 | extern int xfs_dir_ino_validate(struct xfs_mount *mp, xfs_ino_t ino); | 24 | extern int xfs_dir_ino_validate(struct xfs_mount *mp, xfs_ino_t ino); |
159 | extern int xfs_dir2_grow_inode(struct xfs_da_args *args, int space, | 25 | extern int xfs_dir2_grow_inode(struct xfs_da_args *args, int space, |
diff --git a/fs/xfs/xfs_export.c b/fs/xfs/xfs_export.c index 5a6bd5d8779a..ba545634cc04 100644 --- a/fs/xfs/xfs_export.c +++ b/fs/xfs/xfs_export.c | |||
@@ -23,6 +23,7 @@ | |||
23 | #include "xfs_ag.h" | 23 | #include "xfs_ag.h" |
24 | #include "xfs_mount.h" | 24 | #include "xfs_mount.h" |
25 | #include "xfs_da_format.h" | 25 | #include "xfs_da_format.h" |
26 | #include "xfs_da_btree.h" | ||
26 | #include "xfs_dir2.h" | 27 | #include "xfs_dir2.h" |
27 | #include "xfs_export.h" | 28 | #include "xfs_export.h" |
28 | #include "xfs_inode.h" | 29 | #include "xfs_inode.h" |
diff --git a/fs/xfs/xfs_log_recover.c b/fs/xfs/xfs_log_recover.c index 00cd7f3a8f59..f7c312fe91fb 100644 --- a/fs/xfs/xfs_log_recover.c +++ b/fs/xfs/xfs_log_recover.c | |||
@@ -27,6 +27,7 @@ | |||
27 | #include "xfs_ag.h" | 27 | #include "xfs_ag.h" |
28 | #include "xfs_mount.h" | 28 | #include "xfs_mount.h" |
29 | #include "xfs_da_format.h" | 29 | #include "xfs_da_format.h" |
30 | #include "xfs_da_btree.h" | ||
30 | #include "xfs_inode.h" | 31 | #include "xfs_inode.h" |
31 | #include "xfs_trans.h" | 32 | #include "xfs_trans.h" |
32 | #include "xfs_log.h" | 33 | #include "xfs_log.h" |
diff --git a/fs/xfs/xfs_mount.c b/fs/xfs/xfs_mount.c index 13d117089101..acbb4837abc5 100644 --- a/fs/xfs/xfs_mount.c +++ b/fs/xfs/xfs_mount.c | |||
@@ -27,6 +27,7 @@ | |||
27 | #include "xfs_ag.h" | 27 | #include "xfs_ag.h" |
28 | #include "xfs_mount.h" | 28 | #include "xfs_mount.h" |
29 | #include "xfs_da_format.h" | 29 | #include "xfs_da_format.h" |
30 | #include "xfs_da_btree.h" | ||
30 | #include "xfs_inode.h" | 31 | #include "xfs_inode.h" |
31 | #include "xfs_dir2.h" | 32 | #include "xfs_dir2.h" |
32 | #include "xfs_ialloc.h" | 33 | #include "xfs_ialloc.h" |