aboutsummaryrefslogtreecommitdiffstats
path: root/fs/xfs/xfs_dir2_node.c
diff options
context:
space:
mode:
authorDave Chinner <dchinner@redhat.com>2012-06-22 04:50:14 -0400
committerBen Myers <bpm@sgi.com>2012-07-01 15:50:07 -0400
commit1d9025e56143c0c4aebebdb62e46618d3d284218 (patch)
treec31b34008dbd17ac1811c73cc515ea7f6247e2f0 /fs/xfs/xfs_dir2_node.c
parent3605431fb9739a30ccd0c6380ae8e3c6f8e670a5 (diff)
xfs: remove struct xfs_dabuf and infrastructure
The struct xfs_dabuf now only tracks a single xfs_buf and all the information it holds can be gained directly from the xfs_buf. Hence we can remove the struct dabuf and pass the xfs_buf around everywhere. Kill the struct dabuf and the associated infrastructure. Signed-off-by: Dave Chinner <dchinner@redhat.com> Reviewed-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Ben Myers <bpm@sgi.com>
Diffstat (limited to 'fs/xfs/xfs_dir2_node.c')
-rw-r--r--fs/xfs/xfs_dir2_node.c236
1 files changed, 100 insertions, 136 deletions
diff --git a/fs/xfs/xfs_dir2_node.c b/fs/xfs/xfs_dir2_node.c
index b0f26780449d..6c7052406605 100644
--- a/fs/xfs/xfs_dir2_node.c
+++ b/fs/xfs/xfs_dir2_node.c
@@ -36,20 +36,20 @@
36/* 36/*
37 * Function declarations. 37 * Function declarations.
38 */ 38 */
39static void xfs_dir2_free_log_header(xfs_trans_t *tp, xfs_dabuf_t *bp); 39static int xfs_dir2_leafn_add(struct xfs_buf *bp, xfs_da_args_t *args,
40static int xfs_dir2_leafn_add(xfs_dabuf_t *bp, xfs_da_args_t *args, int index); 40 int index);
41#ifdef DEBUG 41#ifdef DEBUG
42static void xfs_dir2_leafn_check(xfs_inode_t *dp, xfs_dabuf_t *bp); 42static void xfs_dir2_leafn_check(struct xfs_inode *dp, struct xfs_buf *bp);
43#else 43#else
44#define xfs_dir2_leafn_check(dp, bp) 44#define xfs_dir2_leafn_check(dp, bp)
45#endif 45#endif
46static void xfs_dir2_leafn_moveents(xfs_da_args_t *args, xfs_dabuf_t *bp_s, 46static void xfs_dir2_leafn_moveents(xfs_da_args_t *args, struct xfs_buf *bp_s,
47 int start_s, xfs_dabuf_t *bp_d, int start_d, 47 int start_s, struct xfs_buf *bp_d,
48 int count); 48 int start_d, int count);
49static void xfs_dir2_leafn_rebalance(xfs_da_state_t *state, 49static void xfs_dir2_leafn_rebalance(xfs_da_state_t *state,
50 xfs_da_state_blk_t *blk1, 50 xfs_da_state_blk_t *blk1,
51 xfs_da_state_blk_t *blk2); 51 xfs_da_state_blk_t *blk2);
52static int xfs_dir2_leafn_remove(xfs_da_args_t *args, xfs_dabuf_t *bp, 52static int xfs_dir2_leafn_remove(xfs_da_args_t *args, struct xfs_buf *bp,
53 int index, xfs_da_state_blk_t *dblk, 53 int index, xfs_da_state_blk_t *dblk,
54 int *rval); 54 int *rval);
55static int xfs_dir2_node_addname_int(xfs_da_args_t *args, 55static int xfs_dir2_node_addname_int(xfs_da_args_t *args,
@@ -60,16 +60,16 @@ static int xfs_dir2_node_addname_int(xfs_da_args_t *args,
60 */ 60 */
61STATIC void 61STATIC void
62xfs_dir2_free_log_bests( 62xfs_dir2_free_log_bests(
63 xfs_trans_t *tp, /* transaction pointer */ 63 struct xfs_trans *tp,
64 xfs_dabuf_t *bp, /* freespace buffer */ 64 struct xfs_buf *bp,
65 int first, /* first entry to log */ 65 int first, /* first entry to log */
66 int last) /* last entry to log */ 66 int last) /* last entry to log */
67{ 67{
68 xfs_dir2_free_t *free; /* freespace structure */ 68 xfs_dir2_free_t *free; /* freespace structure */
69 69
70 free = bp->data; 70 free = bp->b_addr;
71 ASSERT(free->hdr.magic == cpu_to_be32(XFS_DIR2_FREE_MAGIC)); 71 ASSERT(free->hdr.magic == cpu_to_be32(XFS_DIR2_FREE_MAGIC));
72 xfs_da_log_buf(tp, bp, 72 xfs_trans_log_buf(tp, bp,
73 (uint)((char *)&free->bests[first] - (char *)free), 73 (uint)((char *)&free->bests[first] - (char *)free),
74 (uint)((char *)&free->bests[last] - (char *)free + 74 (uint)((char *)&free->bests[last] - (char *)free +
75 sizeof(free->bests[0]) - 1)); 75 sizeof(free->bests[0]) - 1));
@@ -80,14 +80,14 @@ xfs_dir2_free_log_bests(
80 */ 80 */
81static void 81static void
82xfs_dir2_free_log_header( 82xfs_dir2_free_log_header(
83 xfs_trans_t *tp, /* transaction pointer */ 83 struct xfs_trans *tp,
84 xfs_dabuf_t *bp) /* freespace buffer */ 84 struct xfs_buf *bp)
85{ 85{
86 xfs_dir2_free_t *free; /* freespace structure */ 86 xfs_dir2_free_t *free; /* freespace structure */
87 87
88 free = bp->data; 88 free = bp->b_addr;
89 ASSERT(free->hdr.magic == cpu_to_be32(XFS_DIR2_FREE_MAGIC)); 89 ASSERT(free->hdr.magic == cpu_to_be32(XFS_DIR2_FREE_MAGIC));
90 xfs_da_log_buf(tp, bp, (uint)((char *)&free->hdr - (char *)free), 90 xfs_trans_log_buf(tp, bp, (uint)((char *)&free->hdr - (char *)free),
91 (uint)(sizeof(xfs_dir2_free_hdr_t) - 1)); 91 (uint)(sizeof(xfs_dir2_free_hdr_t) - 1));
92} 92}
93 93
@@ -99,11 +99,11 @@ xfs_dir2_free_log_header(
99int /* error */ 99int /* error */
100xfs_dir2_leaf_to_node( 100xfs_dir2_leaf_to_node(
101 xfs_da_args_t *args, /* operation arguments */ 101 xfs_da_args_t *args, /* operation arguments */
102 xfs_dabuf_t *lbp) /* leaf buffer */ 102 struct xfs_buf *lbp) /* leaf buffer */
103{ 103{
104 xfs_inode_t *dp; /* incore directory inode */ 104 xfs_inode_t *dp; /* incore directory inode */
105 int error; /* error return value */ 105 int error; /* error return value */
106 xfs_dabuf_t *fbp; /* freespace buffer */ 106 struct xfs_buf *fbp; /* freespace buffer */
107 xfs_dir2_db_t fdb; /* freespace block number */ 107 xfs_dir2_db_t fdb; /* freespace block number */
108 xfs_dir2_free_t *free; /* freespace structure */ 108 xfs_dir2_free_t *free; /* freespace structure */
109 __be16 *from; /* pointer to freespace entry */ 109 __be16 *from; /* pointer to freespace entry */
@@ -136,8 +136,8 @@ xfs_dir2_leaf_to_node(
136 return error; 136 return error;
137 } 137 }
138 ASSERT(fbp != NULL); 138 ASSERT(fbp != NULL);
139 free = fbp->data; 139 free = fbp->b_addr;
140 leaf = lbp->data; 140 leaf = lbp->b_addr;
141 ltp = xfs_dir2_leaf_tail_p(mp, leaf); 141 ltp = xfs_dir2_leaf_tail_p(mp, leaf);
142 /* 142 /*
143 * Initialize the freespace block header. 143 * Initialize the freespace block header.
@@ -164,7 +164,6 @@ xfs_dir2_leaf_to_node(
164 xfs_dir2_leaf_log_header(tp, lbp); 164 xfs_dir2_leaf_log_header(tp, lbp);
165 xfs_dir2_free_log_header(tp, fbp); 165 xfs_dir2_free_log_header(tp, fbp);
166 xfs_dir2_free_log_bests(tp, fbp, 0, be32_to_cpu(free->hdr.nvalid) - 1); 166 xfs_dir2_free_log_bests(tp, fbp, 0, be32_to_cpu(free->hdr.nvalid) - 1);
167 xfs_da_buf_done(fbp);
168 xfs_dir2_leafn_check(dp, lbp); 167 xfs_dir2_leafn_check(dp, lbp);
169 return 0; 168 return 0;
170} 169}
@@ -175,7 +174,7 @@ xfs_dir2_leaf_to_node(
175 */ 174 */
176static int /* error */ 175static int /* error */
177xfs_dir2_leafn_add( 176xfs_dir2_leafn_add(
178 xfs_dabuf_t *bp, /* leaf buffer */ 177 struct xfs_buf *bp, /* leaf buffer */
179 xfs_da_args_t *args, /* operation arguments */ 178 xfs_da_args_t *args, /* operation arguments */
180 int index) /* insertion pt for new entry */ 179 int index) /* insertion pt for new entry */
181{ 180{
@@ -195,7 +194,7 @@ xfs_dir2_leafn_add(
195 dp = args->dp; 194 dp = args->dp;
196 mp = dp->i_mount; 195 mp = dp->i_mount;
197 tp = args->trans; 196 tp = args->trans;
198 leaf = bp->data; 197 leaf = bp->b_addr;
199 198
200 /* 199 /*
201 * Quick check just to make sure we are not going to index 200 * Quick check just to make sure we are not going to index
@@ -261,15 +260,15 @@ xfs_dir2_leafn_add(
261 */ 260 */
262void 261void
263xfs_dir2_leafn_check( 262xfs_dir2_leafn_check(
264 xfs_inode_t *dp, /* incore directory inode */ 263 struct xfs_inode *dp,
265 xfs_dabuf_t *bp) /* leaf buffer */ 264 struct xfs_buf *bp)
266{ 265{
267 int i; /* leaf index */ 266 int i; /* leaf index */
268 xfs_dir2_leaf_t *leaf; /* leaf structure */ 267 xfs_dir2_leaf_t *leaf; /* leaf structure */
269 xfs_mount_t *mp; /* filesystem mount point */ 268 xfs_mount_t *mp; /* filesystem mount point */
270 int stale; /* count of stale leaves */ 269 int stale; /* count of stale leaves */
271 270
272 leaf = bp->data; 271 leaf = bp->b_addr;
273 mp = dp->i_mount; 272 mp = dp->i_mount;
274 ASSERT(leaf->hdr.info.magic == cpu_to_be16(XFS_DIR2_LEAFN_MAGIC)); 273 ASSERT(leaf->hdr.info.magic == cpu_to_be16(XFS_DIR2_LEAFN_MAGIC));
275 ASSERT(be16_to_cpu(leaf->hdr.count) <= xfs_dir2_max_leaf_ents(mp)); 274 ASSERT(be16_to_cpu(leaf->hdr.count) <= xfs_dir2_max_leaf_ents(mp));
@@ -291,12 +290,12 @@ xfs_dir2_leafn_check(
291 */ 290 */
292xfs_dahash_t /* hash value */ 291xfs_dahash_t /* hash value */
293xfs_dir2_leafn_lasthash( 292xfs_dir2_leafn_lasthash(
294 xfs_dabuf_t *bp, /* leaf buffer */ 293 struct xfs_buf *bp, /* leaf buffer */
295 int *count) /* count of entries in leaf */ 294 int *count) /* count of entries in leaf */
296{ 295{
297 xfs_dir2_leaf_t *leaf; /* leaf structure */ 296 xfs_dir2_leaf_t *leaf; /* leaf structure */
298 297
299 leaf = bp->data; 298 leaf = bp->b_addr;
300 ASSERT(leaf->hdr.info.magic == cpu_to_be16(XFS_DIR2_LEAFN_MAGIC)); 299 ASSERT(leaf->hdr.info.magic == cpu_to_be16(XFS_DIR2_LEAFN_MAGIC));
301 if (count) 300 if (count)
302 *count = be16_to_cpu(leaf->hdr.count); 301 *count = be16_to_cpu(leaf->hdr.count);
@@ -311,12 +310,12 @@ xfs_dir2_leafn_lasthash(
311 */ 310 */
312STATIC int 311STATIC int
313xfs_dir2_leafn_lookup_for_addname( 312xfs_dir2_leafn_lookup_for_addname(
314 xfs_dabuf_t *bp, /* leaf buffer */ 313 struct xfs_buf *bp, /* leaf buffer */
315 xfs_da_args_t *args, /* operation arguments */ 314 xfs_da_args_t *args, /* operation arguments */
316 int *indexp, /* out: leaf entry index */ 315 int *indexp, /* out: leaf entry index */
317 xfs_da_state_t *state) /* state to fill in */ 316 xfs_da_state_t *state) /* state to fill in */
318{ 317{
319 xfs_dabuf_t *curbp = NULL; /* current data/free buffer */ 318 struct xfs_buf *curbp = NULL; /* current data/free buffer */
320 xfs_dir2_db_t curdb = -1; /* current data block number */ 319 xfs_dir2_db_t curdb = -1; /* current data block number */
321 xfs_dir2_db_t curfdb = -1; /* current free block number */ 320 xfs_dir2_db_t curfdb = -1; /* current free block number */
322 xfs_inode_t *dp; /* incore directory inode */ 321 xfs_inode_t *dp; /* incore directory inode */
@@ -335,7 +334,7 @@ xfs_dir2_leafn_lookup_for_addname(
335 dp = args->dp; 334 dp = args->dp;
336 tp = args->trans; 335 tp = args->trans;
337 mp = dp->i_mount; 336 mp = dp->i_mount;
338 leaf = bp->data; 337 leaf = bp->b_addr;
339 ASSERT(leaf->hdr.info.magic == cpu_to_be16(XFS_DIR2_LEAFN_MAGIC)); 338 ASSERT(leaf->hdr.info.magic == cpu_to_be16(XFS_DIR2_LEAFN_MAGIC));
340#ifdef __KERNEL__ 339#ifdef __KERNEL__
341 ASSERT(be16_to_cpu(leaf->hdr.count) > 0); 340 ASSERT(be16_to_cpu(leaf->hdr.count) > 0);
@@ -352,7 +351,7 @@ xfs_dir2_leafn_lookup_for_addname(
352 /* If so, it's a free block buffer, get the block number. */ 351 /* If so, it's a free block buffer, get the block number. */
353 curbp = state->extrablk.bp; 352 curbp = state->extrablk.bp;
354 curfdb = state->extrablk.blkno; 353 curfdb = state->extrablk.blkno;
355 free = curbp->data; 354 free = curbp->b_addr;
356 ASSERT(free->hdr.magic == cpu_to_be32(XFS_DIR2_FREE_MAGIC)); 355 ASSERT(free->hdr.magic == cpu_to_be32(XFS_DIR2_FREE_MAGIC));
357 } 356 }
358 length = xfs_dir2_data_entsize(args->namelen); 357 length = xfs_dir2_data_entsize(args->namelen);
@@ -394,7 +393,7 @@ xfs_dir2_leafn_lookup_for_addname(
394 * If we had one before, drop it. 393 * If we had one before, drop it.
395 */ 394 */
396 if (curbp) 395 if (curbp)
397 xfs_da_brelse(tp, curbp); 396 xfs_trans_brelse(tp, curbp);
398 /* 397 /*
399 * Read the free block. 398 * Read the free block.
400 */ 399 */
@@ -403,7 +402,7 @@ xfs_dir2_leafn_lookup_for_addname(
403 -1, &curbp, XFS_DATA_FORK); 402 -1, &curbp, XFS_DATA_FORK);
404 if (error) 403 if (error)
405 return error; 404 return error;
406 free = curbp->data; 405 free = curbp->b_addr;
407 ASSERT(be32_to_cpu(free->hdr.magic) == 406 ASSERT(be32_to_cpu(free->hdr.magic) ==
408 XFS_DIR2_FREE_MAGIC); 407 XFS_DIR2_FREE_MAGIC);
409 ASSERT((be32_to_cpu(free->hdr.firstdb) % 408 ASSERT((be32_to_cpu(free->hdr.firstdb) %
@@ -424,7 +423,7 @@ xfs_dir2_leafn_lookup_for_addname(
424 XFS_ERROR_REPORT("xfs_dir2_leafn_lookup_int", 423 XFS_ERROR_REPORT("xfs_dir2_leafn_lookup_int",
425 XFS_ERRLEVEL_LOW, mp); 424 XFS_ERRLEVEL_LOW, mp);
426 if (curfdb != newfdb) 425 if (curfdb != newfdb)
427 xfs_da_brelse(tp, curbp); 426 xfs_trans_brelse(tp, curbp);
428 return XFS_ERROR(EFSCORRUPTED); 427 return XFS_ERROR(EFSCORRUPTED);
429 } 428 }
430 curfdb = newfdb; 429 curfdb = newfdb;
@@ -459,12 +458,12 @@ out:
459 */ 458 */
460STATIC int 459STATIC int
461xfs_dir2_leafn_lookup_for_entry( 460xfs_dir2_leafn_lookup_for_entry(
462 xfs_dabuf_t *bp, /* leaf buffer */ 461 struct xfs_buf *bp, /* leaf buffer */
463 xfs_da_args_t *args, /* operation arguments */ 462 xfs_da_args_t *args, /* operation arguments */
464 int *indexp, /* out: leaf entry index */ 463 int *indexp, /* out: leaf entry index */
465 xfs_da_state_t *state) /* state to fill in */ 464 xfs_da_state_t *state) /* state to fill in */
466{ 465{
467 xfs_dabuf_t *curbp = NULL; /* current data/free buffer */ 466 struct xfs_buf *curbp = NULL; /* current data/free buffer */
468 xfs_dir2_db_t curdb = -1; /* current data block number */ 467 xfs_dir2_db_t curdb = -1; /* current data block number */
469 xfs_dir2_data_entry_t *dep; /* data block entry */ 468 xfs_dir2_data_entry_t *dep; /* data block entry */
470 xfs_inode_t *dp; /* incore directory inode */ 469 xfs_inode_t *dp; /* incore directory inode */
@@ -480,7 +479,7 @@ xfs_dir2_leafn_lookup_for_entry(
480 dp = args->dp; 479 dp = args->dp;
481 tp = args->trans; 480 tp = args->trans;
482 mp = dp->i_mount; 481 mp = dp->i_mount;
483 leaf = bp->data; 482 leaf = bp->b_addr;
484 ASSERT(leaf->hdr.info.magic == cpu_to_be16(XFS_DIR2_LEAFN_MAGIC)); 483 ASSERT(leaf->hdr.info.magic == cpu_to_be16(XFS_DIR2_LEAFN_MAGIC));
485#ifdef __KERNEL__ 484#ifdef __KERNEL__
486 ASSERT(be16_to_cpu(leaf->hdr.count) > 0); 485 ASSERT(be16_to_cpu(leaf->hdr.count) > 0);
@@ -525,7 +524,7 @@ xfs_dir2_leafn_lookup_for_entry(
525 */ 524 */
526 if (curbp && (args->cmpresult == XFS_CMP_DIFFERENT || 525 if (curbp && (args->cmpresult == XFS_CMP_DIFFERENT ||
527 curdb != state->extrablk.blkno)) 526 curdb != state->extrablk.blkno))
528 xfs_da_brelse(tp, curbp); 527 xfs_trans_brelse(tp, curbp);
529 /* 528 /*
530 * If needing the block that is saved with a CI match, 529 * If needing the block that is saved with a CI match,
531 * use it otherwise read in the new data block. 530 * use it otherwise read in the new data block.
@@ -547,7 +546,7 @@ xfs_dir2_leafn_lookup_for_entry(
547 /* 546 /*
548 * Point to the data entry. 547 * Point to the data entry.
549 */ 548 */
550 dep = (xfs_dir2_data_entry_t *)((char *)curbp->data + 549 dep = (xfs_dir2_data_entry_t *)((char *)curbp->b_addr +
551 xfs_dir2_dataptr_to_off(mp, be32_to_cpu(lep->address))); 550 xfs_dir2_dataptr_to_off(mp, be32_to_cpu(lep->address)));
552 /* 551 /*
553 * Compare the entry and if it's an exact match, return 552 * Compare the entry and if it's an exact match, return
@@ -559,7 +558,7 @@ xfs_dir2_leafn_lookup_for_entry(
559 /* If there is a CI match block, drop it */ 558 /* If there is a CI match block, drop it */
560 if (args->cmpresult != XFS_CMP_DIFFERENT && 559 if (args->cmpresult != XFS_CMP_DIFFERENT &&
561 curdb != state->extrablk.blkno) 560 curdb != state->extrablk.blkno)
562 xfs_da_brelse(tp, state->extrablk.bp); 561 xfs_trans_brelse(tp, state->extrablk.bp);
563 args->cmpresult = cmp; 562 args->cmpresult = cmp;
564 args->inumber = be64_to_cpu(dep->inumber); 563 args->inumber = be64_to_cpu(dep->inumber);
565 *indexp = index; 564 *indexp = index;
@@ -567,7 +566,7 @@ xfs_dir2_leafn_lookup_for_entry(
567 state->extrablk.bp = curbp; 566 state->extrablk.bp = curbp;
568 state->extrablk.blkno = curdb; 567 state->extrablk.blkno = curdb;
569 state->extrablk.index = (int)((char *)dep - 568 state->extrablk.index = (int)((char *)dep -
570 (char *)curbp->data); 569 (char *)curbp->b_addr);
571 state->extrablk.magic = XFS_DIR2_DATA_MAGIC; 570 state->extrablk.magic = XFS_DIR2_DATA_MAGIC;
572 if (cmp == XFS_CMP_EXACT) 571 if (cmp == XFS_CMP_EXACT)
573 return XFS_ERROR(EEXIST); 572 return XFS_ERROR(EEXIST);
@@ -586,7 +585,7 @@ xfs_dir2_leafn_lookup_for_entry(
586 } else { 585 } else {
587 /* If the curbp is not the CI match block, drop it */ 586 /* If the curbp is not the CI match block, drop it */
588 if (state->extrablk.bp != curbp) 587 if (state->extrablk.bp != curbp)
589 xfs_da_brelse(tp, curbp); 588 xfs_trans_brelse(tp, curbp);
590 } 589 }
591 } else { 590 } else {
592 state->extravalid = 0; 591 state->extravalid = 0;
@@ -602,7 +601,7 @@ xfs_dir2_leafn_lookup_for_entry(
602 */ 601 */
603int 602int
604xfs_dir2_leafn_lookup_int( 603xfs_dir2_leafn_lookup_int(
605 xfs_dabuf_t *bp, /* leaf buffer */ 604 struct xfs_buf *bp, /* leaf buffer */
606 xfs_da_args_t *args, /* operation arguments */ 605 xfs_da_args_t *args, /* operation arguments */
607 int *indexp, /* out: leaf entry index */ 606 int *indexp, /* out: leaf entry index */
608 xfs_da_state_t *state) /* state to fill in */ 607 xfs_da_state_t *state) /* state to fill in */
@@ -620,9 +619,9 @@ xfs_dir2_leafn_lookup_int(
620static void 619static void
621xfs_dir2_leafn_moveents( 620xfs_dir2_leafn_moveents(
622 xfs_da_args_t *args, /* operation arguments */ 621 xfs_da_args_t *args, /* operation arguments */
623 xfs_dabuf_t *bp_s, /* source leaf buffer */ 622 struct xfs_buf *bp_s, /* source leaf buffer */
624 int start_s, /* source leaf index */ 623 int start_s, /* source leaf index */
625 xfs_dabuf_t *bp_d, /* destination leaf buffer */ 624 struct xfs_buf *bp_d, /* destination leaf buffer */
626 int start_d, /* destination leaf index */ 625 int start_d, /* destination leaf index */
627 int count) /* count of leaves to copy */ 626 int count) /* count of leaves to copy */
628{ 627{
@@ -640,8 +639,8 @@ xfs_dir2_leafn_moveents(
640 return; 639 return;
641 } 640 }
642 tp = args->trans; 641 tp = args->trans;
643 leaf_s = bp_s->data; 642 leaf_s = bp_s->b_addr;
644 leaf_d = bp_d->data; 643 leaf_d = bp_d->b_addr;
645 /* 644 /*
646 * If the destination index is not the end of the current 645 * If the destination index is not the end of the current
647 * destination leaf entries, open up a hole in the destination 646 * destination leaf entries, open up a hole in the destination
@@ -702,14 +701,14 @@ xfs_dir2_leafn_moveents(
702 */ 701 */
703int /* sort order */ 702int /* sort order */
704xfs_dir2_leafn_order( 703xfs_dir2_leafn_order(
705 xfs_dabuf_t *leaf1_bp, /* leaf1 buffer */ 704 struct xfs_buf *leaf1_bp, /* leaf1 buffer */
706 xfs_dabuf_t *leaf2_bp) /* leaf2 buffer */ 705 struct xfs_buf *leaf2_bp) /* leaf2 buffer */
707{ 706{
708 xfs_dir2_leaf_t *leaf1; /* leaf1 structure */ 707 xfs_dir2_leaf_t *leaf1; /* leaf1 structure */
709 xfs_dir2_leaf_t *leaf2; /* leaf2 structure */ 708 xfs_dir2_leaf_t *leaf2; /* leaf2 structure */
710 709
711 leaf1 = leaf1_bp->data; 710 leaf1 = leaf1_bp->b_addr;
712 leaf2 = leaf2_bp->data; 711 leaf2 = leaf2_bp->b_addr;
713 ASSERT(leaf1->hdr.info.magic == cpu_to_be16(XFS_DIR2_LEAFN_MAGIC)); 712 ASSERT(leaf1->hdr.info.magic == cpu_to_be16(XFS_DIR2_LEAFN_MAGIC));
714 ASSERT(leaf2->hdr.info.magic == cpu_to_be16(XFS_DIR2_LEAFN_MAGIC)); 713 ASSERT(leaf2->hdr.info.magic == cpu_to_be16(XFS_DIR2_LEAFN_MAGIC));
715 if (be16_to_cpu(leaf1->hdr.count) > 0 && 714 if (be16_to_cpu(leaf1->hdr.count) > 0 &&
@@ -757,8 +756,8 @@ xfs_dir2_leafn_rebalance(
757 blk1 = blk2; 756 blk1 = blk2;
758 blk2 = tmp; 757 blk2 = tmp;
759 } 758 }
760 leaf1 = blk1->bp->data; 759 leaf1 = blk1->bp->b_addr;
761 leaf2 = blk2->bp->data; 760 leaf2 = blk2->bp->b_addr;
762 oldsum = be16_to_cpu(leaf1->hdr.count) + be16_to_cpu(leaf2->hdr.count); 761 oldsum = be16_to_cpu(leaf1->hdr.count) + be16_to_cpu(leaf2->hdr.count);
763#ifdef DEBUG 762#ifdef DEBUG
764 oldstale = be16_to_cpu(leaf1->hdr.stale) + be16_to_cpu(leaf2->hdr.stale); 763 oldstale = be16_to_cpu(leaf1->hdr.stale) + be16_to_cpu(leaf2->hdr.stale);
@@ -834,14 +833,14 @@ xfs_dir2_leafn_rebalance(
834static int /* error */ 833static int /* error */
835xfs_dir2_leafn_remove( 834xfs_dir2_leafn_remove(
836 xfs_da_args_t *args, /* operation arguments */ 835 xfs_da_args_t *args, /* operation arguments */
837 xfs_dabuf_t *bp, /* leaf buffer */ 836 struct xfs_buf *bp, /* leaf buffer */
838 int index, /* leaf entry index */ 837 int index, /* leaf entry index */
839 xfs_da_state_blk_t *dblk, /* data block */ 838 xfs_da_state_blk_t *dblk, /* data block */
840 int *rval) /* resulting block needs join */ 839 int *rval) /* resulting block needs join */
841{ 840{
842 xfs_dir2_data_hdr_t *hdr; /* data block header */ 841 xfs_dir2_data_hdr_t *hdr; /* data block header */
843 xfs_dir2_db_t db; /* data block number */ 842 xfs_dir2_db_t db; /* data block number */
844 xfs_dabuf_t *dbp; /* data block buffer */ 843 struct xfs_buf *dbp; /* data block buffer */
845 xfs_dir2_data_entry_t *dep; /* data block entry */ 844 xfs_dir2_data_entry_t *dep; /* data block entry */
846 xfs_inode_t *dp; /* incore directory inode */ 845 xfs_inode_t *dp; /* incore directory inode */
847 xfs_dir2_leaf_t *leaf; /* leaf structure */ 846 xfs_dir2_leaf_t *leaf; /* leaf structure */
@@ -858,7 +857,7 @@ xfs_dir2_leafn_remove(
858 dp = args->dp; 857 dp = args->dp;
859 tp = args->trans; 858 tp = args->trans;
860 mp = dp->i_mount; 859 mp = dp->i_mount;
861 leaf = bp->data; 860 leaf = bp->b_addr;
862 ASSERT(leaf->hdr.info.magic == cpu_to_be16(XFS_DIR2_LEAFN_MAGIC)); 861 ASSERT(leaf->hdr.info.magic == cpu_to_be16(XFS_DIR2_LEAFN_MAGIC));
863 /* 862 /*
864 * Point to the entry we're removing. 863 * Point to the entry we're removing.
@@ -884,7 +883,7 @@ xfs_dir2_leafn_remove(
884 * in the data block in case it changes. 883 * in the data block in case it changes.
885 */ 884 */
886 dbp = dblk->bp; 885 dbp = dblk->bp;
887 hdr = dbp->data; 886 hdr = dbp->b_addr;
888 dep = (xfs_dir2_data_entry_t *)((char *)hdr + off); 887 dep = (xfs_dir2_data_entry_t *)((char *)hdr + off);
889 longest = be16_to_cpu(hdr->bestfree[0].length); 888 longest = be16_to_cpu(hdr->bestfree[0].length);
890 needlog = needscan = 0; 889 needlog = needscan = 0;
@@ -905,7 +904,7 @@ xfs_dir2_leafn_remove(
905 */ 904 */
906 if (longest < be16_to_cpu(hdr->bestfree[0].length)) { 905 if (longest < be16_to_cpu(hdr->bestfree[0].length)) {
907 int error; /* error return value */ 906 int error; /* error return value */
908 xfs_dabuf_t *fbp; /* freeblock buffer */ 907 struct xfs_buf *fbp; /* freeblock buffer */
909 xfs_dir2_db_t fdb; /* freeblock block number */ 908 xfs_dir2_db_t fdb; /* freeblock block number */
910 int findex; /* index in freeblock entries */ 909 int findex; /* index in freeblock entries */
911 xfs_dir2_free_t *free; /* freeblock structure */ 910 xfs_dir2_free_t *free; /* freeblock structure */
@@ -920,7 +919,7 @@ xfs_dir2_leafn_remove(
920 -1, &fbp, XFS_DATA_FORK))) { 919 -1, &fbp, XFS_DATA_FORK))) {
921 return error; 920 return error;
922 } 921 }
923 free = fbp->data; 922 free = fbp->b_addr;
924 ASSERT(free->hdr.magic == cpu_to_be32(XFS_DIR2_FREE_MAGIC)); 923 ASSERT(free->hdr.magic == cpu_to_be32(XFS_DIR2_FREE_MAGIC));
925 ASSERT(be32_to_cpu(free->hdr.firstdb) == 924 ASSERT(be32_to_cpu(free->hdr.firstdb) ==
926 xfs_dir2_free_max_bests(mp) * 925 xfs_dir2_free_max_bests(mp) *
@@ -948,9 +947,7 @@ xfs_dir2_leafn_remove(
948 * In this case just drop the buffer and some one else 947 * In this case just drop the buffer and some one else
949 * will eventually get rid of the empty block. 948 * will eventually get rid of the empty block.
950 */ 949 */
951 else if (error == ENOSPC && args->total == 0) 950 else if (!(error == ENOSPC && args->total == 0))
952 xfs_da_buf_done(dbp);
953 else
954 return error; 951 return error;
955 } 952 }
956 /* 953 /*
@@ -1018,11 +1015,6 @@ xfs_dir2_leafn_remove(
1018 */ 1015 */
1019 if (logfree) 1016 if (logfree)
1020 xfs_dir2_free_log_bests(tp, fbp, findex, findex); 1017 xfs_dir2_free_log_bests(tp, fbp, findex, findex);
1021 /*
1022 * Drop the buffer if we still have it.
1023 */
1024 if (fbp)
1025 xfs_da_buf_done(fbp);
1026 } 1018 }
1027 xfs_dir2_leafn_check(dp, bp); 1019 xfs_dir2_leafn_check(dp, bp);
1028 /* 1020 /*
@@ -1114,7 +1106,7 @@ xfs_dir2_leafn_toosmall(
1114{ 1106{
1115 xfs_da_state_blk_t *blk; /* leaf block */ 1107 xfs_da_state_blk_t *blk; /* leaf block */
1116 xfs_dablk_t blkno; /* leaf block number */ 1108 xfs_dablk_t blkno; /* leaf block number */
1117 xfs_dabuf_t *bp; /* leaf buffer */ 1109 struct xfs_buf *bp; /* leaf buffer */
1118 int bytes; /* bytes in use */ 1110 int bytes; /* bytes in use */
1119 int count; /* leaf live entry count */ 1111 int count; /* leaf live entry count */
1120 int error; /* error return value */ 1112 int error; /* error return value */
@@ -1130,7 +1122,7 @@ xfs_dir2_leafn_toosmall(
1130 * to coalesce with a sibling. 1122 * to coalesce with a sibling.
1131 */ 1123 */
1132 blk = &state->path.blk[state->path.active - 1]; 1124 blk = &state->path.blk[state->path.active - 1];
1133 info = blk->bp->data; 1125 info = blk->bp->b_addr;
1134 ASSERT(info->magic == cpu_to_be16(XFS_DIR2_LEAFN_MAGIC)); 1126 ASSERT(info->magic == cpu_to_be16(XFS_DIR2_LEAFN_MAGIC));
1135 leaf = (xfs_dir2_leaf_t *)info; 1127 leaf = (xfs_dir2_leaf_t *)info;
1136 count = be16_to_cpu(leaf->hdr.count) - be16_to_cpu(leaf->hdr.stale); 1128 count = be16_to_cpu(leaf->hdr.count) - be16_to_cpu(leaf->hdr.stale);
@@ -1189,7 +1181,7 @@ xfs_dir2_leafn_toosmall(
1189 leaf = (xfs_dir2_leaf_t *)info; 1181 leaf = (xfs_dir2_leaf_t *)info;
1190 count = be16_to_cpu(leaf->hdr.count) - be16_to_cpu(leaf->hdr.stale); 1182 count = be16_to_cpu(leaf->hdr.count) - be16_to_cpu(leaf->hdr.stale);
1191 bytes = state->blocksize - (state->blocksize >> 2); 1183 bytes = state->blocksize - (state->blocksize >> 2);
1192 leaf = bp->data; 1184 leaf = bp->b_addr;
1193 ASSERT(leaf->hdr.info.magic == cpu_to_be16(XFS_DIR2_LEAFN_MAGIC)); 1185 ASSERT(leaf->hdr.info.magic == cpu_to_be16(XFS_DIR2_LEAFN_MAGIC));
1194 count += be16_to_cpu(leaf->hdr.count) - be16_to_cpu(leaf->hdr.stale); 1186 count += be16_to_cpu(leaf->hdr.count) - be16_to_cpu(leaf->hdr.stale);
1195 bytes -= count * (uint)sizeof(leaf->ents[0]); 1187 bytes -= count * (uint)sizeof(leaf->ents[0]);
@@ -1198,7 +1190,7 @@ xfs_dir2_leafn_toosmall(
1198 */ 1190 */
1199 if (bytes >= 0) 1191 if (bytes >= 0)
1200 break; 1192 break;
1201 xfs_da_brelse(state->args->trans, bp); 1193 xfs_trans_brelse(state->args->trans, bp);
1202 } 1194 }
1203 /* 1195 /*
1204 * Didn't like either block, give up. 1196 * Didn't like either block, give up.
@@ -1207,11 +1199,7 @@ xfs_dir2_leafn_toosmall(
1207 *action = 0; 1199 *action = 0;
1208 return 0; 1200 return 0;
1209 } 1201 }
1210 /* 1202
1211 * Done with the sibling leaf block here, drop the dabuf
1212 * so path_shift can get it.
1213 */
1214 xfs_da_buf_done(bp);
1215 /* 1203 /*
1216 * Make altpath point to the block we want to keep (the lower 1204 * Make altpath point to the block we want to keep (the lower
1217 * numbered block) and path point to the block we want to drop. 1205 * numbered block) and path point to the block we want to drop.
@@ -1247,8 +1235,8 @@ xfs_dir2_leafn_unbalance(
1247 args = state->args; 1235 args = state->args;
1248 ASSERT(drop_blk->magic == XFS_DIR2_LEAFN_MAGIC); 1236 ASSERT(drop_blk->magic == XFS_DIR2_LEAFN_MAGIC);
1249 ASSERT(save_blk->magic == XFS_DIR2_LEAFN_MAGIC); 1237 ASSERT(save_blk->magic == XFS_DIR2_LEAFN_MAGIC);
1250 drop_leaf = drop_blk->bp->data; 1238 drop_leaf = drop_blk->bp->b_addr;
1251 save_leaf = save_blk->bp->data; 1239 save_leaf = save_blk->bp->b_addr;
1252 ASSERT(drop_leaf->hdr.info.magic == cpu_to_be16(XFS_DIR2_LEAFN_MAGIC)); 1240 ASSERT(drop_leaf->hdr.info.magic == cpu_to_be16(XFS_DIR2_LEAFN_MAGIC));
1253 ASSERT(save_leaf->hdr.info.magic == cpu_to_be16(XFS_DIR2_LEAFN_MAGIC)); 1241 ASSERT(save_leaf->hdr.info.magic == cpu_to_be16(XFS_DIR2_LEAFN_MAGIC));
1254 /* 1242 /*
@@ -1356,13 +1344,13 @@ xfs_dir2_node_addname_int(
1356{ 1344{
1357 xfs_dir2_data_hdr_t *hdr; /* data block header */ 1345 xfs_dir2_data_hdr_t *hdr; /* data block header */
1358 xfs_dir2_db_t dbno; /* data block number */ 1346 xfs_dir2_db_t dbno; /* data block number */
1359 xfs_dabuf_t *dbp; /* data block buffer */ 1347 struct xfs_buf *dbp; /* data block buffer */
1360 xfs_dir2_data_entry_t *dep; /* data entry pointer */ 1348 xfs_dir2_data_entry_t *dep; /* data entry pointer */
1361 xfs_inode_t *dp; /* incore directory inode */ 1349 xfs_inode_t *dp; /* incore directory inode */
1362 xfs_dir2_data_unused_t *dup; /* data unused entry pointer */ 1350 xfs_dir2_data_unused_t *dup; /* data unused entry pointer */
1363 int error; /* error return value */ 1351 int error; /* error return value */
1364 xfs_dir2_db_t fbno; /* freespace block number */ 1352 xfs_dir2_db_t fbno; /* freespace block number */
1365 xfs_dabuf_t *fbp; /* freespace buffer */ 1353 struct xfs_buf *fbp; /* freespace buffer */
1366 int findex; /* freespace entry index */ 1354 int findex; /* freespace entry index */
1367 xfs_dir2_free_t *free=NULL; /* freespace block structure */ 1355 xfs_dir2_free_t *free=NULL; /* freespace block structure */
1368 xfs_dir2_db_t ifbno; /* initial freespace block no */ 1356 xfs_dir2_db_t ifbno; /* initial freespace block no */
@@ -1390,7 +1378,7 @@ xfs_dir2_node_addname_int(
1390 * Remember initial freespace block number. 1378 * Remember initial freespace block number.
1391 */ 1379 */
1392 ifbno = fblk->blkno; 1380 ifbno = fblk->blkno;
1393 free = fbp->data; 1381 free = fbp->b_addr;
1394 ASSERT(free->hdr.magic == cpu_to_be32(XFS_DIR2_FREE_MAGIC)); 1382 ASSERT(free->hdr.magic == cpu_to_be32(XFS_DIR2_FREE_MAGIC));
1395 findex = fblk->index; 1383 findex = fblk->index;
1396 /* 1384 /*
@@ -1474,7 +1462,7 @@ xfs_dir2_node_addname_int(
1474 if (unlikely(fbp == NULL)) { 1462 if (unlikely(fbp == NULL)) {
1475 continue; 1463 continue;
1476 } 1464 }
1477 free = fbp->data; 1465 free = fbp->b_addr;
1478 ASSERT(free->hdr.magic == cpu_to_be32(XFS_DIR2_FREE_MAGIC)); 1466 ASSERT(free->hdr.magic == cpu_to_be32(XFS_DIR2_FREE_MAGIC));
1479 findex = 0; 1467 findex = 0;
1480 } 1468 }
@@ -1492,7 +1480,7 @@ xfs_dir2_node_addname_int(
1492 /* 1480 /*
1493 * Drop the block. 1481 * Drop the block.
1494 */ 1482 */
1495 xfs_da_brelse(tp, fbp); 1483 xfs_trans_brelse(tp, fbp);
1496 fbp = NULL; 1484 fbp = NULL;
1497 if (fblk && fblk->bp) 1485 if (fblk && fblk->bp)
1498 fblk->bp = NULL; 1486 fblk->bp = NULL;
@@ -1507,36 +1495,23 @@ xfs_dir2_node_addname_int(
1507 /* 1495 /*
1508 * Not allowed to allocate, return failure. 1496 * Not allowed to allocate, return failure.
1509 */ 1497 */
1510 if ((args->op_flags & XFS_DA_OP_JUSTCHECK) || 1498 if ((args->op_flags & XFS_DA_OP_JUSTCHECK) || args->total == 0)
1511 args->total == 0) {
1512 /*
1513 * Drop the freespace buffer unless it came from our
1514 * caller.
1515 */
1516 if ((fblk == NULL || fblk->bp == NULL) && fbp != NULL)
1517 xfs_da_buf_done(fbp);
1518 return XFS_ERROR(ENOSPC); 1499 return XFS_ERROR(ENOSPC);
1519 } 1500
1520 /* 1501 /*
1521 * Allocate and initialize the new data block. 1502 * Allocate and initialize the new data block.
1522 */ 1503 */
1523 if (unlikely((error = xfs_dir2_grow_inode(args, 1504 if (unlikely((error = xfs_dir2_grow_inode(args,
1524 XFS_DIR2_DATA_SPACE, 1505 XFS_DIR2_DATA_SPACE,
1525 &dbno)) || 1506 &dbno)) ||
1526 (error = xfs_dir2_data_init(args, dbno, &dbp)))) { 1507 (error = xfs_dir2_data_init(args, dbno, &dbp))))
1527 /*
1528 * Drop the freespace buffer unless it came from our
1529 * caller.
1530 */
1531 if ((fblk == NULL || fblk->bp == NULL) && fbp != NULL)
1532 xfs_da_buf_done(fbp);
1533 return error; 1508 return error;
1534 } 1509
1535 /* 1510 /*
1536 * If (somehow) we have a freespace block, get rid of it. 1511 * If (somehow) we have a freespace block, get rid of it.
1537 */ 1512 */
1538 if (fbp) 1513 if (fbp)
1539 xfs_da_brelse(tp, fbp); 1514 xfs_trans_brelse(tp, fbp);
1540 if (fblk && fblk->bp) 1515 if (fblk && fblk->bp)
1541 fblk->bp = NULL; 1516 fblk->bp = NULL;
1542 1517
@@ -1547,10 +1522,9 @@ xfs_dir2_node_addname_int(
1547 fbno = xfs_dir2_db_to_fdb(mp, dbno); 1522 fbno = xfs_dir2_db_to_fdb(mp, dbno);
1548 if (unlikely(error = xfs_da_read_buf(tp, dp, 1523 if (unlikely(error = xfs_da_read_buf(tp, dp,
1549 xfs_dir2_db_to_da(mp, fbno), -2, &fbp, 1524 xfs_dir2_db_to_da(mp, fbno), -2, &fbp,
1550 XFS_DATA_FORK))) { 1525 XFS_DATA_FORK)))
1551 xfs_da_buf_done(dbp);
1552 return error; 1526 return error;
1553 } 1527
1554 /* 1528 /*
1555 * If there wasn't a freespace block, the read will 1529 * If there wasn't a freespace block, the read will
1556 * return a NULL fbp. Allocate and initialize a new one. 1530 * return a NULL fbp. Allocate and initialize a new one.
@@ -1598,7 +1572,7 @@ xfs_dir2_node_addname_int(
1598 * Initialize the new block to be empty, and remember 1572 * Initialize the new block to be empty, and remember
1599 * its first slot as our empty slot. 1573 * its first slot as our empty slot.
1600 */ 1574 */
1601 free = fbp->data; 1575 free = fbp->b_addr;
1602 free->hdr.magic = cpu_to_be32(XFS_DIR2_FREE_MAGIC); 1576 free->hdr.magic = cpu_to_be32(XFS_DIR2_FREE_MAGIC);
1603 free->hdr.firstdb = cpu_to_be32( 1577 free->hdr.firstdb = cpu_to_be32(
1604 (fbno - XFS_DIR2_FREE_FIRSTDB(mp)) * 1578 (fbno - XFS_DIR2_FREE_FIRSTDB(mp)) *
@@ -1606,7 +1580,7 @@ xfs_dir2_node_addname_int(
1606 free->hdr.nvalid = 0; 1580 free->hdr.nvalid = 0;
1607 free->hdr.nused = 0; 1581 free->hdr.nused = 0;
1608 } else { 1582 } else {
1609 free = fbp->data; 1583 free = fbp->b_addr;
1610 ASSERT(free->hdr.magic == cpu_to_be32(XFS_DIR2_FREE_MAGIC)); 1584 ASSERT(free->hdr.magic == cpu_to_be32(XFS_DIR2_FREE_MAGIC));
1611 } 1585 }
1612 1586
@@ -1639,7 +1613,7 @@ xfs_dir2_node_addname_int(
1639 * We haven't allocated the data entry yet so this will 1613 * We haven't allocated the data entry yet so this will
1640 * change again. 1614 * change again.
1641 */ 1615 */
1642 hdr = dbp->data; 1616 hdr = dbp->b_addr;
1643 free->bests[findex] = hdr->bestfree[0].length; 1617 free->bests[findex] = hdr->bestfree[0].length;
1644 logfree = 1; 1618 logfree = 1;
1645 } 1619 }
@@ -1650,22 +1624,17 @@ xfs_dir2_node_addname_int(
1650 /* 1624 /*
1651 * If just checking, we succeeded. 1625 * If just checking, we succeeded.
1652 */ 1626 */
1653 if (args->op_flags & XFS_DA_OP_JUSTCHECK) { 1627 if (args->op_flags & XFS_DA_OP_JUSTCHECK)
1654 if ((fblk == NULL || fblk->bp == NULL) && fbp != NULL)
1655 xfs_da_buf_done(fbp);
1656 return 0; 1628 return 0;
1657 } 1629
1658 /* 1630 /*
1659 * Read the data block in. 1631 * Read the data block in.
1660 */ 1632 */
1661 if (unlikely( 1633 error = xfs_da_read_buf(tp, dp, xfs_dir2_db_to_da(mp, dbno),
1662 error = xfs_da_read_buf(tp, dp, xfs_dir2_db_to_da(mp, dbno), 1634 -1, &dbp, XFS_DATA_FORK);
1663 -1, &dbp, XFS_DATA_FORK))) { 1635 if (error)
1664 if ((fblk == NULL || fblk->bp == NULL) && fbp != NULL)
1665 xfs_da_buf_done(fbp);
1666 return error; 1636 return error;
1667 } 1637 hdr = dbp->b_addr;
1668 hdr = dbp->data;
1669 logfree = 0; 1638 logfree = 0;
1670 } 1639 }
1671 ASSERT(be16_to_cpu(hdr->bestfree[0].length) >= length); 1640 ASSERT(be16_to_cpu(hdr->bestfree[0].length) >= length);
@@ -1714,16 +1683,10 @@ xfs_dir2_node_addname_int(
1714 if (logfree) 1683 if (logfree)
1715 xfs_dir2_free_log_bests(tp, fbp, findex, findex); 1684 xfs_dir2_free_log_bests(tp, fbp, findex, findex);
1716 /* 1685 /*
1717 * If the caller didn't hand us the freespace block, drop it.
1718 */
1719 if ((fblk == NULL || fblk->bp == NULL) && fbp != NULL)
1720 xfs_da_buf_done(fbp);
1721 /*
1722 * Return the data block and offset in args, then drop the data block. 1686 * Return the data block and offset in args, then drop the data block.
1723 */ 1687 */
1724 args->blkno = (xfs_dablk_t)dbno; 1688 args->blkno = (xfs_dablk_t)dbno;
1725 args->index = be16_to_cpu(*tagp); 1689 args->index = be16_to_cpu(*tagp);
1726 xfs_da_buf_done(dbp);
1727 return 0; 1690 return 0;
1728} 1691}
1729 1692
@@ -1761,22 +1724,23 @@ xfs_dir2_node_lookup(
1761 /* If a CI match, dup the actual name and return EEXIST */ 1724 /* If a CI match, dup the actual name and return EEXIST */
1762 xfs_dir2_data_entry_t *dep; 1725 xfs_dir2_data_entry_t *dep;
1763 1726
1764 dep = (xfs_dir2_data_entry_t *)((char *)state->extrablk.bp-> 1727 dep = (xfs_dir2_data_entry_t *)
1765 data + state->extrablk.index); 1728 ((char *)state->extrablk.bp->b_addr +
1729 state->extrablk.index);
1766 rval = xfs_dir_cilookup_result(args, dep->name, dep->namelen); 1730 rval = xfs_dir_cilookup_result(args, dep->name, dep->namelen);
1767 } 1731 }
1768 /* 1732 /*
1769 * Release the btree blocks and leaf block. 1733 * Release the btree blocks and leaf block.
1770 */ 1734 */
1771 for (i = 0; i < state->path.active; i++) { 1735 for (i = 0; i < state->path.active; i++) {
1772 xfs_da_brelse(args->trans, state->path.blk[i].bp); 1736 xfs_trans_brelse(args->trans, state->path.blk[i].bp);
1773 state->path.blk[i].bp = NULL; 1737 state->path.blk[i].bp = NULL;
1774 } 1738 }
1775 /* 1739 /*
1776 * Release the data block if we have it. 1740 * Release the data block if we have it.
1777 */ 1741 */
1778 if (state->extravalid && state->extrablk.bp) { 1742 if (state->extravalid && state->extrablk.bp) {
1779 xfs_da_brelse(args->trans, state->extrablk.bp); 1743 xfs_trans_brelse(args->trans, state->extrablk.bp);
1780 state->extrablk.bp = NULL; 1744 state->extrablk.bp = NULL;
1781 } 1745 }
1782 xfs_da_state_free(state); 1746 xfs_da_state_free(state);
@@ -1893,13 +1857,13 @@ xfs_dir2_node_replace(
1893 */ 1857 */
1894 blk = &state->path.blk[state->path.active - 1]; 1858 blk = &state->path.blk[state->path.active - 1];
1895 ASSERT(blk->magic == XFS_DIR2_LEAFN_MAGIC); 1859 ASSERT(blk->magic == XFS_DIR2_LEAFN_MAGIC);
1896 leaf = blk->bp->data; 1860 leaf = blk->bp->b_addr;
1897 lep = &leaf->ents[blk->index]; 1861 lep = &leaf->ents[blk->index];
1898 ASSERT(state->extravalid); 1862 ASSERT(state->extravalid);
1899 /* 1863 /*
1900 * Point to the data entry. 1864 * Point to the data entry.
1901 */ 1865 */
1902 hdr = state->extrablk.bp->data; 1866 hdr = state->extrablk.bp->b_addr;
1903 ASSERT(hdr->magic == cpu_to_be32(XFS_DIR2_DATA_MAGIC)); 1867 ASSERT(hdr->magic == cpu_to_be32(XFS_DIR2_DATA_MAGIC));
1904 dep = (xfs_dir2_data_entry_t *) 1868 dep = (xfs_dir2_data_entry_t *)
1905 ((char *)hdr + 1869 ((char *)hdr +
@@ -1916,14 +1880,14 @@ xfs_dir2_node_replace(
1916 * Didn't find it, and we're holding a data block. Drop it. 1880 * Didn't find it, and we're holding a data block. Drop it.
1917 */ 1881 */
1918 else if (state->extravalid) { 1882 else if (state->extravalid) {
1919 xfs_da_brelse(args->trans, state->extrablk.bp); 1883 xfs_trans_brelse(args->trans, state->extrablk.bp);
1920 state->extrablk.bp = NULL; 1884 state->extrablk.bp = NULL;
1921 } 1885 }
1922 /* 1886 /*
1923 * Release all the buffers in the cursor. 1887 * Release all the buffers in the cursor.
1924 */ 1888 */
1925 for (i = 0; i < state->path.active; i++) { 1889 for (i = 0; i < state->path.active; i++) {
1926 xfs_da_brelse(args->trans, state->path.blk[i].bp); 1890 xfs_trans_brelse(args->trans, state->path.blk[i].bp);
1927 state->path.blk[i].bp = NULL; 1891 state->path.blk[i].bp = NULL;
1928 } 1892 }
1929 xfs_da_state_free(state); 1893 xfs_da_state_free(state);
@@ -1940,7 +1904,7 @@ xfs_dir2_node_trim_free(
1940 xfs_fileoff_t fo, /* free block number */ 1904 xfs_fileoff_t fo, /* free block number */
1941 int *rvalp) /* out: did something */ 1905 int *rvalp) /* out: did something */
1942{ 1906{
1943 xfs_dabuf_t *bp; /* freespace buffer */ 1907 struct xfs_buf *bp; /* freespace buffer */
1944 xfs_inode_t *dp; /* incore directory inode */ 1908 xfs_inode_t *dp; /* incore directory inode */
1945 int error; /* error return code */ 1909 int error; /* error return code */
1946 xfs_dir2_free_t *free; /* freespace structure */ 1910 xfs_dir2_free_t *free; /* freespace structure */
@@ -1965,13 +1929,13 @@ xfs_dir2_node_trim_free(
1965 if (bp == NULL) { 1929 if (bp == NULL) {
1966 return 0; 1930 return 0;
1967 } 1931 }
1968 free = bp->data; 1932 free = bp->b_addr;
1969 ASSERT(free->hdr.magic == cpu_to_be32(XFS_DIR2_FREE_MAGIC)); 1933 ASSERT(free->hdr.magic == cpu_to_be32(XFS_DIR2_FREE_MAGIC));
1970 /* 1934 /*
1971 * If there are used entries, there's nothing to do. 1935 * If there are used entries, there's nothing to do.
1972 */ 1936 */
1973 if (be32_to_cpu(free->hdr.nused) > 0) { 1937 if (be32_to_cpu(free->hdr.nused) > 0) {
1974 xfs_da_brelse(tp, bp); 1938 xfs_trans_brelse(tp, bp);
1975 *rvalp = 0; 1939 *rvalp = 0;
1976 return 0; 1940 return 0;
1977 } 1941 }
@@ -1987,7 +1951,7 @@ xfs_dir2_node_trim_free(
1987 * pieces. This is the last block of an extent. 1951 * pieces. This is the last block of an extent.
1988 */ 1952 */
1989 ASSERT(error != ENOSPC); 1953 ASSERT(error != ENOSPC);
1990 xfs_da_brelse(tp, bp); 1954 xfs_trans_brelse(tp, bp);
1991 return error; 1955 return error;
1992 } 1956 }
1993 /* 1957 /*