xfs: drop dmapi hooks
[deliverable/linux.git] / fs / xfs / xfs_dir2_leaf.c
1 /*
2 * Copyright (c) 2000-2003,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 #include "xfs.h"
19 #include "xfs_fs.h"
20 #include "xfs_types.h"
21 #include "xfs_bit.h"
22 #include "xfs_log.h"
23 #include "xfs_inum.h"
24 #include "xfs_trans.h"
25 #include "xfs_sb.h"
26 #include "xfs_ag.h"
27 #include "xfs_dir2.h"
28 #include "xfs_mount.h"
29 #include "xfs_da_btree.h"
30 #include "xfs_bmap_btree.h"
31 #include "xfs_attr_sf.h"
32 #include "xfs_dir2_sf.h"
33 #include "xfs_dinode.h"
34 #include "xfs_inode.h"
35 #include "xfs_bmap.h"
36 #include "xfs_dir2_data.h"
37 #include "xfs_dir2_leaf.h"
38 #include "xfs_dir2_block.h"
39 #include "xfs_dir2_node.h"
40 #include "xfs_error.h"
41 #include "xfs_trace.h"
42
43 /*
44 * Local function declarations.
45 */
46 #ifdef DEBUG
47 static void xfs_dir2_leaf_check(xfs_inode_t *dp, xfs_dabuf_t *bp);
48 #else
49 #define xfs_dir2_leaf_check(dp, bp)
50 #endif
51 static int xfs_dir2_leaf_lookup_int(xfs_da_args_t *args, xfs_dabuf_t **lbpp,
52 int *indexp, xfs_dabuf_t **dbpp);
53 static void xfs_dir2_leaf_log_bests(struct xfs_trans *tp, struct xfs_dabuf *bp,
54 int first, int last);
55 static void xfs_dir2_leaf_log_tail(struct xfs_trans *tp, struct xfs_dabuf *bp);
56
57
58 /*
59 * Convert a block form directory to a leaf form directory.
60 */
61 int /* error */
62 xfs_dir2_block_to_leaf(
63 xfs_da_args_t *args, /* operation arguments */
64 xfs_dabuf_t *dbp) /* input block's buffer */
65 {
66 __be16 *bestsp; /* leaf's bestsp entries */
67 xfs_dablk_t blkno; /* leaf block's bno */
68 xfs_dir2_block_t *block; /* block structure */
69 xfs_dir2_leaf_entry_t *blp; /* block's leaf entries */
70 xfs_dir2_block_tail_t *btp; /* block's tail */
71 xfs_inode_t *dp; /* incore directory inode */
72 int error; /* error return code */
73 xfs_dabuf_t *lbp; /* leaf block's buffer */
74 xfs_dir2_db_t ldb; /* leaf block's bno */
75 xfs_dir2_leaf_t *leaf; /* leaf structure */
76 xfs_dir2_leaf_tail_t *ltp; /* leaf's tail */
77 xfs_mount_t *mp; /* filesystem mount point */
78 int needlog; /* need to log block header */
79 int needscan; /* need to rescan bestfree */
80 xfs_trans_t *tp; /* transaction pointer */
81
82 trace_xfs_dir2_block_to_leaf(args);
83
84 dp = args->dp;
85 mp = dp->i_mount;
86 tp = args->trans;
87 /*
88 * Add the leaf block to the inode.
89 * This interface will only put blocks in the leaf/node range.
90 * Since that's empty now, we'll get the root (block 0 in range).
91 */
92 if ((error = xfs_da_grow_inode(args, &blkno))) {
93 return error;
94 }
95 ldb = xfs_dir2_da_to_db(mp, blkno);
96 ASSERT(ldb == XFS_DIR2_LEAF_FIRSTDB(mp));
97 /*
98 * Initialize the leaf block, get a buffer for it.
99 */
100 if ((error = xfs_dir2_leaf_init(args, ldb, &lbp, XFS_DIR2_LEAF1_MAGIC))) {
101 return error;
102 }
103 ASSERT(lbp != NULL);
104 leaf = lbp->data;
105 block = dbp->data;
106 xfs_dir2_data_check(dp, dbp);
107 btp = xfs_dir2_block_tail_p(mp, block);
108 blp = xfs_dir2_block_leaf_p(btp);
109 /*
110 * Set the counts in the leaf header.
111 */
112 leaf->hdr.count = cpu_to_be16(be32_to_cpu(btp->count));
113 leaf->hdr.stale = cpu_to_be16(be32_to_cpu(btp->stale));
114 /*
115 * Could compact these but I think we always do the conversion
116 * after squeezing out stale entries.
117 */
118 memcpy(leaf->ents, blp, be32_to_cpu(btp->count) * sizeof(xfs_dir2_leaf_entry_t));
119 xfs_dir2_leaf_log_ents(tp, lbp, 0, be16_to_cpu(leaf->hdr.count) - 1);
120 needscan = 0;
121 needlog = 1;
122 /*
123 * Make the space formerly occupied by the leaf entries and block
124 * tail be free.
125 */
126 xfs_dir2_data_make_free(tp, dbp,
127 (xfs_dir2_data_aoff_t)((char *)blp - (char *)block),
128 (xfs_dir2_data_aoff_t)((char *)block + mp->m_dirblksize -
129 (char *)blp),
130 &needlog, &needscan);
131 /*
132 * Fix up the block header, make it a data block.
133 */
134 block->hdr.magic = cpu_to_be32(XFS_DIR2_DATA_MAGIC);
135 if (needscan)
136 xfs_dir2_data_freescan(mp, (xfs_dir2_data_t *)block, &needlog);
137 /*
138 * Set up leaf tail and bests table.
139 */
140 ltp = xfs_dir2_leaf_tail_p(mp, leaf);
141 ltp->bestcount = cpu_to_be32(1);
142 bestsp = xfs_dir2_leaf_bests_p(ltp);
143 bestsp[0] = block->hdr.bestfree[0].length;
144 /*
145 * Log the data header and leaf bests table.
146 */
147 if (needlog)
148 xfs_dir2_data_log_header(tp, dbp);
149 xfs_dir2_leaf_check(dp, lbp);
150 xfs_dir2_data_check(dp, dbp);
151 xfs_dir2_leaf_log_bests(tp, lbp, 0, 0);
152 xfs_da_buf_done(lbp);
153 return 0;
154 }
155
156 /*
157 * Add an entry to a leaf form directory.
158 */
159 int /* error */
160 xfs_dir2_leaf_addname(
161 xfs_da_args_t *args) /* operation arguments */
162 {
163 __be16 *bestsp; /* freespace table in leaf */
164 int compact; /* need to compact leaves */
165 xfs_dir2_data_t *data; /* data block structure */
166 xfs_dabuf_t *dbp; /* data block buffer */
167 xfs_dir2_data_entry_t *dep; /* data block entry */
168 xfs_inode_t *dp; /* incore directory inode */
169 xfs_dir2_data_unused_t *dup; /* data unused entry */
170 int error; /* error return value */
171 int grown; /* allocated new data block */
172 int highstale; /* index of next stale leaf */
173 int i; /* temporary, index */
174 int index; /* leaf table position */
175 xfs_dabuf_t *lbp; /* leaf's buffer */
176 xfs_dir2_leaf_t *leaf; /* leaf structure */
177 int length; /* length of new entry */
178 xfs_dir2_leaf_entry_t *lep; /* leaf entry table pointer */
179 int lfloglow; /* low leaf logging index */
180 int lfloghigh; /* high leaf logging index */
181 int lowstale; /* index of prev stale leaf */
182 xfs_dir2_leaf_tail_t *ltp; /* leaf tail pointer */
183 xfs_mount_t *mp; /* filesystem mount point */
184 int needbytes; /* leaf block bytes needed */
185 int needlog; /* need to log data header */
186 int needscan; /* need to rescan data free */
187 __be16 *tagp; /* end of data entry */
188 xfs_trans_t *tp; /* transaction pointer */
189 xfs_dir2_db_t use_block; /* data block number */
190
191 trace_xfs_dir2_leaf_addname(args);
192
193 dp = args->dp;
194 tp = args->trans;
195 mp = dp->i_mount;
196 /*
197 * Read the leaf block.
198 */
199 error = xfs_da_read_buf(tp, dp, mp->m_dirleafblk, -1, &lbp,
200 XFS_DATA_FORK);
201 if (error) {
202 return error;
203 }
204 ASSERT(lbp != NULL);
205 /*
206 * Look up the entry by hash value and name.
207 * We know it's not there, our caller has already done a lookup.
208 * So the index is of the entry to insert in front of.
209 * But if there are dup hash values the index is of the first of those.
210 */
211 index = xfs_dir2_leaf_search_hash(args, lbp);
212 leaf = lbp->data;
213 ltp = xfs_dir2_leaf_tail_p(mp, leaf);
214 bestsp = xfs_dir2_leaf_bests_p(ltp);
215 length = xfs_dir2_data_entsize(args->namelen);
216 /*
217 * See if there are any entries with the same hash value
218 * and space in their block for the new entry.
219 * This is good because it puts multiple same-hash value entries
220 * in a data block, improving the lookup of those entries.
221 */
222 for (use_block = -1, lep = &leaf->ents[index];
223 index < be16_to_cpu(leaf->hdr.count) && be32_to_cpu(lep->hashval) == args->hashval;
224 index++, lep++) {
225 if (be32_to_cpu(lep->address) == XFS_DIR2_NULL_DATAPTR)
226 continue;
227 i = xfs_dir2_dataptr_to_db(mp, be32_to_cpu(lep->address));
228 ASSERT(i < be32_to_cpu(ltp->bestcount));
229 ASSERT(be16_to_cpu(bestsp[i]) != NULLDATAOFF);
230 if (be16_to_cpu(bestsp[i]) >= length) {
231 use_block = i;
232 break;
233 }
234 }
235 /*
236 * Didn't find a block yet, linear search all the data blocks.
237 */
238 if (use_block == -1) {
239 for (i = 0; i < be32_to_cpu(ltp->bestcount); i++) {
240 /*
241 * Remember a block we see that's missing.
242 */
243 if (be16_to_cpu(bestsp[i]) == NULLDATAOFF && use_block == -1)
244 use_block = i;
245 else if (be16_to_cpu(bestsp[i]) >= length) {
246 use_block = i;
247 break;
248 }
249 }
250 }
251 /*
252 * How many bytes do we need in the leaf block?
253 */
254 needbytes =
255 (leaf->hdr.stale ? 0 : (uint)sizeof(leaf->ents[0])) +
256 (use_block != -1 ? 0 : (uint)sizeof(leaf->bests[0]));
257 /*
258 * Now kill use_block if it refers to a missing block, so we
259 * can use it as an indication of allocation needed.
260 */
261 if (use_block != -1 && be16_to_cpu(bestsp[use_block]) == NULLDATAOFF)
262 use_block = -1;
263 /*
264 * If we don't have enough free bytes but we can make enough
265 * by compacting out stale entries, we'll do that.
266 */
267 if ((char *)bestsp - (char *)&leaf->ents[be16_to_cpu(leaf->hdr.count)] <
268 needbytes && be16_to_cpu(leaf->hdr.stale) > 1) {
269 compact = 1;
270 }
271 /*
272 * Otherwise if we don't have enough free bytes we need to
273 * convert to node form.
274 */
275 else if ((char *)bestsp - (char *)&leaf->ents[be16_to_cpu(
276 leaf->hdr.count)] < needbytes) {
277 /*
278 * Just checking or no space reservation, give up.
279 */
280 if ((args->op_flags & XFS_DA_OP_JUSTCHECK) ||
281 args->total == 0) {
282 xfs_da_brelse(tp, lbp);
283 return XFS_ERROR(ENOSPC);
284 }
285 /*
286 * Convert to node form.
287 */
288 error = xfs_dir2_leaf_to_node(args, lbp);
289 xfs_da_buf_done(lbp);
290 if (error)
291 return error;
292 /*
293 * Then add the new entry.
294 */
295 return xfs_dir2_node_addname(args);
296 }
297 /*
298 * Otherwise it will fit without compaction.
299 */
300 else
301 compact = 0;
302 /*
303 * If just checking, then it will fit unless we needed to allocate
304 * a new data block.
305 */
306 if (args->op_flags & XFS_DA_OP_JUSTCHECK) {
307 xfs_da_brelse(tp, lbp);
308 return use_block == -1 ? XFS_ERROR(ENOSPC) : 0;
309 }
310 /*
311 * If no allocations are allowed, return now before we've
312 * changed anything.
313 */
314 if (args->total == 0 && use_block == -1) {
315 xfs_da_brelse(tp, lbp);
316 return XFS_ERROR(ENOSPC);
317 }
318 /*
319 * Need to compact the leaf entries, removing stale ones.
320 * Leave one stale entry behind - the one closest to our
321 * insertion index - and we'll shift that one to our insertion
322 * point later.
323 */
324 if (compact) {
325 xfs_dir2_leaf_compact_x1(lbp, &index, &lowstale, &highstale,
326 &lfloglow, &lfloghigh);
327 }
328 /*
329 * There are stale entries, so we'll need log-low and log-high
330 * impossibly bad values later.
331 */
332 else if (be16_to_cpu(leaf->hdr.stale)) {
333 lfloglow = be16_to_cpu(leaf->hdr.count);
334 lfloghigh = -1;
335 }
336 /*
337 * If there was no data block space found, we need to allocate
338 * a new one.
339 */
340 if (use_block == -1) {
341 /*
342 * Add the new data block.
343 */
344 if ((error = xfs_dir2_grow_inode(args, XFS_DIR2_DATA_SPACE,
345 &use_block))) {
346 xfs_da_brelse(tp, lbp);
347 return error;
348 }
349 /*
350 * Initialize the block.
351 */
352 if ((error = xfs_dir2_data_init(args, use_block, &dbp))) {
353 xfs_da_brelse(tp, lbp);
354 return error;
355 }
356 /*
357 * If we're adding a new data block on the end we need to
358 * extend the bests table. Copy it up one entry.
359 */
360 if (use_block >= be32_to_cpu(ltp->bestcount)) {
361 bestsp--;
362 memmove(&bestsp[0], &bestsp[1],
363 be32_to_cpu(ltp->bestcount) * sizeof(bestsp[0]));
364 be32_add_cpu(&ltp->bestcount, 1);
365 xfs_dir2_leaf_log_tail(tp, lbp);
366 xfs_dir2_leaf_log_bests(tp, lbp, 0, be32_to_cpu(ltp->bestcount) - 1);
367 }
368 /*
369 * If we're filling in a previously empty block just log it.
370 */
371 else
372 xfs_dir2_leaf_log_bests(tp, lbp, use_block, use_block);
373 data = dbp->data;
374 bestsp[use_block] = data->hdr.bestfree[0].length;
375 grown = 1;
376 }
377 /*
378 * Already had space in some data block.
379 * Just read that one in.
380 */
381 else {
382 if ((error =
383 xfs_da_read_buf(tp, dp, xfs_dir2_db_to_da(mp, use_block),
384 -1, &dbp, XFS_DATA_FORK))) {
385 xfs_da_brelse(tp, lbp);
386 return error;
387 }
388 data = dbp->data;
389 grown = 0;
390 }
391 xfs_dir2_data_check(dp, dbp);
392 /*
393 * Point to the biggest freespace in our data block.
394 */
395 dup = (xfs_dir2_data_unused_t *)
396 ((char *)data + be16_to_cpu(data->hdr.bestfree[0].offset));
397 ASSERT(be16_to_cpu(dup->length) >= length);
398 needscan = needlog = 0;
399 /*
400 * Mark the initial part of our freespace in use for the new entry.
401 */
402 xfs_dir2_data_use_free(tp, dbp, dup,
403 (xfs_dir2_data_aoff_t)((char *)dup - (char *)data), length,
404 &needlog, &needscan);
405 /*
406 * Initialize our new entry (at last).
407 */
408 dep = (xfs_dir2_data_entry_t *)dup;
409 dep->inumber = cpu_to_be64(args->inumber);
410 dep->namelen = args->namelen;
411 memcpy(dep->name, args->name, dep->namelen);
412 tagp = xfs_dir2_data_entry_tag_p(dep);
413 *tagp = cpu_to_be16((char *)dep - (char *)data);
414 /*
415 * Need to scan fix up the bestfree table.
416 */
417 if (needscan)
418 xfs_dir2_data_freescan(mp, data, &needlog);
419 /*
420 * Need to log the data block's header.
421 */
422 if (needlog)
423 xfs_dir2_data_log_header(tp, dbp);
424 xfs_dir2_data_log_entry(tp, dbp, dep);
425 /*
426 * If the bests table needs to be changed, do it.
427 * Log the change unless we've already done that.
428 */
429 if (be16_to_cpu(bestsp[use_block]) != be16_to_cpu(data->hdr.bestfree[0].length)) {
430 bestsp[use_block] = data->hdr.bestfree[0].length;
431 if (!grown)
432 xfs_dir2_leaf_log_bests(tp, lbp, use_block, use_block);
433 }
434 /*
435 * Now we need to make room to insert the leaf entry.
436 * If there are no stale entries, we just insert a hole at index.
437 */
438 if (!leaf->hdr.stale) {
439 /*
440 * lep is still good as the index leaf entry.
441 */
442 if (index < be16_to_cpu(leaf->hdr.count))
443 memmove(lep + 1, lep,
444 (be16_to_cpu(leaf->hdr.count) - index) * sizeof(*lep));
445 /*
446 * Record low and high logging indices for the leaf.
447 */
448 lfloglow = index;
449 lfloghigh = be16_to_cpu(leaf->hdr.count);
450 be16_add_cpu(&leaf->hdr.count, 1);
451 }
452 /*
453 * There are stale entries.
454 * We will use one of them for the new entry.
455 * It's probably not at the right location, so we'll have to
456 * shift some up or down first.
457 */
458 else {
459 /*
460 * If we didn't compact before, we need to find the nearest
461 * stale entries before and after our insertion point.
462 */
463 if (compact == 0) {
464 /*
465 * Find the first stale entry before the insertion
466 * point, if any.
467 */
468 for (lowstale = index - 1;
469 lowstale >= 0 &&
470 be32_to_cpu(leaf->ents[lowstale].address) !=
471 XFS_DIR2_NULL_DATAPTR;
472 lowstale--)
473 continue;
474 /*
475 * Find the next stale entry at or after the insertion
476 * point, if any. Stop if we go so far that the
477 * lowstale entry would be better.
478 */
479 for (highstale = index;
480 highstale < be16_to_cpu(leaf->hdr.count) &&
481 be32_to_cpu(leaf->ents[highstale].address) !=
482 XFS_DIR2_NULL_DATAPTR &&
483 (lowstale < 0 ||
484 index - lowstale - 1 >= highstale - index);
485 highstale++)
486 continue;
487 }
488 /*
489 * If the low one is better, use it.
490 */
491 if (lowstale >= 0 &&
492 (highstale == be16_to_cpu(leaf->hdr.count) ||
493 index - lowstale - 1 < highstale - index)) {
494 ASSERT(index - lowstale - 1 >= 0);
495 ASSERT(be32_to_cpu(leaf->ents[lowstale].address) ==
496 XFS_DIR2_NULL_DATAPTR);
497 /*
498 * Copy entries up to cover the stale entry
499 * and make room for the new entry.
500 */
501 if (index - lowstale - 1 > 0)
502 memmove(&leaf->ents[lowstale],
503 &leaf->ents[lowstale + 1],
504 (index - lowstale - 1) * sizeof(*lep));
505 lep = &leaf->ents[index - 1];
506 lfloglow = MIN(lowstale, lfloglow);
507 lfloghigh = MAX(index - 1, lfloghigh);
508 }
509 /*
510 * The high one is better, so use that one.
511 */
512 else {
513 ASSERT(highstale - index >= 0);
514 ASSERT(be32_to_cpu(leaf->ents[highstale].address) ==
515 XFS_DIR2_NULL_DATAPTR);
516 /*
517 * Copy entries down to cover the stale entry
518 * and make room for the new entry.
519 */
520 if (highstale - index > 0)
521 memmove(&leaf->ents[index + 1],
522 &leaf->ents[index],
523 (highstale - index) * sizeof(*lep));
524 lep = &leaf->ents[index];
525 lfloglow = MIN(index, lfloglow);
526 lfloghigh = MAX(highstale, lfloghigh);
527 }
528 be16_add_cpu(&leaf->hdr.stale, -1);
529 }
530 /*
531 * Fill in the new leaf entry.
532 */
533 lep->hashval = cpu_to_be32(args->hashval);
534 lep->address = cpu_to_be32(xfs_dir2_db_off_to_dataptr(mp, use_block,
535 be16_to_cpu(*tagp)));
536 /*
537 * Log the leaf fields and give up the buffers.
538 */
539 xfs_dir2_leaf_log_header(tp, lbp);
540 xfs_dir2_leaf_log_ents(tp, lbp, lfloglow, lfloghigh);
541 xfs_dir2_leaf_check(dp, lbp);
542 xfs_da_buf_done(lbp);
543 xfs_dir2_data_check(dp, dbp);
544 xfs_da_buf_done(dbp);
545 return 0;
546 }
547
548 #ifdef DEBUG
549 /*
550 * Check the internal consistency of a leaf1 block.
551 * Pop an assert if something is wrong.
552 */
553 STATIC void
554 xfs_dir2_leaf_check(
555 xfs_inode_t *dp, /* incore directory inode */
556 xfs_dabuf_t *bp) /* leaf's buffer */
557 {
558 int i; /* leaf index */
559 xfs_dir2_leaf_t *leaf; /* leaf structure */
560 xfs_dir2_leaf_tail_t *ltp; /* leaf tail pointer */
561 xfs_mount_t *mp; /* filesystem mount point */
562 int stale; /* count of stale leaves */
563
564 leaf = bp->data;
565 mp = dp->i_mount;
566 ASSERT(be16_to_cpu(leaf->hdr.info.magic) == XFS_DIR2_LEAF1_MAGIC);
567 /*
568 * This value is not restrictive enough.
569 * Should factor in the size of the bests table as well.
570 * We can deduce a value for that from di_size.
571 */
572 ASSERT(be16_to_cpu(leaf->hdr.count) <= xfs_dir2_max_leaf_ents(mp));
573 ltp = xfs_dir2_leaf_tail_p(mp, leaf);
574 /*
575 * Leaves and bests don't overlap.
576 */
577 ASSERT((char *)&leaf->ents[be16_to_cpu(leaf->hdr.count)] <=
578 (char *)xfs_dir2_leaf_bests_p(ltp));
579 /*
580 * Check hash value order, count stale entries.
581 */
582 for (i = stale = 0; i < be16_to_cpu(leaf->hdr.count); i++) {
583 if (i + 1 < be16_to_cpu(leaf->hdr.count))
584 ASSERT(be32_to_cpu(leaf->ents[i].hashval) <=
585 be32_to_cpu(leaf->ents[i + 1].hashval));
586 if (be32_to_cpu(leaf->ents[i].address) == XFS_DIR2_NULL_DATAPTR)
587 stale++;
588 }
589 ASSERT(be16_to_cpu(leaf->hdr.stale) == stale);
590 }
591 #endif /* DEBUG */
592
593 /*
594 * Compact out any stale entries in the leaf.
595 * Log the header and changed leaf entries, if any.
596 */
597 void
598 xfs_dir2_leaf_compact(
599 xfs_da_args_t *args, /* operation arguments */
600 xfs_dabuf_t *bp) /* leaf buffer */
601 {
602 int from; /* source leaf index */
603 xfs_dir2_leaf_t *leaf; /* leaf structure */
604 int loglow; /* first leaf entry to log */
605 int to; /* target leaf index */
606
607 leaf = bp->data;
608 if (!leaf->hdr.stale) {
609 return;
610 }
611 /*
612 * Compress out the stale entries in place.
613 */
614 for (from = to = 0, loglow = -1; from < be16_to_cpu(leaf->hdr.count); from++) {
615 if (be32_to_cpu(leaf->ents[from].address) == XFS_DIR2_NULL_DATAPTR)
616 continue;
617 /*
618 * Only actually copy the entries that are different.
619 */
620 if (from > to) {
621 if (loglow == -1)
622 loglow = to;
623 leaf->ents[to] = leaf->ents[from];
624 }
625 to++;
626 }
627 /*
628 * Update and log the header, log the leaf entries.
629 */
630 ASSERT(be16_to_cpu(leaf->hdr.stale) == from - to);
631 be16_add_cpu(&leaf->hdr.count, -(be16_to_cpu(leaf->hdr.stale)));
632 leaf->hdr.stale = 0;
633 xfs_dir2_leaf_log_header(args->trans, bp);
634 if (loglow != -1)
635 xfs_dir2_leaf_log_ents(args->trans, bp, loglow, to - 1);
636 }
637
638 /*
639 * Compact the leaf entries, removing stale ones.
640 * Leave one stale entry behind - the one closest to our
641 * insertion index - and the caller will shift that one to our insertion
642 * point later.
643 * Return new insertion index, where the remaining stale entry is,
644 * and leaf logging indices.
645 */
646 void
647 xfs_dir2_leaf_compact_x1(
648 xfs_dabuf_t *bp, /* leaf buffer */
649 int *indexp, /* insertion index */
650 int *lowstalep, /* out: stale entry before us */
651 int *highstalep, /* out: stale entry after us */
652 int *lowlogp, /* out: low log index */
653 int *highlogp) /* out: high log index */
654 {
655 int from; /* source copy index */
656 int highstale; /* stale entry at/after index */
657 int index; /* insertion index */
658 int keepstale; /* source index of kept stale */
659 xfs_dir2_leaf_t *leaf; /* leaf structure */
660 int lowstale; /* stale entry before index */
661 int newindex=0; /* new insertion index */
662 int to; /* destination copy index */
663
664 leaf = bp->data;
665 ASSERT(be16_to_cpu(leaf->hdr.stale) > 1);
666 index = *indexp;
667 /*
668 * Find the first stale entry before our index, if any.
669 */
670 for (lowstale = index - 1;
671 lowstale >= 0 &&
672 be32_to_cpu(leaf->ents[lowstale].address) != XFS_DIR2_NULL_DATAPTR;
673 lowstale--)
674 continue;
675 /*
676 * Find the first stale entry at or after our index, if any.
677 * Stop if the answer would be worse than lowstale.
678 */
679 for (highstale = index;
680 highstale < be16_to_cpu(leaf->hdr.count) &&
681 be32_to_cpu(leaf->ents[highstale].address) != XFS_DIR2_NULL_DATAPTR &&
682 (lowstale < 0 || index - lowstale > highstale - index);
683 highstale++)
684 continue;
685 /*
686 * Pick the better of lowstale and highstale.
687 */
688 if (lowstale >= 0 &&
689 (highstale == be16_to_cpu(leaf->hdr.count) ||
690 index - lowstale <= highstale - index))
691 keepstale = lowstale;
692 else
693 keepstale = highstale;
694 /*
695 * Copy the entries in place, removing all the stale entries
696 * except keepstale.
697 */
698 for (from = to = 0; from < be16_to_cpu(leaf->hdr.count); from++) {
699 /*
700 * Notice the new value of index.
701 */
702 if (index == from)
703 newindex = to;
704 if (from != keepstale &&
705 be32_to_cpu(leaf->ents[from].address) == XFS_DIR2_NULL_DATAPTR) {
706 if (from == to)
707 *lowlogp = to;
708 continue;
709 }
710 /*
711 * Record the new keepstale value for the insertion.
712 */
713 if (from == keepstale)
714 lowstale = highstale = to;
715 /*
716 * Copy only the entries that have moved.
717 */
718 if (from > to)
719 leaf->ents[to] = leaf->ents[from];
720 to++;
721 }
722 ASSERT(from > to);
723 /*
724 * If the insertion point was past the last entry,
725 * set the new insertion point accordingly.
726 */
727 if (index == from)
728 newindex = to;
729 *indexp = newindex;
730 /*
731 * Adjust the leaf header values.
732 */
733 be16_add_cpu(&leaf->hdr.count, -(from - to));
734 leaf->hdr.stale = cpu_to_be16(1);
735 /*
736 * Remember the low/high stale value only in the "right"
737 * direction.
738 */
739 if (lowstale >= newindex)
740 lowstale = -1;
741 else
742 highstale = be16_to_cpu(leaf->hdr.count);
743 *highlogp = be16_to_cpu(leaf->hdr.count) - 1;
744 *lowstalep = lowstale;
745 *highstalep = highstale;
746 }
747
748 /*
749 * Getdents (readdir) for leaf and node directories.
750 * This reads the data blocks only, so is the same for both forms.
751 */
752 int /* error */
753 xfs_dir2_leaf_getdents(
754 xfs_inode_t *dp, /* incore directory inode */
755 void *dirent,
756 size_t bufsize,
757 xfs_off_t *offset,
758 filldir_t filldir)
759 {
760 xfs_dabuf_t *bp; /* data block buffer */
761 int byteoff; /* offset in current block */
762 xfs_dir2_db_t curdb; /* db for current block */
763 xfs_dir2_off_t curoff; /* current overall offset */
764 xfs_dir2_data_t *data; /* data block structure */
765 xfs_dir2_data_entry_t *dep; /* data entry */
766 xfs_dir2_data_unused_t *dup; /* unused entry */
767 int error = 0; /* error return value */
768 int i; /* temporary loop index */
769 int j; /* temporary loop index */
770 int length; /* temporary length value */
771 xfs_bmbt_irec_t *map; /* map vector for blocks */
772 xfs_extlen_t map_blocks; /* number of fsbs in map */
773 xfs_dablk_t map_off; /* last mapped file offset */
774 int map_size; /* total entries in *map */
775 int map_valid; /* valid entries in *map */
776 xfs_mount_t *mp; /* filesystem mount point */
777 xfs_dir2_off_t newoff; /* new curoff after new blk */
778 int nmap; /* mappings to ask xfs_bmapi */
779 char *ptr = NULL; /* pointer to current data */
780 int ra_current; /* number of read-ahead blks */
781 int ra_index; /* *map index for read-ahead */
782 int ra_offset; /* map entry offset for ra */
783 int ra_want; /* readahead count wanted */
784
785 /*
786 * If the offset is at or past the largest allowed value,
787 * give up right away.
788 */
789 if (*offset >= XFS_DIR2_MAX_DATAPTR)
790 return 0;
791
792 mp = dp->i_mount;
793
794 /*
795 * Set up to bmap a number of blocks based on the caller's
796 * buffer size, the directory block size, and the filesystem
797 * block size.
798 */
799 map_size = howmany(bufsize + mp->m_dirblksize, mp->m_sb.sb_blocksize);
800 map = kmem_alloc(map_size * sizeof(*map), KM_SLEEP);
801 map_valid = ra_index = ra_offset = ra_current = map_blocks = 0;
802 bp = NULL;
803
804 /*
805 * Inside the loop we keep the main offset value as a byte offset
806 * in the directory file.
807 */
808 curoff = xfs_dir2_dataptr_to_byte(mp, *offset);
809
810 /*
811 * Force this conversion through db so we truncate the offset
812 * down to get the start of the data block.
813 */
814 map_off = xfs_dir2_db_to_da(mp, xfs_dir2_byte_to_db(mp, curoff));
815 /*
816 * Loop over directory entries until we reach the end offset.
817 * Get more blocks and readahead as necessary.
818 */
819 while (curoff < XFS_DIR2_LEAF_OFFSET) {
820 /*
821 * If we have no buffer, or we're off the end of the
822 * current buffer, need to get another one.
823 */
824 if (!bp || ptr >= (char *)bp->data + mp->m_dirblksize) {
825 /*
826 * If we have a buffer, we need to release it and
827 * take it out of the mapping.
828 */
829 if (bp) {
830 xfs_da_brelse(NULL, bp);
831 bp = NULL;
832 map_blocks -= mp->m_dirblkfsbs;
833 /*
834 * Loop to get rid of the extents for the
835 * directory block.
836 */
837 for (i = mp->m_dirblkfsbs; i > 0; ) {
838 j = MIN((int)map->br_blockcount, i);
839 map->br_blockcount -= j;
840 map->br_startblock += j;
841 map->br_startoff += j;
842 /*
843 * If mapping is done, pitch it from
844 * the table.
845 */
846 if (!map->br_blockcount && --map_valid)
847 memmove(&map[0], &map[1],
848 sizeof(map[0]) *
849 map_valid);
850 i -= j;
851 }
852 }
853 /*
854 * Recalculate the readahead blocks wanted.
855 */
856 ra_want = howmany(bufsize + mp->m_dirblksize,
857 mp->m_sb.sb_blocksize) - 1;
858 ASSERT(ra_want >= 0);
859
860 /*
861 * If we don't have as many as we want, and we haven't
862 * run out of data blocks, get some more mappings.
863 */
864 if (1 + ra_want > map_blocks &&
865 map_off <
866 xfs_dir2_byte_to_da(mp, XFS_DIR2_LEAF_OFFSET)) {
867 /*
868 * Get more bmaps, fill in after the ones
869 * we already have in the table.
870 */
871 nmap = map_size - map_valid;
872 error = xfs_bmapi(NULL, dp,
873 map_off,
874 xfs_dir2_byte_to_da(mp,
875 XFS_DIR2_LEAF_OFFSET) - map_off,
876 XFS_BMAPI_METADATA, NULL, 0,
877 &map[map_valid], &nmap, NULL, NULL);
878 /*
879 * Don't know if we should ignore this or
880 * try to return an error.
881 * The trouble with returning errors
882 * is that readdir will just stop without
883 * actually passing the error through.
884 */
885 if (error)
886 break; /* XXX */
887 /*
888 * If we got all the mappings we asked for,
889 * set the final map offset based on the
890 * last bmap value received.
891 * Otherwise, we've reached the end.
892 */
893 if (nmap == map_size - map_valid)
894 map_off =
895 map[map_valid + nmap - 1].br_startoff +
896 map[map_valid + nmap - 1].br_blockcount;
897 else
898 map_off =
899 xfs_dir2_byte_to_da(mp,
900 XFS_DIR2_LEAF_OFFSET);
901 /*
902 * Look for holes in the mapping, and
903 * eliminate them. Count up the valid blocks.
904 */
905 for (i = map_valid; i < map_valid + nmap; ) {
906 if (map[i].br_startblock ==
907 HOLESTARTBLOCK) {
908 nmap--;
909 length = map_valid + nmap - i;
910 if (length)
911 memmove(&map[i],
912 &map[i + 1],
913 sizeof(map[i]) *
914 length);
915 } else {
916 map_blocks +=
917 map[i].br_blockcount;
918 i++;
919 }
920 }
921 map_valid += nmap;
922 }
923 /*
924 * No valid mappings, so no more data blocks.
925 */
926 if (!map_valid) {
927 curoff = xfs_dir2_da_to_byte(mp, map_off);
928 break;
929 }
930 /*
931 * Read the directory block starting at the first
932 * mapping.
933 */
934 curdb = xfs_dir2_da_to_db(mp, map->br_startoff);
935 error = xfs_da_read_buf(NULL, dp, map->br_startoff,
936 map->br_blockcount >= mp->m_dirblkfsbs ?
937 XFS_FSB_TO_DADDR(mp, map->br_startblock) :
938 -1,
939 &bp, XFS_DATA_FORK);
940 /*
941 * Should just skip over the data block instead
942 * of giving up.
943 */
944 if (error)
945 break; /* XXX */
946 /*
947 * Adjust the current amount of read-ahead: we just
948 * read a block that was previously ra.
949 */
950 if (ra_current)
951 ra_current -= mp->m_dirblkfsbs;
952 /*
953 * Do we need more readahead?
954 */
955 for (ra_index = ra_offset = i = 0;
956 ra_want > ra_current && i < map_blocks;
957 i += mp->m_dirblkfsbs) {
958 ASSERT(ra_index < map_valid);
959 /*
960 * Read-ahead a contiguous directory block.
961 */
962 if (i > ra_current &&
963 map[ra_index].br_blockcount >=
964 mp->m_dirblkfsbs) {
965 xfs_baread(mp->m_ddev_targp,
966 XFS_FSB_TO_DADDR(mp,
967 map[ra_index].br_startblock +
968 ra_offset),
969 (int)BTOBB(mp->m_dirblksize));
970 ra_current = i;
971 }
972 /*
973 * Read-ahead a non-contiguous directory block.
974 * This doesn't use our mapping, but this
975 * is a very rare case.
976 */
977 else if (i > ra_current) {
978 (void)xfs_da_reada_buf(NULL, dp,
979 map[ra_index].br_startoff +
980 ra_offset, XFS_DATA_FORK);
981 ra_current = i;
982 }
983 /*
984 * Advance offset through the mapping table.
985 */
986 for (j = 0; j < mp->m_dirblkfsbs; j++) {
987 /*
988 * The rest of this extent but not
989 * more than a dir block.
990 */
991 length = MIN(mp->m_dirblkfsbs,
992 (int)(map[ra_index].br_blockcount -
993 ra_offset));
994 j += length;
995 ra_offset += length;
996 /*
997 * Advance to the next mapping if
998 * this one is used up.
999 */
1000 if (ra_offset ==
1001 map[ra_index].br_blockcount) {
1002 ra_offset = 0;
1003 ra_index++;
1004 }
1005 }
1006 }
1007 /*
1008 * Having done a read, we need to set a new offset.
1009 */
1010 newoff = xfs_dir2_db_off_to_byte(mp, curdb, 0);
1011 /*
1012 * Start of the current block.
1013 */
1014 if (curoff < newoff)
1015 curoff = newoff;
1016 /*
1017 * Make sure we're in the right block.
1018 */
1019 else if (curoff > newoff)
1020 ASSERT(xfs_dir2_byte_to_db(mp, curoff) ==
1021 curdb);
1022 data = bp->data;
1023 xfs_dir2_data_check(dp, bp);
1024 /*
1025 * Find our position in the block.
1026 */
1027 ptr = (char *)&data->u;
1028 byteoff = xfs_dir2_byte_to_off(mp, curoff);
1029 /*
1030 * Skip past the header.
1031 */
1032 if (byteoff == 0)
1033 curoff += (uint)sizeof(data->hdr);
1034 /*
1035 * Skip past entries until we reach our offset.
1036 */
1037 else {
1038 while ((char *)ptr - (char *)data < byteoff) {
1039 dup = (xfs_dir2_data_unused_t *)ptr;
1040
1041 if (be16_to_cpu(dup->freetag)
1042 == XFS_DIR2_DATA_FREE_TAG) {
1043
1044 length = be16_to_cpu(dup->length);
1045 ptr += length;
1046 continue;
1047 }
1048 dep = (xfs_dir2_data_entry_t *)ptr;
1049 length =
1050 xfs_dir2_data_entsize(dep->namelen);
1051 ptr += length;
1052 }
1053 /*
1054 * Now set our real offset.
1055 */
1056 curoff =
1057 xfs_dir2_db_off_to_byte(mp,
1058 xfs_dir2_byte_to_db(mp, curoff),
1059 (char *)ptr - (char *)data);
1060 if (ptr >= (char *)data + mp->m_dirblksize) {
1061 continue;
1062 }
1063 }
1064 }
1065 /*
1066 * We have a pointer to an entry.
1067 * Is it a live one?
1068 */
1069 dup = (xfs_dir2_data_unused_t *)ptr;
1070 /*
1071 * No, it's unused, skip over it.
1072 */
1073 if (be16_to_cpu(dup->freetag) == XFS_DIR2_DATA_FREE_TAG) {
1074 length = be16_to_cpu(dup->length);
1075 ptr += length;
1076 curoff += length;
1077 continue;
1078 }
1079
1080 dep = (xfs_dir2_data_entry_t *)ptr;
1081 length = xfs_dir2_data_entsize(dep->namelen);
1082
1083 if (filldir(dirent, (char *)dep->name, dep->namelen,
1084 xfs_dir2_byte_to_dataptr(mp, curoff) & 0x7fffffff,
1085 be64_to_cpu(dep->inumber), DT_UNKNOWN))
1086 break;
1087
1088 /*
1089 * Advance to next entry in the block.
1090 */
1091 ptr += length;
1092 curoff += length;
1093 /* bufsize may have just been a guess; don't go negative */
1094 bufsize = bufsize > length ? bufsize - length : 0;
1095 }
1096
1097 /*
1098 * All done. Set output offset value to current offset.
1099 */
1100 if (curoff > xfs_dir2_dataptr_to_byte(mp, XFS_DIR2_MAX_DATAPTR))
1101 *offset = XFS_DIR2_MAX_DATAPTR & 0x7fffffff;
1102 else
1103 *offset = xfs_dir2_byte_to_dataptr(mp, curoff) & 0x7fffffff;
1104 kmem_free(map);
1105 if (bp)
1106 xfs_da_brelse(NULL, bp);
1107 return error;
1108 }
1109
1110 /*
1111 * Initialize a new leaf block, leaf1 or leafn magic accepted.
1112 */
1113 int
1114 xfs_dir2_leaf_init(
1115 xfs_da_args_t *args, /* operation arguments */
1116 xfs_dir2_db_t bno, /* directory block number */
1117 xfs_dabuf_t **bpp, /* out: leaf buffer */
1118 int magic) /* magic number for block */
1119 {
1120 xfs_dabuf_t *bp; /* leaf buffer */
1121 xfs_inode_t *dp; /* incore directory inode */
1122 int error; /* error return code */
1123 xfs_dir2_leaf_t *leaf; /* leaf structure */
1124 xfs_dir2_leaf_tail_t *ltp; /* leaf tail structure */
1125 xfs_mount_t *mp; /* filesystem mount point */
1126 xfs_trans_t *tp; /* transaction pointer */
1127
1128 dp = args->dp;
1129 ASSERT(dp != NULL);
1130 tp = args->trans;
1131 mp = dp->i_mount;
1132 ASSERT(bno >= XFS_DIR2_LEAF_FIRSTDB(mp) &&
1133 bno < XFS_DIR2_FREE_FIRSTDB(mp));
1134 /*
1135 * Get the buffer for the block.
1136 */
1137 error = xfs_da_get_buf(tp, dp, xfs_dir2_db_to_da(mp, bno), -1, &bp,
1138 XFS_DATA_FORK);
1139 if (error) {
1140 return error;
1141 }
1142 ASSERT(bp != NULL);
1143 leaf = bp->data;
1144 /*
1145 * Initialize the header.
1146 */
1147 leaf->hdr.info.magic = cpu_to_be16(magic);
1148 leaf->hdr.info.forw = 0;
1149 leaf->hdr.info.back = 0;
1150 leaf->hdr.count = 0;
1151 leaf->hdr.stale = 0;
1152 xfs_dir2_leaf_log_header(tp, bp);
1153 /*
1154 * If it's a leaf-format directory initialize the tail.
1155 * In this case our caller has the real bests table to copy into
1156 * the block.
1157 */
1158 if (magic == XFS_DIR2_LEAF1_MAGIC) {
1159 ltp = xfs_dir2_leaf_tail_p(mp, leaf);
1160 ltp->bestcount = 0;
1161 xfs_dir2_leaf_log_tail(tp, bp);
1162 }
1163 *bpp = bp;
1164 return 0;
1165 }
1166
1167 /*
1168 * Log the bests entries indicated from a leaf1 block.
1169 */
1170 static void
1171 xfs_dir2_leaf_log_bests(
1172 xfs_trans_t *tp, /* transaction pointer */
1173 xfs_dabuf_t *bp, /* leaf buffer */
1174 int first, /* first entry to log */
1175 int last) /* last entry to log */
1176 {
1177 __be16 *firstb; /* pointer to first entry */
1178 __be16 *lastb; /* pointer to last entry */
1179 xfs_dir2_leaf_t *leaf; /* leaf structure */
1180 xfs_dir2_leaf_tail_t *ltp; /* leaf tail structure */
1181
1182 leaf = bp->data;
1183 ASSERT(be16_to_cpu(leaf->hdr.info.magic) == XFS_DIR2_LEAF1_MAGIC);
1184 ltp = xfs_dir2_leaf_tail_p(tp->t_mountp, leaf);
1185 firstb = xfs_dir2_leaf_bests_p(ltp) + first;
1186 lastb = xfs_dir2_leaf_bests_p(ltp) + last;
1187 xfs_da_log_buf(tp, bp, (uint)((char *)firstb - (char *)leaf),
1188 (uint)((char *)lastb - (char *)leaf + sizeof(*lastb) - 1));
1189 }
1190
1191 /*
1192 * Log the leaf entries indicated from a leaf1 or leafn block.
1193 */
1194 void
1195 xfs_dir2_leaf_log_ents(
1196 xfs_trans_t *tp, /* transaction pointer */
1197 xfs_dabuf_t *bp, /* leaf buffer */
1198 int first, /* first entry to log */
1199 int last) /* last entry to log */
1200 {
1201 xfs_dir2_leaf_entry_t *firstlep; /* pointer to first entry */
1202 xfs_dir2_leaf_entry_t *lastlep; /* pointer to last entry */
1203 xfs_dir2_leaf_t *leaf; /* leaf structure */
1204
1205 leaf = bp->data;
1206 ASSERT(be16_to_cpu(leaf->hdr.info.magic) == XFS_DIR2_LEAF1_MAGIC ||
1207 be16_to_cpu(leaf->hdr.info.magic) == XFS_DIR2_LEAFN_MAGIC);
1208 firstlep = &leaf->ents[first];
1209 lastlep = &leaf->ents[last];
1210 xfs_da_log_buf(tp, bp, (uint)((char *)firstlep - (char *)leaf),
1211 (uint)((char *)lastlep - (char *)leaf + sizeof(*lastlep) - 1));
1212 }
1213
1214 /*
1215 * Log the header of the leaf1 or leafn block.
1216 */
1217 void
1218 xfs_dir2_leaf_log_header(
1219 xfs_trans_t *tp, /* transaction pointer */
1220 xfs_dabuf_t *bp) /* leaf buffer */
1221 {
1222 xfs_dir2_leaf_t *leaf; /* leaf structure */
1223
1224 leaf = bp->data;
1225 ASSERT(be16_to_cpu(leaf->hdr.info.magic) == XFS_DIR2_LEAF1_MAGIC ||
1226 be16_to_cpu(leaf->hdr.info.magic) == XFS_DIR2_LEAFN_MAGIC);
1227 xfs_da_log_buf(tp, bp, (uint)((char *)&leaf->hdr - (char *)leaf),
1228 (uint)(sizeof(leaf->hdr) - 1));
1229 }
1230
1231 /*
1232 * Log the tail of the leaf1 block.
1233 */
1234 STATIC void
1235 xfs_dir2_leaf_log_tail(
1236 xfs_trans_t *tp, /* transaction pointer */
1237 xfs_dabuf_t *bp) /* leaf buffer */
1238 {
1239 xfs_dir2_leaf_t *leaf; /* leaf structure */
1240 xfs_dir2_leaf_tail_t *ltp; /* leaf tail structure */
1241 xfs_mount_t *mp; /* filesystem mount point */
1242
1243 mp = tp->t_mountp;
1244 leaf = bp->data;
1245 ASSERT(be16_to_cpu(leaf->hdr.info.magic) == XFS_DIR2_LEAF1_MAGIC);
1246 ltp = xfs_dir2_leaf_tail_p(mp, leaf);
1247 xfs_da_log_buf(tp, bp, (uint)((char *)ltp - (char *)leaf),
1248 (uint)(mp->m_dirblksize - 1));
1249 }
1250
1251 /*
1252 * Look up the entry referred to by args in the leaf format directory.
1253 * Most of the work is done by the xfs_dir2_leaf_lookup_int routine which
1254 * is also used by the node-format code.
1255 */
1256 int
1257 xfs_dir2_leaf_lookup(
1258 xfs_da_args_t *args) /* operation arguments */
1259 {
1260 xfs_dabuf_t *dbp; /* data block buffer */
1261 xfs_dir2_data_entry_t *dep; /* data block entry */
1262 xfs_inode_t *dp; /* incore directory inode */
1263 int error; /* error return code */
1264 int index; /* found entry index */
1265 xfs_dabuf_t *lbp; /* leaf buffer */
1266 xfs_dir2_leaf_t *leaf; /* leaf structure */
1267 xfs_dir2_leaf_entry_t *lep; /* leaf entry */
1268 xfs_trans_t *tp; /* transaction pointer */
1269
1270 trace_xfs_dir2_leaf_lookup(args);
1271
1272 /*
1273 * Look up name in the leaf block, returning both buffers and index.
1274 */
1275 if ((error = xfs_dir2_leaf_lookup_int(args, &lbp, &index, &dbp))) {
1276 return error;
1277 }
1278 tp = args->trans;
1279 dp = args->dp;
1280 xfs_dir2_leaf_check(dp, lbp);
1281 leaf = lbp->data;
1282 /*
1283 * Get to the leaf entry and contained data entry address.
1284 */
1285 lep = &leaf->ents[index];
1286 /*
1287 * Point to the data entry.
1288 */
1289 dep = (xfs_dir2_data_entry_t *)
1290 ((char *)dbp->data +
1291 xfs_dir2_dataptr_to_off(dp->i_mount, be32_to_cpu(lep->address)));
1292 /*
1293 * Return the found inode number & CI name if appropriate
1294 */
1295 args->inumber = be64_to_cpu(dep->inumber);
1296 error = xfs_dir_cilookup_result(args, dep->name, dep->namelen);
1297 xfs_da_brelse(tp, dbp);
1298 xfs_da_brelse(tp, lbp);
1299 return XFS_ERROR(error);
1300 }
1301
1302 /*
1303 * Look up name/hash in the leaf block.
1304 * Fill in indexp with the found index, and dbpp with the data buffer.
1305 * If not found dbpp will be NULL, and ENOENT comes back.
1306 * lbpp will always be filled in with the leaf buffer unless there's an error.
1307 */
1308 static int /* error */
1309 xfs_dir2_leaf_lookup_int(
1310 xfs_da_args_t *args, /* operation arguments */
1311 xfs_dabuf_t **lbpp, /* out: leaf buffer */
1312 int *indexp, /* out: index in leaf block */
1313 xfs_dabuf_t **dbpp) /* out: data buffer */
1314 {
1315 xfs_dir2_db_t curdb = -1; /* current data block number */
1316 xfs_dabuf_t *dbp = NULL; /* data buffer */
1317 xfs_dir2_data_entry_t *dep; /* data entry */
1318 xfs_inode_t *dp; /* incore directory inode */
1319 int error; /* error return code */
1320 int index; /* index in leaf block */
1321 xfs_dabuf_t *lbp; /* leaf buffer */
1322 xfs_dir2_leaf_entry_t *lep; /* leaf entry */
1323 xfs_dir2_leaf_t *leaf; /* leaf structure */
1324 xfs_mount_t *mp; /* filesystem mount point */
1325 xfs_dir2_db_t newdb; /* new data block number */
1326 xfs_trans_t *tp; /* transaction pointer */
1327 xfs_dir2_db_t cidb = -1; /* case match data block no. */
1328 enum xfs_dacmp cmp; /* name compare result */
1329
1330 dp = args->dp;
1331 tp = args->trans;
1332 mp = dp->i_mount;
1333 /*
1334 * Read the leaf block into the buffer.
1335 */
1336 error = xfs_da_read_buf(tp, dp, mp->m_dirleafblk, -1, &lbp,
1337 XFS_DATA_FORK);
1338 if (error)
1339 return error;
1340 *lbpp = lbp;
1341 leaf = lbp->data;
1342 xfs_dir2_leaf_check(dp, lbp);
1343 /*
1344 * Look for the first leaf entry with our hash value.
1345 */
1346 index = xfs_dir2_leaf_search_hash(args, lbp);
1347 /*
1348 * Loop over all the entries with the right hash value
1349 * looking to match the name.
1350 */
1351 for (lep = &leaf->ents[index]; index < be16_to_cpu(leaf->hdr.count) &&
1352 be32_to_cpu(lep->hashval) == args->hashval;
1353 lep++, index++) {
1354 /*
1355 * Skip over stale leaf entries.
1356 */
1357 if (be32_to_cpu(lep->address) == XFS_DIR2_NULL_DATAPTR)
1358 continue;
1359 /*
1360 * Get the new data block number.
1361 */
1362 newdb = xfs_dir2_dataptr_to_db(mp, be32_to_cpu(lep->address));
1363 /*
1364 * If it's not the same as the old data block number,
1365 * need to pitch the old one and read the new one.
1366 */
1367 if (newdb != curdb) {
1368 if (dbp)
1369 xfs_da_brelse(tp, dbp);
1370 error = xfs_da_read_buf(tp, dp,
1371 xfs_dir2_db_to_da(mp, newdb),
1372 -1, &dbp, XFS_DATA_FORK);
1373 if (error) {
1374 xfs_da_brelse(tp, lbp);
1375 return error;
1376 }
1377 xfs_dir2_data_check(dp, dbp);
1378 curdb = newdb;
1379 }
1380 /*
1381 * Point to the data entry.
1382 */
1383 dep = (xfs_dir2_data_entry_t *)((char *)dbp->data +
1384 xfs_dir2_dataptr_to_off(mp, be32_to_cpu(lep->address)));
1385 /*
1386 * Compare name and if it's an exact match, return the index
1387 * and buffer. If it's the first case-insensitive match, store
1388 * the index and buffer and continue looking for an exact match.
1389 */
1390 cmp = mp->m_dirnameops->compname(args, dep->name, dep->namelen);
1391 if (cmp != XFS_CMP_DIFFERENT && cmp != args->cmpresult) {
1392 args->cmpresult = cmp;
1393 *indexp = index;
1394 /* case exact match: return the current buffer. */
1395 if (cmp == XFS_CMP_EXACT) {
1396 *dbpp = dbp;
1397 return 0;
1398 }
1399 cidb = curdb;
1400 }
1401 }
1402 ASSERT(args->op_flags & XFS_DA_OP_OKNOENT);
1403 /*
1404 * Here, we can only be doing a lookup (not a rename or remove).
1405 * If a case-insensitive match was found earlier, re-read the
1406 * appropriate data block if required and return it.
1407 */
1408 if (args->cmpresult == XFS_CMP_CASE) {
1409 ASSERT(cidb != -1);
1410 if (cidb != curdb) {
1411 xfs_da_brelse(tp, dbp);
1412 error = xfs_da_read_buf(tp, dp,
1413 xfs_dir2_db_to_da(mp, cidb),
1414 -1, &dbp, XFS_DATA_FORK);
1415 if (error) {
1416 xfs_da_brelse(tp, lbp);
1417 return error;
1418 }
1419 }
1420 *dbpp = dbp;
1421 return 0;
1422 }
1423 /*
1424 * No match found, return ENOENT.
1425 */
1426 ASSERT(cidb == -1);
1427 if (dbp)
1428 xfs_da_brelse(tp, dbp);
1429 xfs_da_brelse(tp, lbp);
1430 return XFS_ERROR(ENOENT);
1431 }
1432
1433 /*
1434 * Remove an entry from a leaf format directory.
1435 */
1436 int /* error */
1437 xfs_dir2_leaf_removename(
1438 xfs_da_args_t *args) /* operation arguments */
1439 {
1440 __be16 *bestsp; /* leaf block best freespace */
1441 xfs_dir2_data_t *data; /* data block structure */
1442 xfs_dir2_db_t db; /* data block number */
1443 xfs_dabuf_t *dbp; /* data block buffer */
1444 xfs_dir2_data_entry_t *dep; /* data entry structure */
1445 xfs_inode_t *dp; /* incore directory inode */
1446 int error; /* error return code */
1447 xfs_dir2_db_t i; /* temporary data block # */
1448 int index; /* index into leaf entries */
1449 xfs_dabuf_t *lbp; /* leaf buffer */
1450 xfs_dir2_leaf_t *leaf; /* leaf structure */
1451 xfs_dir2_leaf_entry_t *lep; /* leaf entry */
1452 xfs_dir2_leaf_tail_t *ltp; /* leaf tail structure */
1453 xfs_mount_t *mp; /* filesystem mount point */
1454 int needlog; /* need to log data header */
1455 int needscan; /* need to rescan data frees */
1456 xfs_dir2_data_off_t oldbest; /* old value of best free */
1457 xfs_trans_t *tp; /* transaction pointer */
1458
1459 trace_xfs_dir2_leaf_removename(args);
1460
1461 /*
1462 * Lookup the leaf entry, get the leaf and data blocks read in.
1463 */
1464 if ((error = xfs_dir2_leaf_lookup_int(args, &lbp, &index, &dbp))) {
1465 return error;
1466 }
1467 dp = args->dp;
1468 tp = args->trans;
1469 mp = dp->i_mount;
1470 leaf = lbp->data;
1471 data = dbp->data;
1472 xfs_dir2_data_check(dp, dbp);
1473 /*
1474 * Point to the leaf entry, use that to point to the data entry.
1475 */
1476 lep = &leaf->ents[index];
1477 db = xfs_dir2_dataptr_to_db(mp, be32_to_cpu(lep->address));
1478 dep = (xfs_dir2_data_entry_t *)
1479 ((char *)data + xfs_dir2_dataptr_to_off(mp, be32_to_cpu(lep->address)));
1480 needscan = needlog = 0;
1481 oldbest = be16_to_cpu(data->hdr.bestfree[0].length);
1482 ltp = xfs_dir2_leaf_tail_p(mp, leaf);
1483 bestsp = xfs_dir2_leaf_bests_p(ltp);
1484 ASSERT(be16_to_cpu(bestsp[db]) == oldbest);
1485 /*
1486 * Mark the former data entry unused.
1487 */
1488 xfs_dir2_data_make_free(tp, dbp,
1489 (xfs_dir2_data_aoff_t)((char *)dep - (char *)data),
1490 xfs_dir2_data_entsize(dep->namelen), &needlog, &needscan);
1491 /*
1492 * We just mark the leaf entry stale by putting a null in it.
1493 */
1494 be16_add_cpu(&leaf->hdr.stale, 1);
1495 xfs_dir2_leaf_log_header(tp, lbp);
1496 lep->address = cpu_to_be32(XFS_DIR2_NULL_DATAPTR);
1497 xfs_dir2_leaf_log_ents(tp, lbp, index, index);
1498 /*
1499 * Scan the freespace in the data block again if necessary,
1500 * log the data block header if necessary.
1501 */
1502 if (needscan)
1503 xfs_dir2_data_freescan(mp, data, &needlog);
1504 if (needlog)
1505 xfs_dir2_data_log_header(tp, dbp);
1506 /*
1507 * If the longest freespace in the data block has changed,
1508 * put the new value in the bests table and log that.
1509 */
1510 if (be16_to_cpu(data->hdr.bestfree[0].length) != oldbest) {
1511 bestsp[db] = data->hdr.bestfree[0].length;
1512 xfs_dir2_leaf_log_bests(tp, lbp, db, db);
1513 }
1514 xfs_dir2_data_check(dp, dbp);
1515 /*
1516 * If the data block is now empty then get rid of the data block.
1517 */
1518 if (be16_to_cpu(data->hdr.bestfree[0].length) ==
1519 mp->m_dirblksize - (uint)sizeof(data->hdr)) {
1520 ASSERT(db != mp->m_dirdatablk);
1521 if ((error = xfs_dir2_shrink_inode(args, db, dbp))) {
1522 /*
1523 * Nope, can't get rid of it because it caused
1524 * allocation of a bmap btree block to do so.
1525 * Just go on, returning success, leaving the
1526 * empty block in place.
1527 */
1528 if (error == ENOSPC && args->total == 0) {
1529 xfs_da_buf_done(dbp);
1530 error = 0;
1531 }
1532 xfs_dir2_leaf_check(dp, lbp);
1533 xfs_da_buf_done(lbp);
1534 return error;
1535 }
1536 dbp = NULL;
1537 /*
1538 * If this is the last data block then compact the
1539 * bests table by getting rid of entries.
1540 */
1541 if (db == be32_to_cpu(ltp->bestcount) - 1) {
1542 /*
1543 * Look for the last active entry (i).
1544 */
1545 for (i = db - 1; i > 0; i--) {
1546 if (be16_to_cpu(bestsp[i]) != NULLDATAOFF)
1547 break;
1548 }
1549 /*
1550 * Copy the table down so inactive entries at the
1551 * end are removed.
1552 */
1553 memmove(&bestsp[db - i], bestsp,
1554 (be32_to_cpu(ltp->bestcount) - (db - i)) * sizeof(*bestsp));
1555 be32_add_cpu(&ltp->bestcount, -(db - i));
1556 xfs_dir2_leaf_log_tail(tp, lbp);
1557 xfs_dir2_leaf_log_bests(tp, lbp, 0, be32_to_cpu(ltp->bestcount) - 1);
1558 } else
1559 bestsp[db] = cpu_to_be16(NULLDATAOFF);
1560 }
1561 /*
1562 * If the data block was not the first one, drop it.
1563 */
1564 else if (db != mp->m_dirdatablk && dbp != NULL) {
1565 xfs_da_buf_done(dbp);
1566 dbp = NULL;
1567 }
1568 xfs_dir2_leaf_check(dp, lbp);
1569 /*
1570 * See if we can convert to block form.
1571 */
1572 return xfs_dir2_leaf_to_block(args, lbp, dbp);
1573 }
1574
1575 /*
1576 * Replace the inode number in a leaf format directory entry.
1577 */
1578 int /* error */
1579 xfs_dir2_leaf_replace(
1580 xfs_da_args_t *args) /* operation arguments */
1581 {
1582 xfs_dabuf_t *dbp; /* data block buffer */
1583 xfs_dir2_data_entry_t *dep; /* data block entry */
1584 xfs_inode_t *dp; /* incore directory inode */
1585 int error; /* error return code */
1586 int index; /* index of leaf entry */
1587 xfs_dabuf_t *lbp; /* leaf buffer */
1588 xfs_dir2_leaf_t *leaf; /* leaf structure */
1589 xfs_dir2_leaf_entry_t *lep; /* leaf entry */
1590 xfs_trans_t *tp; /* transaction pointer */
1591
1592 trace_xfs_dir2_leaf_replace(args);
1593
1594 /*
1595 * Look up the entry.
1596 */
1597 if ((error = xfs_dir2_leaf_lookup_int(args, &lbp, &index, &dbp))) {
1598 return error;
1599 }
1600 dp = args->dp;
1601 leaf = lbp->data;
1602 /*
1603 * Point to the leaf entry, get data address from it.
1604 */
1605 lep = &leaf->ents[index];
1606 /*
1607 * Point to the data entry.
1608 */
1609 dep = (xfs_dir2_data_entry_t *)
1610 ((char *)dbp->data +
1611 xfs_dir2_dataptr_to_off(dp->i_mount, be32_to_cpu(lep->address)));
1612 ASSERT(args->inumber != be64_to_cpu(dep->inumber));
1613 /*
1614 * Put the new inode number in, log it.
1615 */
1616 dep->inumber = cpu_to_be64(args->inumber);
1617 tp = args->trans;
1618 xfs_dir2_data_log_entry(tp, dbp, dep);
1619 xfs_da_buf_done(dbp);
1620 xfs_dir2_leaf_check(dp, lbp);
1621 xfs_da_brelse(tp, lbp);
1622 return 0;
1623 }
1624
1625 /*
1626 * Return index in the leaf block (lbp) which is either the first
1627 * one with this hash value, or if there are none, the insert point
1628 * for that hash value.
1629 */
1630 int /* index value */
1631 xfs_dir2_leaf_search_hash(
1632 xfs_da_args_t *args, /* operation arguments */
1633 xfs_dabuf_t *lbp) /* leaf buffer */
1634 {
1635 xfs_dahash_t hash=0; /* hash from this entry */
1636 xfs_dahash_t hashwant; /* hash value looking for */
1637 int high; /* high leaf index */
1638 int low; /* low leaf index */
1639 xfs_dir2_leaf_t *leaf; /* leaf structure */
1640 xfs_dir2_leaf_entry_t *lep; /* leaf entry */
1641 int mid=0; /* current leaf index */
1642
1643 leaf = lbp->data;
1644 #ifndef __KERNEL__
1645 if (!leaf->hdr.count)
1646 return 0;
1647 #endif
1648 /*
1649 * Note, the table cannot be empty, so we have to go through the loop.
1650 * Binary search the leaf entries looking for our hash value.
1651 */
1652 for (lep = leaf->ents, low = 0, high = be16_to_cpu(leaf->hdr.count) - 1,
1653 hashwant = args->hashval;
1654 low <= high; ) {
1655 mid = (low + high) >> 1;
1656 if ((hash = be32_to_cpu(lep[mid].hashval)) == hashwant)
1657 break;
1658 if (hash < hashwant)
1659 low = mid + 1;
1660 else
1661 high = mid - 1;
1662 }
1663 /*
1664 * Found one, back up through all the equal hash values.
1665 */
1666 if (hash == hashwant) {
1667 while (mid > 0 && be32_to_cpu(lep[mid - 1].hashval) == hashwant) {
1668 mid--;
1669 }
1670 }
1671 /*
1672 * Need to point to an entry higher than ours.
1673 */
1674 else if (hash < hashwant)
1675 mid++;
1676 return mid;
1677 }
1678
1679 /*
1680 * Trim off a trailing data block. We know it's empty since the leaf
1681 * freespace table says so.
1682 */
1683 int /* error */
1684 xfs_dir2_leaf_trim_data(
1685 xfs_da_args_t *args, /* operation arguments */
1686 xfs_dabuf_t *lbp, /* leaf buffer */
1687 xfs_dir2_db_t db) /* data block number */
1688 {
1689 __be16 *bestsp; /* leaf bests table */
1690 #ifdef DEBUG
1691 xfs_dir2_data_t *data; /* data block structure */
1692 #endif
1693 xfs_dabuf_t *dbp; /* data block buffer */
1694 xfs_inode_t *dp; /* incore directory inode */
1695 int error; /* error return value */
1696 xfs_dir2_leaf_t *leaf; /* leaf structure */
1697 xfs_dir2_leaf_tail_t *ltp; /* leaf tail structure */
1698 xfs_mount_t *mp; /* filesystem mount point */
1699 xfs_trans_t *tp; /* transaction pointer */
1700
1701 dp = args->dp;
1702 mp = dp->i_mount;
1703 tp = args->trans;
1704 /*
1705 * Read the offending data block. We need its buffer.
1706 */
1707 if ((error = xfs_da_read_buf(tp, dp, xfs_dir2_db_to_da(mp, db), -1, &dbp,
1708 XFS_DATA_FORK))) {
1709 return error;
1710 }
1711 #ifdef DEBUG
1712 data = dbp->data;
1713 ASSERT(be32_to_cpu(data->hdr.magic) == XFS_DIR2_DATA_MAGIC);
1714 #endif
1715 /* this seems to be an error
1716 * data is only valid if DEBUG is defined?
1717 * RMC 09/08/1999
1718 */
1719
1720 leaf = lbp->data;
1721 ltp = xfs_dir2_leaf_tail_p(mp, leaf);
1722 ASSERT(be16_to_cpu(data->hdr.bestfree[0].length) ==
1723 mp->m_dirblksize - (uint)sizeof(data->hdr));
1724 ASSERT(db == be32_to_cpu(ltp->bestcount) - 1);
1725 /*
1726 * Get rid of the data block.
1727 */
1728 if ((error = xfs_dir2_shrink_inode(args, db, dbp))) {
1729 ASSERT(error != ENOSPC);
1730 xfs_da_brelse(tp, dbp);
1731 return error;
1732 }
1733 /*
1734 * Eliminate the last bests entry from the table.
1735 */
1736 bestsp = xfs_dir2_leaf_bests_p(ltp);
1737 be32_add_cpu(&ltp->bestcount, -1);
1738 memmove(&bestsp[1], &bestsp[0], be32_to_cpu(ltp->bestcount) * sizeof(*bestsp));
1739 xfs_dir2_leaf_log_tail(tp, lbp);
1740 xfs_dir2_leaf_log_bests(tp, lbp, 0, be32_to_cpu(ltp->bestcount) - 1);
1741 return 0;
1742 }
1743
1744 /*
1745 * Convert node form directory to leaf form directory.
1746 * The root of the node form dir needs to already be a LEAFN block.
1747 * Just return if we can't do anything.
1748 */
1749 int /* error */
1750 xfs_dir2_node_to_leaf(
1751 xfs_da_state_t *state) /* directory operation state */
1752 {
1753 xfs_da_args_t *args; /* operation arguments */
1754 xfs_inode_t *dp; /* incore directory inode */
1755 int error; /* error return code */
1756 xfs_dabuf_t *fbp; /* buffer for freespace block */
1757 xfs_fileoff_t fo; /* freespace file offset */
1758 xfs_dir2_free_t *free; /* freespace structure */
1759 xfs_dabuf_t *lbp; /* buffer for leaf block */
1760 xfs_dir2_leaf_tail_t *ltp; /* tail of leaf structure */
1761 xfs_dir2_leaf_t *leaf; /* leaf structure */
1762 xfs_mount_t *mp; /* filesystem mount point */
1763 int rval; /* successful free trim? */
1764 xfs_trans_t *tp; /* transaction pointer */
1765
1766 /*
1767 * There's more than a leaf level in the btree, so there must
1768 * be multiple leafn blocks. Give up.
1769 */
1770 if (state->path.active > 1)
1771 return 0;
1772 args = state->args;
1773
1774 trace_xfs_dir2_node_to_leaf(args);
1775
1776 mp = state->mp;
1777 dp = args->dp;
1778 tp = args->trans;
1779 /*
1780 * Get the last offset in the file.
1781 */
1782 if ((error = xfs_bmap_last_offset(tp, dp, &fo, XFS_DATA_FORK))) {
1783 return error;
1784 }
1785 fo -= mp->m_dirblkfsbs;
1786 /*
1787 * If there are freespace blocks other than the first one,
1788 * take this opportunity to remove trailing empty freespace blocks
1789 * that may have been left behind during no-space-reservation
1790 * operations.
1791 */
1792 while (fo > mp->m_dirfreeblk) {
1793 if ((error = xfs_dir2_node_trim_free(args, fo, &rval))) {
1794 return error;
1795 }
1796 if (rval)
1797 fo -= mp->m_dirblkfsbs;
1798 else
1799 return 0;
1800 }
1801 /*
1802 * Now find the block just before the freespace block.
1803 */
1804 if ((error = xfs_bmap_last_before(tp, dp, &fo, XFS_DATA_FORK))) {
1805 return error;
1806 }
1807 /*
1808 * If it's not the single leaf block, give up.
1809 */
1810 if (XFS_FSB_TO_B(mp, fo) > XFS_DIR2_LEAF_OFFSET + mp->m_dirblksize)
1811 return 0;
1812 lbp = state->path.blk[0].bp;
1813 leaf = lbp->data;
1814 ASSERT(be16_to_cpu(leaf->hdr.info.magic) == XFS_DIR2_LEAFN_MAGIC);
1815 /*
1816 * Read the freespace block.
1817 */
1818 if ((error = xfs_da_read_buf(tp, dp, mp->m_dirfreeblk, -1, &fbp,
1819 XFS_DATA_FORK))) {
1820 return error;
1821 }
1822 free = fbp->data;
1823 ASSERT(be32_to_cpu(free->hdr.magic) == XFS_DIR2_FREE_MAGIC);
1824 ASSERT(!free->hdr.firstdb);
1825 /*
1826 * Now see if the leafn and free data will fit in a leaf1.
1827 * If not, release the buffer and give up.
1828 */
1829 if ((uint)sizeof(leaf->hdr) +
1830 (be16_to_cpu(leaf->hdr.count) - be16_to_cpu(leaf->hdr.stale)) * (uint)sizeof(leaf->ents[0]) +
1831 be32_to_cpu(free->hdr.nvalid) * (uint)sizeof(leaf->bests[0]) +
1832 (uint)sizeof(leaf->tail) >
1833 mp->m_dirblksize) {
1834 xfs_da_brelse(tp, fbp);
1835 return 0;
1836 }
1837 /*
1838 * If the leaf has any stale entries in it, compress them out.
1839 * The compact routine will log the header.
1840 */
1841 if (be16_to_cpu(leaf->hdr.stale))
1842 xfs_dir2_leaf_compact(args, lbp);
1843 else
1844 xfs_dir2_leaf_log_header(tp, lbp);
1845 leaf->hdr.info.magic = cpu_to_be16(XFS_DIR2_LEAF1_MAGIC);
1846 /*
1847 * Set up the leaf tail from the freespace block.
1848 */
1849 ltp = xfs_dir2_leaf_tail_p(mp, leaf);
1850 ltp->bestcount = free->hdr.nvalid;
1851 /*
1852 * Set up the leaf bests table.
1853 */
1854 memcpy(xfs_dir2_leaf_bests_p(ltp), free->bests,
1855 be32_to_cpu(ltp->bestcount) * sizeof(leaf->bests[0]));
1856 xfs_dir2_leaf_log_bests(tp, lbp, 0, be32_to_cpu(ltp->bestcount) - 1);
1857 xfs_dir2_leaf_log_tail(tp, lbp);
1858 xfs_dir2_leaf_check(dp, lbp);
1859 /*
1860 * Get rid of the freespace block.
1861 */
1862 error = xfs_dir2_shrink_inode(args, XFS_DIR2_FREE_FIRSTDB(mp), fbp);
1863 if (error) {
1864 /*
1865 * This can't fail here because it can only happen when
1866 * punching out the middle of an extent, and this is an
1867 * isolated block.
1868 */
1869 ASSERT(error != ENOSPC);
1870 return error;
1871 }
1872 fbp = NULL;
1873 /*
1874 * Now see if we can convert the single-leaf directory
1875 * down to a block form directory.
1876 * This routine always kills the dabuf for the leaf, so
1877 * eliminate it from the path.
1878 */
1879 error = xfs_dir2_leaf_to_block(args, lbp, NULL);
1880 state->path.blk[0].bp = NULL;
1881 return error;
1882 }
This page took 0.070772 seconds and 5 git commands to generate.