diff options
author | Jiri Kosina <jkosina@suse.cz> | 2013-01-29 04:48:30 -0500 |
---|---|---|
committer | Jiri Kosina <jkosina@suse.cz> | 2013-01-29 04:48:30 -0500 |
commit | 617677295b53a40d0e54aac4cbbc216ffbc755dd (patch) | |
tree | 51b9e87213243ed5efff252c8e8d8fec4eebc588 /fs/xfs/xfs_dir2_block.c | |
parent | 5c8d1b68e01a144813e38795fe6dbe7ebb506131 (diff) | |
parent | 6abb7c25775b7fb2225ad0508236d63ca710e65f (diff) |
Merge branch 'master' into for-next
Conflicts:
drivers/devfreq/exynos4_bus.c
Sync with Linus' tree to be able to apply patches that are
against newer code (mvneta).
Diffstat (limited to 'fs/xfs/xfs_dir2_block.c')
-rw-r--r-- | fs/xfs/xfs_dir2_block.c | 434 |
1 files changed, 253 insertions, 181 deletions
diff --git a/fs/xfs/xfs_dir2_block.c b/fs/xfs/xfs_dir2_block.c index e93ca8f054f4..12afe07a91d7 100644 --- a/fs/xfs/xfs_dir2_block.c +++ b/fs/xfs/xfs_dir2_block.c | |||
@@ -56,6 +56,214 @@ xfs_dir_startup(void) | |||
56 | xfs_dir_hash_dotdot = xfs_da_hashname((unsigned char *)"..", 2); | 56 | xfs_dir_hash_dotdot = xfs_da_hashname((unsigned char *)"..", 2); |
57 | } | 57 | } |
58 | 58 | ||
59 | static void | ||
60 | xfs_dir2_block_verify( | ||
61 | struct xfs_buf *bp) | ||
62 | { | ||
63 | struct xfs_mount *mp = bp->b_target->bt_mount; | ||
64 | struct xfs_dir2_data_hdr *hdr = bp->b_addr; | ||
65 | int block_ok = 0; | ||
66 | |||
67 | block_ok = hdr->magic == cpu_to_be32(XFS_DIR2_BLOCK_MAGIC); | ||
68 | block_ok = block_ok && __xfs_dir2_data_check(NULL, bp) == 0; | ||
69 | |||
70 | if (!block_ok) { | ||
71 | XFS_CORRUPTION_ERROR(__func__, XFS_ERRLEVEL_LOW, mp, hdr); | ||
72 | xfs_buf_ioerror(bp, EFSCORRUPTED); | ||
73 | } | ||
74 | } | ||
75 | |||
76 | static void | ||
77 | xfs_dir2_block_read_verify( | ||
78 | struct xfs_buf *bp) | ||
79 | { | ||
80 | xfs_dir2_block_verify(bp); | ||
81 | } | ||
82 | |||
83 | static void | ||
84 | xfs_dir2_block_write_verify( | ||
85 | struct xfs_buf *bp) | ||
86 | { | ||
87 | xfs_dir2_block_verify(bp); | ||
88 | } | ||
89 | |||
90 | const struct xfs_buf_ops xfs_dir2_block_buf_ops = { | ||
91 | .verify_read = xfs_dir2_block_read_verify, | ||
92 | .verify_write = xfs_dir2_block_write_verify, | ||
93 | }; | ||
94 | |||
95 | static int | ||
96 | xfs_dir2_block_read( | ||
97 | struct xfs_trans *tp, | ||
98 | struct xfs_inode *dp, | ||
99 | struct xfs_buf **bpp) | ||
100 | { | ||
101 | struct xfs_mount *mp = dp->i_mount; | ||
102 | |||
103 | return xfs_da_read_buf(tp, dp, mp->m_dirdatablk, -1, bpp, | ||
104 | XFS_DATA_FORK, &xfs_dir2_block_buf_ops); | ||
105 | } | ||
106 | |||
107 | static void | ||
108 | xfs_dir2_block_need_space( | ||
109 | struct xfs_dir2_data_hdr *hdr, | ||
110 | struct xfs_dir2_block_tail *btp, | ||
111 | struct xfs_dir2_leaf_entry *blp, | ||
112 | __be16 **tagpp, | ||
113 | struct xfs_dir2_data_unused **dupp, | ||
114 | struct xfs_dir2_data_unused **enddupp, | ||
115 | int *compact, | ||
116 | int len) | ||
117 | { | ||
118 | struct xfs_dir2_data_free *bf; | ||
119 | __be16 *tagp = NULL; | ||
120 | struct xfs_dir2_data_unused *dup = NULL; | ||
121 | struct xfs_dir2_data_unused *enddup = NULL; | ||
122 | |||
123 | *compact = 0; | ||
124 | bf = hdr->bestfree; | ||
125 | |||
126 | /* | ||
127 | * If there are stale entries we'll use one for the leaf. | ||
128 | */ | ||
129 | if (btp->stale) { | ||
130 | if (be16_to_cpu(bf[0].length) >= len) { | ||
131 | /* | ||
132 | * The biggest entry enough to avoid compaction. | ||
133 | */ | ||
134 | dup = (xfs_dir2_data_unused_t *) | ||
135 | ((char *)hdr + be16_to_cpu(bf[0].offset)); | ||
136 | goto out; | ||
137 | } | ||
138 | |||
139 | /* | ||
140 | * Will need to compact to make this work. | ||
141 | * Tag just before the first leaf entry. | ||
142 | */ | ||
143 | *compact = 1; | ||
144 | tagp = (__be16 *)blp - 1; | ||
145 | |||
146 | /* Data object just before the first leaf entry. */ | ||
147 | dup = (xfs_dir2_data_unused_t *)((char *)hdr + be16_to_cpu(*tagp)); | ||
148 | |||
149 | /* | ||
150 | * If it's not free then the data will go where the | ||
151 | * leaf data starts now, if it works at all. | ||
152 | */ | ||
153 | if (be16_to_cpu(dup->freetag) == XFS_DIR2_DATA_FREE_TAG) { | ||
154 | if (be16_to_cpu(dup->length) + (be32_to_cpu(btp->stale) - 1) * | ||
155 | (uint)sizeof(*blp) < len) | ||
156 | dup = NULL; | ||
157 | } else if ((be32_to_cpu(btp->stale) - 1) * (uint)sizeof(*blp) < len) | ||
158 | dup = NULL; | ||
159 | else | ||
160 | dup = (xfs_dir2_data_unused_t *)blp; | ||
161 | goto out; | ||
162 | } | ||
163 | |||
164 | /* | ||
165 | * no stale entries, so just use free space. | ||
166 | * Tag just before the first leaf entry. | ||
167 | */ | ||
168 | tagp = (__be16 *)blp - 1; | ||
169 | |||
170 | /* Data object just before the first leaf entry. */ | ||
171 | enddup = (xfs_dir2_data_unused_t *)((char *)hdr + be16_to_cpu(*tagp)); | ||
172 | |||
173 | /* | ||
174 | * If it's not free then can't do this add without cleaning up: | ||
175 | * the space before the first leaf entry needs to be free so it | ||
176 | * can be expanded to hold the pointer to the new entry. | ||
177 | */ | ||
178 | if (be16_to_cpu(enddup->freetag) == XFS_DIR2_DATA_FREE_TAG) { | ||
179 | /* | ||
180 | * Check out the biggest freespace and see if it's the same one. | ||
181 | */ | ||
182 | dup = (xfs_dir2_data_unused_t *) | ||
183 | ((char *)hdr + be16_to_cpu(bf[0].offset)); | ||
184 | if (dup != enddup) { | ||
185 | /* | ||
186 | * Not the same free entry, just check its length. | ||
187 | */ | ||
188 | if (be16_to_cpu(dup->length) < len) | ||
189 | dup = NULL; | ||
190 | goto out; | ||
191 | } | ||
192 | |||
193 | /* | ||
194 | * It is the biggest freespace, can it hold the leaf too? | ||
195 | */ | ||
196 | if (be16_to_cpu(dup->length) < len + (uint)sizeof(*blp)) { | ||
197 | /* | ||
198 | * Yes, use the second-largest entry instead if it works. | ||
199 | */ | ||
200 | if (be16_to_cpu(bf[1].length) >= len) | ||
201 | dup = (xfs_dir2_data_unused_t *) | ||
202 | ((char *)hdr + be16_to_cpu(bf[1].offset)); | ||
203 | else | ||
204 | dup = NULL; | ||
205 | } | ||
206 | } | ||
207 | out: | ||
208 | *tagpp = tagp; | ||
209 | *dupp = dup; | ||
210 | *enddupp = enddup; | ||
211 | } | ||
212 | |||
213 | /* | ||
214 | * compact the leaf entries. | ||
215 | * Leave the highest-numbered stale entry stale. | ||
216 | * XXX should be the one closest to mid but mid is not yet computed. | ||
217 | */ | ||
218 | static void | ||
219 | xfs_dir2_block_compact( | ||
220 | struct xfs_trans *tp, | ||
221 | struct xfs_buf *bp, | ||
222 | struct xfs_dir2_data_hdr *hdr, | ||
223 | struct xfs_dir2_block_tail *btp, | ||
224 | struct xfs_dir2_leaf_entry *blp, | ||
225 | int *needlog, | ||
226 | int *lfloghigh, | ||
227 | int *lfloglow) | ||
228 | { | ||
229 | int fromidx; /* source leaf index */ | ||
230 | int toidx; /* target leaf index */ | ||
231 | int needscan = 0; | ||
232 | int highstale; /* high stale index */ | ||
233 | |||
234 | fromidx = toidx = be32_to_cpu(btp->count) - 1; | ||
235 | highstale = *lfloghigh = -1; | ||
236 | for (; fromidx >= 0; fromidx--) { | ||
237 | if (blp[fromidx].address == cpu_to_be32(XFS_DIR2_NULL_DATAPTR)) { | ||
238 | if (highstale == -1) | ||
239 | highstale = toidx; | ||
240 | else { | ||
241 | if (*lfloghigh == -1) | ||
242 | *lfloghigh = toidx; | ||
243 | continue; | ||
244 | } | ||
245 | } | ||
246 | if (fromidx < toidx) | ||
247 | blp[toidx] = blp[fromidx]; | ||
248 | toidx--; | ||
249 | } | ||
250 | *lfloglow = toidx + 1 - (be32_to_cpu(btp->stale) - 1); | ||
251 | *lfloghigh -= be32_to_cpu(btp->stale) - 1; | ||
252 | be32_add_cpu(&btp->count, -(be32_to_cpu(btp->stale) - 1)); | ||
253 | xfs_dir2_data_make_free(tp, bp, | ||
254 | (xfs_dir2_data_aoff_t)((char *)blp - (char *)hdr), | ||
255 | (xfs_dir2_data_aoff_t)((be32_to_cpu(btp->stale) - 1) * sizeof(*blp)), | ||
256 | needlog, &needscan); | ||
257 | blp += be32_to_cpu(btp->stale) - 1; | ||
258 | btp->stale = cpu_to_be32(1); | ||
259 | /* | ||
260 | * If we now need to rebuild the bestfree map, do so. | ||
261 | * This needs to happen before the next call to use_free. | ||
262 | */ | ||
263 | if (needscan) | ||
264 | xfs_dir2_data_freescan(tp->t_mountp, hdr, needlog); | ||
265 | } | ||
266 | |||
59 | /* | 267 | /* |
60 | * Add an entry to a block directory. | 268 | * Add an entry to a block directory. |
61 | */ | 269 | */ |
@@ -63,7 +271,6 @@ int /* error */ | |||
63 | xfs_dir2_block_addname( | 271 | xfs_dir2_block_addname( |
64 | xfs_da_args_t *args) /* directory op arguments */ | 272 | xfs_da_args_t *args) /* directory op arguments */ |
65 | { | 273 | { |
66 | xfs_dir2_data_free_t *bf; /* bestfree table in block */ | ||
67 | xfs_dir2_data_hdr_t *hdr; /* block header */ | 274 | xfs_dir2_data_hdr_t *hdr; /* block header */ |
68 | xfs_dir2_leaf_entry_t *blp; /* block leaf entries */ | 275 | xfs_dir2_leaf_entry_t *blp; /* block leaf entries */ |
69 | struct xfs_buf *bp; /* buffer for block */ | 276 | struct xfs_buf *bp; /* buffer for block */ |
@@ -94,134 +301,44 @@ xfs_dir2_block_addname( | |||
94 | dp = args->dp; | 301 | dp = args->dp; |
95 | tp = args->trans; | 302 | tp = args->trans; |
96 | mp = dp->i_mount; | 303 | mp = dp->i_mount; |
97 | /* | 304 | |
98 | * Read the (one and only) directory block into dabuf bp. | 305 | /* Read the (one and only) directory block into bp. */ |
99 | */ | 306 | error = xfs_dir2_block_read(tp, dp, &bp); |
100 | if ((error = | 307 | if (error) |
101 | xfs_da_read_buf(tp, dp, mp->m_dirdatablk, -1, &bp, XFS_DATA_FORK))) { | ||
102 | return error; | 308 | return error; |
103 | } | 309 | |
104 | ASSERT(bp != NULL); | ||
105 | hdr = bp->b_addr; | ||
106 | /* | ||
107 | * Check the magic number, corrupted if wrong. | ||
108 | */ | ||
109 | if (unlikely(hdr->magic != cpu_to_be32(XFS_DIR2_BLOCK_MAGIC))) { | ||
110 | XFS_CORRUPTION_ERROR("xfs_dir2_block_addname", | ||
111 | XFS_ERRLEVEL_LOW, mp, hdr); | ||
112 | xfs_trans_brelse(tp, bp); | ||
113 | return XFS_ERROR(EFSCORRUPTED); | ||
114 | } | ||
115 | len = xfs_dir2_data_entsize(args->namelen); | 310 | len = xfs_dir2_data_entsize(args->namelen); |
311 | |||
116 | /* | 312 | /* |
117 | * Set up pointers to parts of the block. | 313 | * Set up pointers to parts of the block. |
118 | */ | 314 | */ |
119 | bf = hdr->bestfree; | 315 | hdr = bp->b_addr; |
120 | btp = xfs_dir2_block_tail_p(mp, hdr); | 316 | btp = xfs_dir2_block_tail_p(mp, hdr); |
121 | blp = xfs_dir2_block_leaf_p(btp); | 317 | blp = xfs_dir2_block_leaf_p(btp); |
318 | |||
122 | /* | 319 | /* |
123 | * No stale entries? Need space for entry and new leaf. | 320 | * Find out if we can reuse stale entries or whether we need extra |
124 | */ | 321 | * space for entry and new leaf. |
125 | if (!btp->stale) { | ||
126 | /* | ||
127 | * Tag just before the first leaf entry. | ||
128 | */ | ||
129 | tagp = (__be16 *)blp - 1; | ||
130 | /* | ||
131 | * Data object just before the first leaf entry. | ||
132 | */ | ||
133 | enddup = (xfs_dir2_data_unused_t *)((char *)hdr + be16_to_cpu(*tagp)); | ||
134 | /* | ||
135 | * If it's not free then can't do this add without cleaning up: | ||
136 | * the space before the first leaf entry needs to be free so it | ||
137 | * can be expanded to hold the pointer to the new entry. | ||
138 | */ | ||
139 | if (be16_to_cpu(enddup->freetag) != XFS_DIR2_DATA_FREE_TAG) | ||
140 | dup = enddup = NULL; | ||
141 | /* | ||
142 | * Check out the biggest freespace and see if it's the same one. | ||
143 | */ | ||
144 | else { | ||
145 | dup = (xfs_dir2_data_unused_t *) | ||
146 | ((char *)hdr + be16_to_cpu(bf[0].offset)); | ||
147 | if (dup == enddup) { | ||
148 | /* | ||
149 | * It is the biggest freespace, is it too small | ||
150 | * to hold the new leaf too? | ||
151 | */ | ||
152 | if (be16_to_cpu(dup->length) < len + (uint)sizeof(*blp)) { | ||
153 | /* | ||
154 | * Yes, we use the second-largest | ||
155 | * entry instead if it works. | ||
156 | */ | ||
157 | if (be16_to_cpu(bf[1].length) >= len) | ||
158 | dup = (xfs_dir2_data_unused_t *) | ||
159 | ((char *)hdr + | ||
160 | be16_to_cpu(bf[1].offset)); | ||
161 | else | ||
162 | dup = NULL; | ||
163 | } | ||
164 | } else { | ||
165 | /* | ||
166 | * Not the same free entry, | ||
167 | * just check its length. | ||
168 | */ | ||
169 | if (be16_to_cpu(dup->length) < len) { | ||
170 | dup = NULL; | ||
171 | } | ||
172 | } | ||
173 | } | ||
174 | compact = 0; | ||
175 | } | ||
176 | /* | ||
177 | * If there are stale entries we'll use one for the leaf. | ||
178 | * Is the biggest entry enough to avoid compaction? | ||
179 | */ | ||
180 | else if (be16_to_cpu(bf[0].length) >= len) { | ||
181 | dup = (xfs_dir2_data_unused_t *) | ||
182 | ((char *)hdr + be16_to_cpu(bf[0].offset)); | ||
183 | compact = 0; | ||
184 | } | ||
185 | /* | ||
186 | * Will need to compact to make this work. | ||
187 | */ | 322 | */ |
188 | else { | 323 | xfs_dir2_block_need_space(hdr, btp, blp, &tagp, &dup, |
189 | /* | 324 | &enddup, &compact, len); |
190 | * Tag just before the first leaf entry. | 325 | |
191 | */ | ||
192 | tagp = (__be16 *)blp - 1; | ||
193 | /* | ||
194 | * Data object just before the first leaf entry. | ||
195 | */ | ||
196 | dup = (xfs_dir2_data_unused_t *)((char *)hdr + be16_to_cpu(*tagp)); | ||
197 | /* | ||
198 | * If it's not free then the data will go where the | ||
199 | * leaf data starts now, if it works at all. | ||
200 | */ | ||
201 | if (be16_to_cpu(dup->freetag) == XFS_DIR2_DATA_FREE_TAG) { | ||
202 | if (be16_to_cpu(dup->length) + (be32_to_cpu(btp->stale) - 1) * | ||
203 | (uint)sizeof(*blp) < len) | ||
204 | dup = NULL; | ||
205 | } else if ((be32_to_cpu(btp->stale) - 1) * (uint)sizeof(*blp) < len) | ||
206 | dup = NULL; | ||
207 | else | ||
208 | dup = (xfs_dir2_data_unused_t *)blp; | ||
209 | compact = 1; | ||
210 | } | ||
211 | /* | 326 | /* |
212 | * If this isn't a real add, we're done with the buffer. | 327 | * Done everything we need for a space check now. |
213 | */ | 328 | */ |
214 | if (args->op_flags & XFS_DA_OP_JUSTCHECK) | 329 | if (args->op_flags & XFS_DA_OP_JUSTCHECK) { |
215 | xfs_trans_brelse(tp, bp); | 330 | xfs_trans_brelse(tp, bp); |
331 | if (!dup) | ||
332 | return XFS_ERROR(ENOSPC); | ||
333 | return 0; | ||
334 | } | ||
335 | |||
216 | /* | 336 | /* |
217 | * If we don't have space for the new entry & leaf ... | 337 | * If we don't have space for the new entry & leaf ... |
218 | */ | 338 | */ |
219 | if (!dup) { | 339 | if (!dup) { |
220 | /* | 340 | /* Don't have a space reservation: return no-space. */ |
221 | * Not trying to actually do anything, or don't have | 341 | if (args->total == 0) |
222 | * a space reservation: return no-space. | ||
223 | */ | ||
224 | if ((args->op_flags & XFS_DA_OP_JUSTCHECK) || args->total == 0) | ||
225 | return XFS_ERROR(ENOSPC); | 342 | return XFS_ERROR(ENOSPC); |
226 | /* | 343 | /* |
227 | * Convert to the next larger format. | 344 | * Convert to the next larger format. |
@@ -232,65 +349,26 @@ xfs_dir2_block_addname( | |||
232 | return error; | 349 | return error; |
233 | return xfs_dir2_leaf_addname(args); | 350 | return xfs_dir2_leaf_addname(args); |
234 | } | 351 | } |
235 | /* | 352 | |
236 | * Just checking, and it would work, so say so. | ||
237 | */ | ||
238 | if (args->op_flags & XFS_DA_OP_JUSTCHECK) | ||
239 | return 0; | ||
240 | needlog = needscan = 0; | 353 | needlog = needscan = 0; |
354 | |||
241 | /* | 355 | /* |
242 | * If need to compact the leaf entries, do it now. | 356 | * If need to compact the leaf entries, do it now. |
243 | * Leave the highest-numbered stale entry stale. | ||
244 | * XXX should be the one closest to mid but mid is not yet computed. | ||
245 | */ | 357 | */ |
246 | if (compact) { | 358 | if (compact) { |
247 | int fromidx; /* source leaf index */ | 359 | xfs_dir2_block_compact(tp, bp, hdr, btp, blp, &needlog, |
248 | int toidx; /* target leaf index */ | 360 | &lfloghigh, &lfloglow); |
249 | 361 | /* recalculate blp post-compaction */ | |
250 | for (fromidx = toidx = be32_to_cpu(btp->count) - 1, | 362 | blp = xfs_dir2_block_leaf_p(btp); |
251 | highstale = lfloghigh = -1; | 363 | } else if (btp->stale) { |
252 | fromidx >= 0; | ||
253 | fromidx--) { | ||
254 | if (blp[fromidx].address == | ||
255 | cpu_to_be32(XFS_DIR2_NULL_DATAPTR)) { | ||
256 | if (highstale == -1) | ||
257 | highstale = toidx; | ||
258 | else { | ||
259 | if (lfloghigh == -1) | ||
260 | lfloghigh = toidx; | ||
261 | continue; | ||
262 | } | ||
263 | } | ||
264 | if (fromidx < toidx) | ||
265 | blp[toidx] = blp[fromidx]; | ||
266 | toidx--; | ||
267 | } | ||
268 | lfloglow = toidx + 1 - (be32_to_cpu(btp->stale) - 1); | ||
269 | lfloghigh -= be32_to_cpu(btp->stale) - 1; | ||
270 | be32_add_cpu(&btp->count, -(be32_to_cpu(btp->stale) - 1)); | ||
271 | xfs_dir2_data_make_free(tp, bp, | ||
272 | (xfs_dir2_data_aoff_t)((char *)blp - (char *)hdr), | ||
273 | (xfs_dir2_data_aoff_t)((be32_to_cpu(btp->stale) - 1) * sizeof(*blp)), | ||
274 | &needlog, &needscan); | ||
275 | blp += be32_to_cpu(btp->stale) - 1; | ||
276 | btp->stale = cpu_to_be32(1); | ||
277 | /* | 364 | /* |
278 | * If we now need to rebuild the bestfree map, do so. | 365 | * Set leaf logging boundaries to impossible state. |
279 | * This needs to happen before the next call to use_free. | 366 | * For the no-stale case they're set explicitly. |
280 | */ | 367 | */ |
281 | if (needscan) { | ||
282 | xfs_dir2_data_freescan(mp, hdr, &needlog); | ||
283 | needscan = 0; | ||
284 | } | ||
285 | } | ||
286 | /* | ||
287 | * Set leaf logging boundaries to impossible state. | ||
288 | * For the no-stale case they're set explicitly. | ||
289 | */ | ||
290 | else if (btp->stale) { | ||
291 | lfloglow = be32_to_cpu(btp->count); | 368 | lfloglow = be32_to_cpu(btp->count); |
292 | lfloghigh = -1; | 369 | lfloghigh = -1; |
293 | } | 370 | } |
371 | |||
294 | /* | 372 | /* |
295 | * Find the slot that's first lower than our hash value, -1 if none. | 373 | * Find the slot that's first lower than our hash value, -1 if none. |
296 | */ | 374 | */ |
@@ -450,18 +528,13 @@ xfs_dir2_block_getdents( | |||
450 | /* | 528 | /* |
451 | * If the block number in the offset is out of range, we're done. | 529 | * If the block number in the offset is out of range, we're done. |
452 | */ | 530 | */ |
453 | if (xfs_dir2_dataptr_to_db(mp, *offset) > mp->m_dirdatablk) { | 531 | if (xfs_dir2_dataptr_to_db(mp, *offset) > mp->m_dirdatablk) |
454 | return 0; | 532 | return 0; |
455 | } | 533 | |
456 | /* | 534 | error = xfs_dir2_block_read(NULL, dp, &bp); |
457 | * Can't read the block, give up, else get dabuf in bp. | ||
458 | */ | ||
459 | error = xfs_da_read_buf(NULL, dp, mp->m_dirdatablk, -1, | ||
460 | &bp, XFS_DATA_FORK); | ||
461 | if (error) | 535 | if (error) |
462 | return error; | 536 | return error; |
463 | 537 | ||
464 | ASSERT(bp != NULL); | ||
465 | /* | 538 | /* |
466 | * Extract the byte offset we start at from the seek pointer. | 539 | * Extract the byte offset we start at from the seek pointer. |
467 | * We'll skip entries before this. | 540 | * We'll skip entries before this. |
@@ -637,14 +710,11 @@ xfs_dir2_block_lookup_int( | |||
637 | dp = args->dp; | 710 | dp = args->dp; |
638 | tp = args->trans; | 711 | tp = args->trans; |
639 | mp = dp->i_mount; | 712 | mp = dp->i_mount; |
640 | /* | 713 | |
641 | * Read the buffer, return error if we can't get it. | 714 | error = xfs_dir2_block_read(tp, dp, &bp); |
642 | */ | 715 | if (error) |
643 | if ((error = | ||
644 | xfs_da_read_buf(tp, dp, mp->m_dirdatablk, -1, &bp, XFS_DATA_FORK))) { | ||
645 | return error; | 716 | return error; |
646 | } | 717 | |
647 | ASSERT(bp != NULL); | ||
648 | hdr = bp->b_addr; | 718 | hdr = bp->b_addr; |
649 | xfs_dir2_data_check(dp, bp); | 719 | xfs_dir2_data_check(dp, bp); |
650 | btp = xfs_dir2_block_tail_p(mp, hdr); | 720 | btp = xfs_dir2_block_tail_p(mp, hdr); |
@@ -917,10 +987,10 @@ xfs_dir2_leaf_to_block( | |||
917 | /* | 987 | /* |
918 | * Read the data block if we don't already have it, give up if it fails. | 988 | * Read the data block if we don't already have it, give up if it fails. |
919 | */ | 989 | */ |
920 | if (dbp == NULL && | 990 | if (!dbp) { |
921 | (error = xfs_da_read_buf(tp, dp, mp->m_dirdatablk, -1, &dbp, | 991 | error = xfs_dir2_data_read(tp, dp, mp->m_dirdatablk, -1, &dbp); |
922 | XFS_DATA_FORK))) { | 992 | if (error) |
923 | return error; | 993 | return error; |
924 | } | 994 | } |
925 | hdr = dbp->b_addr; | 995 | hdr = dbp->b_addr; |
926 | ASSERT(hdr->magic == cpu_to_be32(XFS_DIR2_DATA_MAGIC)); | 996 | ASSERT(hdr->magic == cpu_to_be32(XFS_DIR2_DATA_MAGIC)); |
@@ -944,6 +1014,7 @@ xfs_dir2_leaf_to_block( | |||
944 | /* | 1014 | /* |
945 | * Start converting it to block form. | 1015 | * Start converting it to block form. |
946 | */ | 1016 | */ |
1017 | dbp->b_ops = &xfs_dir2_block_buf_ops; | ||
947 | hdr->magic = cpu_to_be32(XFS_DIR2_BLOCK_MAGIC); | 1018 | hdr->magic = cpu_to_be32(XFS_DIR2_BLOCK_MAGIC); |
948 | needlog = 1; | 1019 | needlog = 1; |
949 | needscan = 0; | 1020 | needscan = 0; |
@@ -1073,6 +1144,7 @@ xfs_dir2_sf_to_block( | |||
1073 | kmem_free(sfp); | 1144 | kmem_free(sfp); |
1074 | return error; | 1145 | return error; |
1075 | } | 1146 | } |
1147 | bp->b_ops = &xfs_dir2_block_buf_ops; | ||
1076 | hdr = bp->b_addr; | 1148 | hdr = bp->b_addr; |
1077 | hdr->magic = cpu_to_be32(XFS_DIR2_BLOCK_MAGIC); | 1149 | hdr->magic = cpu_to_be32(XFS_DIR2_BLOCK_MAGIC); |
1078 | /* | 1150 | /* |