diff options
-rw-r--r-- | fs/xfs/xfs_dir2_block.c | 175 | ||||
-rw-r--r-- | fs/xfs/xfs_dir2_block.h | 5 | ||||
-rw-r--r-- | fs/xfs/xfs_dir2_data.c | 6 | ||||
-rw-r--r-- | fs/xfs/xfs_dir2_leaf.c | 16 | ||||
-rw-r--r-- | fs/xfs/xfs_dir2_sf.c | 9 | ||||
-rw-r--r-- | fs/xfs/xfs_dir2_sf.h | 4 |
6 files changed, 106 insertions, 109 deletions
diff --git a/fs/xfs/xfs_dir2_block.c b/fs/xfs/xfs_dir2_block.c index c66f194fc2a8..a0037cc4dd8c 100644 --- a/fs/xfs/xfs_dir2_block.c +++ b/fs/xfs/xfs_dir2_block.c | |||
@@ -67,7 +67,7 @@ xfs_dir2_block_addname( | |||
67 | xfs_da_args_t *args) /* directory op arguments */ | 67 | xfs_da_args_t *args) /* directory op arguments */ |
68 | { | 68 | { |
69 | xfs_dir2_data_free_t *bf; /* bestfree table in block */ | 69 | xfs_dir2_data_free_t *bf; /* bestfree table in block */ |
70 | xfs_dir2_block_t *block; /* directory block structure */ | 70 | xfs_dir2_data_hdr_t *hdr; /* block header */ |
71 | xfs_dir2_leaf_entry_t *blp; /* block leaf entries */ | 71 | xfs_dir2_leaf_entry_t *blp; /* block leaf entries */ |
72 | xfs_dabuf_t *bp; /* buffer for block */ | 72 | xfs_dabuf_t *bp; /* buffer for block */ |
73 | xfs_dir2_block_tail_t *btp; /* block tail */ | 73 | xfs_dir2_block_tail_t *btp; /* block tail */ |
@@ -105,13 +105,13 @@ xfs_dir2_block_addname( | |||
105 | return error; | 105 | return error; |
106 | } | 106 | } |
107 | ASSERT(bp != NULL); | 107 | ASSERT(bp != NULL); |
108 | block = bp->data; | 108 | hdr = bp->data; |
109 | /* | 109 | /* |
110 | * Check the magic number, corrupted if wrong. | 110 | * Check the magic number, corrupted if wrong. |
111 | */ | 111 | */ |
112 | if (unlikely(be32_to_cpu(block->hdr.magic) != XFS_DIR2_BLOCK_MAGIC)) { | 112 | if (unlikely(be32_to_cpu(hdr->magic) != XFS_DIR2_BLOCK_MAGIC)) { |
113 | XFS_CORRUPTION_ERROR("xfs_dir2_block_addname", | 113 | XFS_CORRUPTION_ERROR("xfs_dir2_block_addname", |
114 | XFS_ERRLEVEL_LOW, mp, block); | 114 | XFS_ERRLEVEL_LOW, mp, hdr); |
115 | xfs_da_brelse(tp, bp); | 115 | xfs_da_brelse(tp, bp); |
116 | return XFS_ERROR(EFSCORRUPTED); | 116 | return XFS_ERROR(EFSCORRUPTED); |
117 | } | 117 | } |
@@ -119,8 +119,8 @@ xfs_dir2_block_addname( | |||
119 | /* | 119 | /* |
120 | * Set up pointers to parts of the block. | 120 | * Set up pointers to parts of the block. |
121 | */ | 121 | */ |
122 | bf = block->hdr.bestfree; | 122 | bf = hdr->bestfree; |
123 | btp = xfs_dir2_block_tail_p(mp, block); | 123 | btp = xfs_dir2_block_tail_p(mp, hdr); |
124 | blp = xfs_dir2_block_leaf_p(btp); | 124 | blp = xfs_dir2_block_leaf_p(btp); |
125 | /* | 125 | /* |
126 | * No stale entries? Need space for entry and new leaf. | 126 | * No stale entries? Need space for entry and new leaf. |
@@ -133,7 +133,7 @@ xfs_dir2_block_addname( | |||
133 | /* | 133 | /* |
134 | * Data object just before the first leaf entry. | 134 | * Data object just before the first leaf entry. |
135 | */ | 135 | */ |
136 | enddup = (xfs_dir2_data_unused_t *)((char *)block + be16_to_cpu(*tagp)); | 136 | enddup = (xfs_dir2_data_unused_t *)((char *)hdr + be16_to_cpu(*tagp)); |
137 | /* | 137 | /* |
138 | * If it's not free then can't do this add without cleaning up: | 138 | * If it's not free then can't do this add without cleaning up: |
139 | * the space before the first leaf entry needs to be free so it | 139 | * the space before the first leaf entry needs to be free so it |
@@ -146,7 +146,7 @@ xfs_dir2_block_addname( | |||
146 | */ | 146 | */ |
147 | else { | 147 | else { |
148 | dup = (xfs_dir2_data_unused_t *) | 148 | dup = (xfs_dir2_data_unused_t *) |
149 | ((char *)block + be16_to_cpu(bf[0].offset)); | 149 | ((char *)hdr + be16_to_cpu(bf[0].offset)); |
150 | if (dup == enddup) { | 150 | if (dup == enddup) { |
151 | /* | 151 | /* |
152 | * It is the biggest freespace, is it too small | 152 | * It is the biggest freespace, is it too small |
@@ -159,7 +159,7 @@ xfs_dir2_block_addname( | |||
159 | */ | 159 | */ |
160 | if (be16_to_cpu(bf[1].length) >= len) | 160 | if (be16_to_cpu(bf[1].length) >= len) |
161 | dup = (xfs_dir2_data_unused_t *) | 161 | dup = (xfs_dir2_data_unused_t *) |
162 | ((char *)block + | 162 | ((char *)hdr + |
163 | be16_to_cpu(bf[1].offset)); | 163 | be16_to_cpu(bf[1].offset)); |
164 | else | 164 | else |
165 | dup = NULL; | 165 | dup = NULL; |
@@ -182,7 +182,7 @@ xfs_dir2_block_addname( | |||
182 | */ | 182 | */ |
183 | else if (be16_to_cpu(bf[0].length) >= len) { | 183 | else if (be16_to_cpu(bf[0].length) >= len) { |
184 | dup = (xfs_dir2_data_unused_t *) | 184 | dup = (xfs_dir2_data_unused_t *) |
185 | ((char *)block + be16_to_cpu(bf[0].offset)); | 185 | ((char *)hdr + be16_to_cpu(bf[0].offset)); |
186 | compact = 0; | 186 | compact = 0; |
187 | } | 187 | } |
188 | /* | 188 | /* |
@@ -196,7 +196,7 @@ xfs_dir2_block_addname( | |||
196 | /* | 196 | /* |
197 | * Data object just before the first leaf entry. | 197 | * Data object just before the first leaf entry. |
198 | */ | 198 | */ |
199 | dup = (xfs_dir2_data_unused_t *)((char *)block + be16_to_cpu(*tagp)); | 199 | dup = (xfs_dir2_data_unused_t *)((char *)hdr + be16_to_cpu(*tagp)); |
200 | /* | 200 | /* |
201 | * If it's not free then the data will go where the | 201 | * If it's not free then the data will go where the |
202 | * leaf data starts now, if it works at all. | 202 | * leaf data starts now, if it works at all. |
@@ -272,7 +272,7 @@ xfs_dir2_block_addname( | |||
272 | lfloghigh -= be32_to_cpu(btp->stale) - 1; | 272 | lfloghigh -= be32_to_cpu(btp->stale) - 1; |
273 | be32_add_cpu(&btp->count, -(be32_to_cpu(btp->stale) - 1)); | 273 | be32_add_cpu(&btp->count, -(be32_to_cpu(btp->stale) - 1)); |
274 | xfs_dir2_data_make_free(tp, bp, | 274 | xfs_dir2_data_make_free(tp, bp, |
275 | (xfs_dir2_data_aoff_t)((char *)blp - (char *)block), | 275 | (xfs_dir2_data_aoff_t)((char *)blp - (char *)hdr), |
276 | (xfs_dir2_data_aoff_t)((be32_to_cpu(btp->stale) - 1) * sizeof(*blp)), | 276 | (xfs_dir2_data_aoff_t)((be32_to_cpu(btp->stale) - 1) * sizeof(*blp)), |
277 | &needlog, &needscan); | 277 | &needlog, &needscan); |
278 | blp += be32_to_cpu(btp->stale) - 1; | 278 | blp += be32_to_cpu(btp->stale) - 1; |
@@ -282,7 +282,7 @@ xfs_dir2_block_addname( | |||
282 | * This needs to happen before the next call to use_free. | 282 | * This needs to happen before the next call to use_free. |
283 | */ | 283 | */ |
284 | if (needscan) { | 284 | if (needscan) { |
285 | xfs_dir2_data_freescan(mp, (xfs_dir2_data_t *)block, &needlog); | 285 | xfs_dir2_data_freescan(mp, (xfs_dir2_data_t *)hdr, &needlog); |
286 | needscan = 0; | 286 | needscan = 0; |
287 | } | 287 | } |
288 | } | 288 | } |
@@ -318,7 +318,7 @@ xfs_dir2_block_addname( | |||
318 | */ | 318 | */ |
319 | xfs_dir2_data_use_free(tp, bp, enddup, | 319 | xfs_dir2_data_use_free(tp, bp, enddup, |
320 | (xfs_dir2_data_aoff_t) | 320 | (xfs_dir2_data_aoff_t) |
321 | ((char *)enddup - (char *)block + be16_to_cpu(enddup->length) - | 321 | ((char *)enddup - (char *)hdr + be16_to_cpu(enddup->length) - |
322 | sizeof(*blp)), | 322 | sizeof(*blp)), |
323 | (xfs_dir2_data_aoff_t)sizeof(*blp), | 323 | (xfs_dir2_data_aoff_t)sizeof(*blp), |
324 | &needlog, &needscan); | 324 | &needlog, &needscan); |
@@ -331,7 +331,7 @@ xfs_dir2_block_addname( | |||
331 | * This needs to happen before the next call to use_free. | 331 | * This needs to happen before the next call to use_free. |
332 | */ | 332 | */ |
333 | if (needscan) { | 333 | if (needscan) { |
334 | xfs_dir2_data_freescan(mp, (xfs_dir2_data_t *)block, | 334 | xfs_dir2_data_freescan(mp, (xfs_dir2_data_t *)hdr, |
335 | &needlog); | 335 | &needlog); |
336 | needscan = 0; | 336 | needscan = 0; |
337 | } | 337 | } |
@@ -397,13 +397,13 @@ xfs_dir2_block_addname( | |||
397 | */ | 397 | */ |
398 | blp[mid].hashval = cpu_to_be32(args->hashval); | 398 | blp[mid].hashval = cpu_to_be32(args->hashval); |
399 | blp[mid].address = cpu_to_be32(xfs_dir2_byte_to_dataptr(mp, | 399 | blp[mid].address = cpu_to_be32(xfs_dir2_byte_to_dataptr(mp, |
400 | (char *)dep - (char *)block)); | 400 | (char *)dep - (char *)hdr)); |
401 | xfs_dir2_block_log_leaf(tp, bp, lfloglow, lfloghigh); | 401 | xfs_dir2_block_log_leaf(tp, bp, lfloglow, lfloghigh); |
402 | /* | 402 | /* |
403 | * Mark space for the data entry used. | 403 | * Mark space for the data entry used. |
404 | */ | 404 | */ |
405 | xfs_dir2_data_use_free(tp, bp, dup, | 405 | xfs_dir2_data_use_free(tp, bp, dup, |
406 | (xfs_dir2_data_aoff_t)((char *)dup - (char *)block), | 406 | (xfs_dir2_data_aoff_t)((char *)dup - (char *)hdr), |
407 | (xfs_dir2_data_aoff_t)len, &needlog, &needscan); | 407 | (xfs_dir2_data_aoff_t)len, &needlog, &needscan); |
408 | /* | 408 | /* |
409 | * Create the new data entry. | 409 | * Create the new data entry. |
@@ -412,12 +412,12 @@ xfs_dir2_block_addname( | |||
412 | dep->namelen = args->namelen; | 412 | dep->namelen = args->namelen; |
413 | memcpy(dep->name, args->name, args->namelen); | 413 | memcpy(dep->name, args->name, args->namelen); |
414 | tagp = xfs_dir2_data_entry_tag_p(dep); | 414 | tagp = xfs_dir2_data_entry_tag_p(dep); |
415 | *tagp = cpu_to_be16((char *)dep - (char *)block); | 415 | *tagp = cpu_to_be16((char *)dep - (char *)hdr); |
416 | /* | 416 | /* |
417 | * Clean up the bestfree array and log the header, tail, and entry. | 417 | * Clean up the bestfree array and log the header, tail, and entry. |
418 | */ | 418 | */ |
419 | if (needscan) | 419 | if (needscan) |
420 | xfs_dir2_data_freescan(mp, (xfs_dir2_data_t *)block, &needlog); | 420 | xfs_dir2_data_freescan(mp, (xfs_dir2_data_t *)hdr, &needlog); |
421 | if (needlog) | 421 | if (needlog) |
422 | xfs_dir2_data_log_header(tp, bp); | 422 | xfs_dir2_data_log_header(tp, bp); |
423 | xfs_dir2_block_log_tail(tp, bp); | 423 | xfs_dir2_block_log_tail(tp, bp); |
@@ -438,6 +438,7 @@ xfs_dir2_block_getdents( | |||
438 | filldir_t filldir) | 438 | filldir_t filldir) |
439 | { | 439 | { |
440 | xfs_dir2_block_t *block; /* directory block structure */ | 440 | xfs_dir2_block_t *block; /* directory block structure */ |
441 | xfs_dir2_data_hdr_t *hdr; /* block header */ | ||
441 | xfs_dabuf_t *bp; /* buffer for block */ | 442 | xfs_dabuf_t *bp; /* buffer for block */ |
442 | xfs_dir2_block_tail_t *btp; /* block tail */ | 443 | xfs_dir2_block_tail_t *btp; /* block tail */ |
443 | xfs_dir2_data_entry_t *dep; /* block data entry */ | 444 | xfs_dir2_data_entry_t *dep; /* block data entry */ |
@@ -471,11 +472,12 @@ xfs_dir2_block_getdents( | |||
471 | */ | 472 | */ |
472 | wantoff = xfs_dir2_dataptr_to_off(mp, *offset); | 473 | wantoff = xfs_dir2_dataptr_to_off(mp, *offset); |
473 | block = bp->data; | 474 | block = bp->data; |
475 | hdr = &block->hdr; | ||
474 | xfs_dir2_data_check(dp, bp); | 476 | xfs_dir2_data_check(dp, bp); |
475 | /* | 477 | /* |
476 | * Set up values for the loop. | 478 | * Set up values for the loop. |
477 | */ | 479 | */ |
478 | btp = xfs_dir2_block_tail_p(mp, block); | 480 | btp = xfs_dir2_block_tail_p(mp, hdr); |
479 | ptr = (char *)block->u; | 481 | ptr = (char *)block->u; |
480 | endptr = (char *)xfs_dir2_block_leaf_p(btp); | 482 | endptr = (char *)xfs_dir2_block_leaf_p(btp); |
481 | 483 | ||
@@ -502,11 +504,11 @@ xfs_dir2_block_getdents( | |||
502 | /* | 504 | /* |
503 | * The entry is before the desired starting point, skip it. | 505 | * The entry is before the desired starting point, skip it. |
504 | */ | 506 | */ |
505 | if ((char *)dep - (char *)block < wantoff) | 507 | if ((char *)dep - (char *)hdr < wantoff) |
506 | continue; | 508 | continue; |
507 | 509 | ||
508 | cook = xfs_dir2_db_off_to_dataptr(mp, mp->m_dirdatablk, | 510 | cook = xfs_dir2_db_off_to_dataptr(mp, mp->m_dirdatablk, |
509 | (char *)dep - (char *)block); | 511 | (char *)dep - (char *)hdr); |
510 | 512 | ||
511 | /* | 513 | /* |
512 | * If it didn't fit, set the final offset to here & return. | 514 | * If it didn't fit, set the final offset to here & return. |
@@ -540,17 +542,14 @@ xfs_dir2_block_log_leaf( | |||
540 | int first, /* index of first logged leaf */ | 542 | int first, /* index of first logged leaf */ |
541 | int last) /* index of last logged leaf */ | 543 | int last) /* index of last logged leaf */ |
542 | { | 544 | { |
543 | xfs_dir2_block_t *block; /* directory block structure */ | 545 | xfs_dir2_data_hdr_t *hdr = bp->data; |
544 | xfs_dir2_leaf_entry_t *blp; /* block leaf entries */ | 546 | xfs_dir2_leaf_entry_t *blp; |
545 | xfs_dir2_block_tail_t *btp; /* block tail */ | 547 | xfs_dir2_block_tail_t *btp; |
546 | xfs_mount_t *mp; /* filesystem mount point */ | ||
547 | 548 | ||
548 | mp = tp->t_mountp; | 549 | btp = xfs_dir2_block_tail_p(tp->t_mountp, hdr); |
549 | block = bp->data; | ||
550 | btp = xfs_dir2_block_tail_p(mp, block); | ||
551 | blp = xfs_dir2_block_leaf_p(btp); | 550 | blp = xfs_dir2_block_leaf_p(btp); |
552 | xfs_da_log_buf(tp, bp, (uint)((char *)&blp[first] - (char *)block), | 551 | xfs_da_log_buf(tp, bp, (uint)((char *)&blp[first] - (char *)hdr), |
553 | (uint)((char *)&blp[last + 1] - (char *)block - 1)); | 552 | (uint)((char *)&blp[last + 1] - (char *)hdr - 1)); |
554 | } | 553 | } |
555 | 554 | ||
556 | /* | 555 | /* |
@@ -561,15 +560,12 @@ xfs_dir2_block_log_tail( | |||
561 | xfs_trans_t *tp, /* transaction structure */ | 560 | xfs_trans_t *tp, /* transaction structure */ |
562 | xfs_dabuf_t *bp) /* block buffer */ | 561 | xfs_dabuf_t *bp) /* block buffer */ |
563 | { | 562 | { |
564 | xfs_dir2_block_t *block; /* directory block structure */ | 563 | xfs_dir2_data_hdr_t *hdr = bp->data; |
565 | xfs_dir2_block_tail_t *btp; /* block tail */ | 564 | xfs_dir2_block_tail_t *btp; |
566 | xfs_mount_t *mp; /* filesystem mount point */ | ||
567 | 565 | ||
568 | mp = tp->t_mountp; | 566 | btp = xfs_dir2_block_tail_p(tp->t_mountp, hdr); |
569 | block = bp->data; | 567 | xfs_da_log_buf(tp, bp, (uint)((char *)btp - (char *)hdr), |
570 | btp = xfs_dir2_block_tail_p(mp, block); | 568 | (uint)((char *)(btp + 1) - (char *)hdr - 1)); |
571 | xfs_da_log_buf(tp, bp, (uint)((char *)btp - (char *)block), | ||
572 | (uint)((char *)(btp + 1) - (char *)block - 1)); | ||
573 | } | 569 | } |
574 | 570 | ||
575 | /* | 571 | /* |
@@ -580,7 +576,7 @@ int /* error */ | |||
580 | xfs_dir2_block_lookup( | 576 | xfs_dir2_block_lookup( |
581 | xfs_da_args_t *args) /* dir lookup arguments */ | 577 | xfs_da_args_t *args) /* dir lookup arguments */ |
582 | { | 578 | { |
583 | xfs_dir2_block_t *block; /* block structure */ | 579 | xfs_dir2_data_hdr_t *hdr; /* block header */ |
584 | xfs_dir2_leaf_entry_t *blp; /* block leaf entries */ | 580 | xfs_dir2_leaf_entry_t *blp; /* block leaf entries */ |
585 | xfs_dabuf_t *bp; /* block buffer */ | 581 | xfs_dabuf_t *bp; /* block buffer */ |
586 | xfs_dir2_block_tail_t *btp; /* block tail */ | 582 | xfs_dir2_block_tail_t *btp; /* block tail */ |
@@ -600,14 +596,14 @@ xfs_dir2_block_lookup( | |||
600 | return error; | 596 | return error; |
601 | dp = args->dp; | 597 | dp = args->dp; |
602 | mp = dp->i_mount; | 598 | mp = dp->i_mount; |
603 | block = bp->data; | 599 | hdr = bp->data; |
604 | xfs_dir2_data_check(dp, bp); | 600 | xfs_dir2_data_check(dp, bp); |
605 | btp = xfs_dir2_block_tail_p(mp, block); | 601 | btp = xfs_dir2_block_tail_p(mp, hdr); |
606 | blp = xfs_dir2_block_leaf_p(btp); | 602 | blp = xfs_dir2_block_leaf_p(btp); |
607 | /* | 603 | /* |
608 | * Get the offset from the leaf entry, to point to the data. | 604 | * Get the offset from the leaf entry, to point to the data. |
609 | */ | 605 | */ |
610 | dep = (xfs_dir2_data_entry_t *)((char *)block + | 606 | dep = (xfs_dir2_data_entry_t *)((char *)hdr + |
611 | xfs_dir2_dataptr_to_off(mp, be32_to_cpu(blp[ent].address))); | 607 | xfs_dir2_dataptr_to_off(mp, be32_to_cpu(blp[ent].address))); |
612 | /* | 608 | /* |
613 | * Fill in inode number, CI name if appropriate, release the block. | 609 | * Fill in inode number, CI name if appropriate, release the block. |
@@ -628,7 +624,7 @@ xfs_dir2_block_lookup_int( | |||
628 | int *entno) /* returned entry number */ | 624 | int *entno) /* returned entry number */ |
629 | { | 625 | { |
630 | xfs_dir2_dataptr_t addr; /* data entry address */ | 626 | xfs_dir2_dataptr_t addr; /* data entry address */ |
631 | xfs_dir2_block_t *block; /* block structure */ | 627 | xfs_dir2_data_hdr_t *hdr; /* block header */ |
632 | xfs_dir2_leaf_entry_t *blp; /* block leaf entries */ | 628 | xfs_dir2_leaf_entry_t *blp; /* block leaf entries */ |
633 | xfs_dabuf_t *bp; /* block buffer */ | 629 | xfs_dabuf_t *bp; /* block buffer */ |
634 | xfs_dir2_block_tail_t *btp; /* block tail */ | 630 | xfs_dir2_block_tail_t *btp; /* block tail */ |
@@ -654,9 +650,9 @@ xfs_dir2_block_lookup_int( | |||
654 | return error; | 650 | return error; |
655 | } | 651 | } |
656 | ASSERT(bp != NULL); | 652 | ASSERT(bp != NULL); |
657 | block = bp->data; | 653 | hdr = bp->data; |
658 | xfs_dir2_data_check(dp, bp); | 654 | xfs_dir2_data_check(dp, bp); |
659 | btp = xfs_dir2_block_tail_p(mp, block); | 655 | btp = xfs_dir2_block_tail_p(mp, hdr); |
660 | blp = xfs_dir2_block_leaf_p(btp); | 656 | blp = xfs_dir2_block_leaf_p(btp); |
661 | /* | 657 | /* |
662 | * Loop doing a binary search for our hash value. | 658 | * Loop doing a binary search for our hash value. |
@@ -694,7 +690,7 @@ xfs_dir2_block_lookup_int( | |||
694 | * Get pointer to the entry from the leaf. | 690 | * Get pointer to the entry from the leaf. |
695 | */ | 691 | */ |
696 | dep = (xfs_dir2_data_entry_t *) | 692 | dep = (xfs_dir2_data_entry_t *) |
697 | ((char *)block + xfs_dir2_dataptr_to_off(mp, addr)); | 693 | ((char *)hdr + xfs_dir2_dataptr_to_off(mp, addr)); |
698 | /* | 694 | /* |
699 | * Compare name and if it's an exact match, return the index | 695 | * Compare name and if it's an exact match, return the index |
700 | * and buffer. If it's the first case-insensitive match, store | 696 | * and buffer. If it's the first case-insensitive match, store |
@@ -733,7 +729,7 @@ int /* error */ | |||
733 | xfs_dir2_block_removename( | 729 | xfs_dir2_block_removename( |
734 | xfs_da_args_t *args) /* directory operation args */ | 730 | xfs_da_args_t *args) /* directory operation args */ |
735 | { | 731 | { |
736 | xfs_dir2_block_t *block; /* block structure */ | 732 | xfs_dir2_data_hdr_t *hdr; /* block header */ |
737 | xfs_dir2_leaf_entry_t *blp; /* block leaf pointer */ | 733 | xfs_dir2_leaf_entry_t *blp; /* block leaf pointer */ |
738 | xfs_dabuf_t *bp; /* block buffer */ | 734 | xfs_dabuf_t *bp; /* block buffer */ |
739 | xfs_dir2_block_tail_t *btp; /* block tail */ | 735 | xfs_dir2_block_tail_t *btp; /* block tail */ |
@@ -760,20 +756,20 @@ xfs_dir2_block_removename( | |||
760 | dp = args->dp; | 756 | dp = args->dp; |
761 | tp = args->trans; | 757 | tp = args->trans; |
762 | mp = dp->i_mount; | 758 | mp = dp->i_mount; |
763 | block = bp->data; | 759 | hdr = bp->data; |
764 | btp = xfs_dir2_block_tail_p(mp, block); | 760 | btp = xfs_dir2_block_tail_p(mp, hdr); |
765 | blp = xfs_dir2_block_leaf_p(btp); | 761 | blp = xfs_dir2_block_leaf_p(btp); |
766 | /* | 762 | /* |
767 | * Point to the data entry using the leaf entry. | 763 | * Point to the data entry using the leaf entry. |
768 | */ | 764 | */ |
769 | dep = (xfs_dir2_data_entry_t *) | 765 | dep = (xfs_dir2_data_entry_t *) |
770 | ((char *)block + xfs_dir2_dataptr_to_off(mp, be32_to_cpu(blp[ent].address))); | 766 | ((char *)hdr + xfs_dir2_dataptr_to_off(mp, be32_to_cpu(blp[ent].address))); |
771 | /* | 767 | /* |
772 | * Mark the data entry's space free. | 768 | * Mark the data entry's space free. |
773 | */ | 769 | */ |
774 | needlog = needscan = 0; | 770 | needlog = needscan = 0; |
775 | xfs_dir2_data_make_free(tp, bp, | 771 | xfs_dir2_data_make_free(tp, bp, |
776 | (xfs_dir2_data_aoff_t)((char *)dep - (char *)block), | 772 | (xfs_dir2_data_aoff_t)((char *)dep - (char *)hdr), |
777 | xfs_dir2_data_entsize(dep->namelen), &needlog, &needscan); | 773 | xfs_dir2_data_entsize(dep->namelen), &needlog, &needscan); |
778 | /* | 774 | /* |
779 | * Fix up the block tail. | 775 | * Fix up the block tail. |
@@ -789,15 +785,15 @@ xfs_dir2_block_removename( | |||
789 | * Fix up bestfree, log the header if necessary. | 785 | * Fix up bestfree, log the header if necessary. |
790 | */ | 786 | */ |
791 | if (needscan) | 787 | if (needscan) |
792 | xfs_dir2_data_freescan(mp, (xfs_dir2_data_t *)block, &needlog); | 788 | xfs_dir2_data_freescan(mp, (xfs_dir2_data_t *)hdr, &needlog); |
793 | if (needlog) | 789 | if (needlog) |
794 | xfs_dir2_data_log_header(tp, bp); | 790 | xfs_dir2_data_log_header(tp, bp); |
795 | xfs_dir2_data_check(dp, bp); | 791 | xfs_dir2_data_check(dp, bp); |
796 | /* | 792 | /* |
797 | * See if the size as a shortform is good enough. | 793 | * See if the size as a shortform is good enough. |
798 | */ | 794 | */ |
799 | if ((size = xfs_dir2_block_sfsize(dp, block, &sfh)) > | 795 | size = xfs_dir2_block_sfsize(dp, hdr, &sfh); |
800 | XFS_IFORK_DSIZE(dp)) { | 796 | if (size > XFS_IFORK_DSIZE(dp)) { |
801 | xfs_da_buf_done(bp); | 797 | xfs_da_buf_done(bp); |
802 | return 0; | 798 | return 0; |
803 | } | 799 | } |
@@ -815,7 +811,7 @@ int /* error */ | |||
815 | xfs_dir2_block_replace( | 811 | xfs_dir2_block_replace( |
816 | xfs_da_args_t *args) /* directory operation args */ | 812 | xfs_da_args_t *args) /* directory operation args */ |
817 | { | 813 | { |
818 | xfs_dir2_block_t *block; /* block structure */ | 814 | xfs_dir2_data_hdr_t *hdr; /* block header */ |
819 | xfs_dir2_leaf_entry_t *blp; /* block leaf entries */ | 815 | xfs_dir2_leaf_entry_t *blp; /* block leaf entries */ |
820 | xfs_dabuf_t *bp; /* block buffer */ | 816 | xfs_dabuf_t *bp; /* block buffer */ |
821 | xfs_dir2_block_tail_t *btp; /* block tail */ | 817 | xfs_dir2_block_tail_t *btp; /* block tail */ |
@@ -836,14 +832,14 @@ xfs_dir2_block_replace( | |||
836 | } | 832 | } |
837 | dp = args->dp; | 833 | dp = args->dp; |
838 | mp = dp->i_mount; | 834 | mp = dp->i_mount; |
839 | block = bp->data; | 835 | hdr = bp->data; |
840 | btp = xfs_dir2_block_tail_p(mp, block); | 836 | btp = xfs_dir2_block_tail_p(mp, hdr); |
841 | blp = xfs_dir2_block_leaf_p(btp); | 837 | blp = xfs_dir2_block_leaf_p(btp); |
842 | /* | 838 | /* |
843 | * Point to the data entry we need to change. | 839 | * Point to the data entry we need to change. |
844 | */ | 840 | */ |
845 | dep = (xfs_dir2_data_entry_t *) | 841 | dep = (xfs_dir2_data_entry_t *) |
846 | ((char *)block + xfs_dir2_dataptr_to_off(mp, be32_to_cpu(blp[ent].address))); | 842 | ((char *)hdr + xfs_dir2_dataptr_to_off(mp, be32_to_cpu(blp[ent].address))); |
847 | ASSERT(be64_to_cpu(dep->inumber) != args->inumber); | 843 | ASSERT(be64_to_cpu(dep->inumber) != args->inumber); |
848 | /* | 844 | /* |
849 | * Change the inode number to the new value. | 845 | * Change the inode number to the new value. |
@@ -882,7 +878,7 @@ xfs_dir2_leaf_to_block( | |||
882 | xfs_dabuf_t *dbp) /* data buffer */ | 878 | xfs_dabuf_t *dbp) /* data buffer */ |
883 | { | 879 | { |
884 | __be16 *bestsp; /* leaf bests table */ | 880 | __be16 *bestsp; /* leaf bests table */ |
885 | xfs_dir2_block_t *block; /* block structure */ | 881 | xfs_dir2_data_hdr_t *hdr; /* block header */ |
886 | xfs_dir2_block_tail_t *btp; /* block tail */ | 882 | xfs_dir2_block_tail_t *btp; /* block tail */ |
887 | xfs_inode_t *dp; /* incore directory inode */ | 883 | xfs_inode_t *dp; /* incore directory inode */ |
888 | xfs_dir2_data_unused_t *dup; /* unused data entry */ | 884 | xfs_dir2_data_unused_t *dup; /* unused data entry */ |
@@ -917,7 +913,7 @@ xfs_dir2_leaf_to_block( | |||
917 | while (dp->i_d.di_size > mp->m_dirblksize) { | 913 | while (dp->i_d.di_size > mp->m_dirblksize) { |
918 | bestsp = xfs_dir2_leaf_bests_p(ltp); | 914 | bestsp = xfs_dir2_leaf_bests_p(ltp); |
919 | if (be16_to_cpu(bestsp[be32_to_cpu(ltp->bestcount) - 1]) == | 915 | if (be16_to_cpu(bestsp[be32_to_cpu(ltp->bestcount) - 1]) == |
920 | mp->m_dirblksize - (uint)sizeof(block->hdr)) { | 916 | mp->m_dirblksize - (uint)sizeof(*hdr)) { |
921 | if ((error = | 917 | if ((error = |
922 | xfs_dir2_leaf_trim_data(args, lbp, | 918 | xfs_dir2_leaf_trim_data(args, lbp, |
923 | (xfs_dir2_db_t)(be32_to_cpu(ltp->bestcount) - 1)))) | 919 | (xfs_dir2_db_t)(be32_to_cpu(ltp->bestcount) - 1)))) |
@@ -935,18 +931,18 @@ xfs_dir2_leaf_to_block( | |||
935 | XFS_DATA_FORK))) { | 931 | XFS_DATA_FORK))) { |
936 | goto out; | 932 | goto out; |
937 | } | 933 | } |
938 | block = dbp->data; | 934 | hdr = dbp->data; |
939 | ASSERT(be32_to_cpu(block->hdr.magic) == XFS_DIR2_DATA_MAGIC); | 935 | ASSERT(be32_to_cpu(hdr->magic) == XFS_DIR2_DATA_MAGIC); |
940 | /* | 936 | /* |
941 | * Size of the "leaf" area in the block. | 937 | * Size of the "leaf" area in the block. |
942 | */ | 938 | */ |
943 | size = (uint)sizeof(block->tail) + | 939 | size = (uint)sizeof(xfs_dir2_block_tail_t) + |
944 | (uint)sizeof(*lep) * (be16_to_cpu(leaf->hdr.count) - be16_to_cpu(leaf->hdr.stale)); | 940 | (uint)sizeof(*lep) * (be16_to_cpu(leaf->hdr.count) - be16_to_cpu(leaf->hdr.stale)); |
945 | /* | 941 | /* |
946 | * Look at the last data entry. | 942 | * Look at the last data entry. |
947 | */ | 943 | */ |
948 | tagp = (__be16 *)((char *)block + mp->m_dirblksize) - 1; | 944 | tagp = (__be16 *)((char *)hdr + mp->m_dirblksize) - 1; |
949 | dup = (xfs_dir2_data_unused_t *)((char *)block + be16_to_cpu(*tagp)); | 945 | dup = (xfs_dir2_data_unused_t *)((char *)hdr + be16_to_cpu(*tagp)); |
950 | /* | 946 | /* |
951 | * If it's not free or is too short we can't do it. | 947 | * If it's not free or is too short we can't do it. |
952 | */ | 948 | */ |
@@ -958,7 +954,7 @@ xfs_dir2_leaf_to_block( | |||
958 | /* | 954 | /* |
959 | * Start converting it to block form. | 955 | * Start converting it to block form. |
960 | */ | 956 | */ |
961 | block->hdr.magic = cpu_to_be32(XFS_DIR2_BLOCK_MAGIC); | 957 | hdr->magic = cpu_to_be32(XFS_DIR2_BLOCK_MAGIC); |
962 | needlog = 1; | 958 | needlog = 1; |
963 | needscan = 0; | 959 | needscan = 0; |
964 | /* | 960 | /* |
@@ -969,7 +965,7 @@ xfs_dir2_leaf_to_block( | |||
969 | /* | 965 | /* |
970 | * Initialize the block tail. | 966 | * Initialize the block tail. |
971 | */ | 967 | */ |
972 | btp = xfs_dir2_block_tail_p(mp, block); | 968 | btp = xfs_dir2_block_tail_p(mp, hdr); |
973 | btp->count = cpu_to_be32(be16_to_cpu(leaf->hdr.count) - be16_to_cpu(leaf->hdr.stale)); | 969 | btp->count = cpu_to_be32(be16_to_cpu(leaf->hdr.count) - be16_to_cpu(leaf->hdr.stale)); |
974 | btp->stale = 0; | 970 | btp->stale = 0; |
975 | xfs_dir2_block_log_tail(tp, dbp); | 971 | xfs_dir2_block_log_tail(tp, dbp); |
@@ -988,7 +984,7 @@ xfs_dir2_leaf_to_block( | |||
988 | * Scan the bestfree if we need it and log the data block header. | 984 | * Scan the bestfree if we need it and log the data block header. |
989 | */ | 985 | */ |
990 | if (needscan) | 986 | if (needscan) |
991 | xfs_dir2_data_freescan(mp, (xfs_dir2_data_t *)block, &needlog); | 987 | xfs_dir2_data_freescan(mp, (xfs_dir2_data_t *)hdr, &needlog); |
992 | if (needlog) | 988 | if (needlog) |
993 | xfs_dir2_data_log_header(tp, dbp); | 989 | xfs_dir2_data_log_header(tp, dbp); |
994 | /* | 990 | /* |
@@ -1002,8 +998,8 @@ xfs_dir2_leaf_to_block( | |||
1002 | /* | 998 | /* |
1003 | * Now see if the resulting block can be shrunken to shortform. | 999 | * Now see if the resulting block can be shrunken to shortform. |
1004 | */ | 1000 | */ |
1005 | if ((size = xfs_dir2_block_sfsize(dp, block, &sfh)) > | 1001 | size = xfs_dir2_block_sfsize(dp, hdr, &sfh); |
1006 | XFS_IFORK_DSIZE(dp)) { | 1002 | if (size > XFS_IFORK_DSIZE(dp)) { |
1007 | error = 0; | 1003 | error = 0; |
1008 | goto out; | 1004 | goto out; |
1009 | } | 1005 | } |
@@ -1025,6 +1021,7 @@ xfs_dir2_sf_to_block( | |||
1025 | { | 1021 | { |
1026 | xfs_dir2_db_t blkno; /* dir-relative block # (0) */ | 1022 | xfs_dir2_db_t blkno; /* dir-relative block # (0) */ |
1027 | xfs_dir2_block_t *block; /* block structure */ | 1023 | xfs_dir2_block_t *block; /* block structure */ |
1024 | xfs_dir2_data_hdr_t *hdr; /* block header */ | ||
1028 | xfs_dir2_leaf_entry_t *blp; /* block leaf entries */ | 1025 | xfs_dir2_leaf_entry_t *blp; /* block leaf entries */ |
1029 | xfs_dabuf_t *bp; /* block buffer */ | 1026 | xfs_dabuf_t *bp; /* block buffer */ |
1030 | xfs_dir2_block_tail_t *btp; /* block tail pointer */ | 1027 | xfs_dir2_block_tail_t *btp; /* block tail pointer */ |
@@ -1095,7 +1092,8 @@ xfs_dir2_sf_to_block( | |||
1095 | return error; | 1092 | return error; |
1096 | } | 1093 | } |
1097 | block = bp->data; | 1094 | block = bp->data; |
1098 | block->hdr.magic = cpu_to_be32(XFS_DIR2_BLOCK_MAGIC); | 1095 | hdr = &block->hdr; |
1096 | hdr->magic = cpu_to_be32(XFS_DIR2_BLOCK_MAGIC); | ||
1099 | /* | 1097 | /* |
1100 | * Compute size of block "tail" area. | 1098 | * Compute size of block "tail" area. |
1101 | */ | 1099 | */ |
@@ -1113,45 +1111,45 @@ xfs_dir2_sf_to_block( | |||
1113 | /* | 1111 | /* |
1114 | * Fill in the tail. | 1112 | * Fill in the tail. |
1115 | */ | 1113 | */ |
1116 | btp = xfs_dir2_block_tail_p(mp, block); | 1114 | btp = xfs_dir2_block_tail_p(mp, hdr); |
1117 | btp->count = cpu_to_be32(sfp->count + 2); /* ., .. */ | 1115 | btp->count = cpu_to_be32(sfp->count + 2); /* ., .. */ |
1118 | btp->stale = 0; | 1116 | btp->stale = 0; |
1119 | blp = xfs_dir2_block_leaf_p(btp); | 1117 | blp = xfs_dir2_block_leaf_p(btp); |
1120 | endoffset = (uint)((char *)blp - (char *)block); | 1118 | endoffset = (uint)((char *)blp - (char *)hdr); |
1121 | /* | 1119 | /* |
1122 | * Remove the freespace, we'll manage it. | 1120 | * Remove the freespace, we'll manage it. |
1123 | */ | 1121 | */ |
1124 | xfs_dir2_data_use_free(tp, bp, dup, | 1122 | xfs_dir2_data_use_free(tp, bp, dup, |
1125 | (xfs_dir2_data_aoff_t)((char *)dup - (char *)block), | 1123 | (xfs_dir2_data_aoff_t)((char *)dup - (char *)hdr), |
1126 | be16_to_cpu(dup->length), &needlog, &needscan); | 1124 | be16_to_cpu(dup->length), &needlog, &needscan); |
1127 | /* | 1125 | /* |
1128 | * Create entry for . | 1126 | * Create entry for . |
1129 | */ | 1127 | */ |
1130 | dep = (xfs_dir2_data_entry_t *) | 1128 | dep = (xfs_dir2_data_entry_t *) |
1131 | ((char *)block + XFS_DIR2_DATA_DOT_OFFSET); | 1129 | ((char *)hdr + XFS_DIR2_DATA_DOT_OFFSET); |
1132 | dep->inumber = cpu_to_be64(dp->i_ino); | 1130 | dep->inumber = cpu_to_be64(dp->i_ino); |
1133 | dep->namelen = 1; | 1131 | dep->namelen = 1; |
1134 | dep->name[0] = '.'; | 1132 | dep->name[0] = '.'; |
1135 | tagp = xfs_dir2_data_entry_tag_p(dep); | 1133 | tagp = xfs_dir2_data_entry_tag_p(dep); |
1136 | *tagp = cpu_to_be16((char *)dep - (char *)block); | 1134 | *tagp = cpu_to_be16((char *)dep - (char *)hdr); |
1137 | xfs_dir2_data_log_entry(tp, bp, dep); | 1135 | xfs_dir2_data_log_entry(tp, bp, dep); |
1138 | blp[0].hashval = cpu_to_be32(xfs_dir_hash_dot); | 1136 | blp[0].hashval = cpu_to_be32(xfs_dir_hash_dot); |
1139 | blp[0].address = cpu_to_be32(xfs_dir2_byte_to_dataptr(mp, | 1137 | blp[0].address = cpu_to_be32(xfs_dir2_byte_to_dataptr(mp, |
1140 | (char *)dep - (char *)block)); | 1138 | (char *)dep - (char *)hdr)); |
1141 | /* | 1139 | /* |
1142 | * Create entry for .. | 1140 | * Create entry for .. |
1143 | */ | 1141 | */ |
1144 | dep = (xfs_dir2_data_entry_t *) | 1142 | dep = (xfs_dir2_data_entry_t *) |
1145 | ((char *)block + XFS_DIR2_DATA_DOTDOT_OFFSET); | 1143 | ((char *)hdr + XFS_DIR2_DATA_DOTDOT_OFFSET); |
1146 | dep->inumber = cpu_to_be64(xfs_dir2_sf_get_parent_ino(sfp)); | 1144 | dep->inumber = cpu_to_be64(xfs_dir2_sf_get_parent_ino(sfp)); |
1147 | dep->namelen = 2; | 1145 | dep->namelen = 2; |
1148 | dep->name[0] = dep->name[1] = '.'; | 1146 | dep->name[0] = dep->name[1] = '.'; |
1149 | tagp = xfs_dir2_data_entry_tag_p(dep); | 1147 | tagp = xfs_dir2_data_entry_tag_p(dep); |
1150 | *tagp = cpu_to_be16((char *)dep - (char *)block); | 1148 | *tagp = cpu_to_be16((char *)dep - (char *)hdr); |
1151 | xfs_dir2_data_log_entry(tp, bp, dep); | 1149 | xfs_dir2_data_log_entry(tp, bp, dep); |
1152 | blp[1].hashval = cpu_to_be32(xfs_dir_hash_dotdot); | 1150 | blp[1].hashval = cpu_to_be32(xfs_dir_hash_dotdot); |
1153 | blp[1].address = cpu_to_be32(xfs_dir2_byte_to_dataptr(mp, | 1151 | blp[1].address = cpu_to_be32(xfs_dir2_byte_to_dataptr(mp, |
1154 | (char *)dep - (char *)block)); | 1152 | (char *)dep - (char *)hdr)); |
1155 | offset = XFS_DIR2_DATA_FIRST_OFFSET; | 1153 | offset = XFS_DIR2_DATA_FIRST_OFFSET; |
1156 | /* | 1154 | /* |
1157 | * Loop over existing entries, stuff them in. | 1155 | * Loop over existing entries, stuff them in. |
@@ -1177,14 +1175,13 @@ xfs_dir2_sf_to_block( | |||
1177 | * There should be a hole here, make one. | 1175 | * There should be a hole here, make one. |
1178 | */ | 1176 | */ |
1179 | if (offset < newoffset) { | 1177 | if (offset < newoffset) { |
1180 | dup = (xfs_dir2_data_unused_t *) | 1178 | dup = (xfs_dir2_data_unused_t *)((char *)hdr + offset); |
1181 | ((char *)block + offset); | ||
1182 | dup->freetag = cpu_to_be16(XFS_DIR2_DATA_FREE_TAG); | 1179 | dup->freetag = cpu_to_be16(XFS_DIR2_DATA_FREE_TAG); |
1183 | dup->length = cpu_to_be16(newoffset - offset); | 1180 | dup->length = cpu_to_be16(newoffset - offset); |
1184 | *xfs_dir2_data_unused_tag_p(dup) = cpu_to_be16( | 1181 | *xfs_dir2_data_unused_tag_p(dup) = cpu_to_be16( |
1185 | ((char *)dup - (char *)block)); | 1182 | ((char *)dup - (char *)hdr)); |
1186 | xfs_dir2_data_log_unused(tp, bp, dup); | 1183 | xfs_dir2_data_log_unused(tp, bp, dup); |
1187 | (void)xfs_dir2_data_freeinsert((xfs_dir2_data_t *)block, | 1184 | (void)xfs_dir2_data_freeinsert((xfs_dir2_data_t *)hdr, |
1188 | dup, &dummy); | 1185 | dup, &dummy); |
1189 | offset += be16_to_cpu(dup->length); | 1186 | offset += be16_to_cpu(dup->length); |
1190 | continue; | 1187 | continue; |
@@ -1192,20 +1189,20 @@ xfs_dir2_sf_to_block( | |||
1192 | /* | 1189 | /* |
1193 | * Copy a real entry. | 1190 | * Copy a real entry. |
1194 | */ | 1191 | */ |
1195 | dep = (xfs_dir2_data_entry_t *)((char *)block + newoffset); | 1192 | dep = (xfs_dir2_data_entry_t *)((char *)hdr + newoffset); |
1196 | dep->inumber = cpu_to_be64(xfs_dir2_sfe_get_ino(sfp, sfep)); | 1193 | dep->inumber = cpu_to_be64(xfs_dir2_sfe_get_ino(sfp, sfep)); |
1197 | dep->namelen = sfep->namelen; | 1194 | dep->namelen = sfep->namelen; |
1198 | memcpy(dep->name, sfep->name, dep->namelen); | 1195 | memcpy(dep->name, sfep->name, dep->namelen); |
1199 | tagp = xfs_dir2_data_entry_tag_p(dep); | 1196 | tagp = xfs_dir2_data_entry_tag_p(dep); |
1200 | *tagp = cpu_to_be16((char *)dep - (char *)block); | 1197 | *tagp = cpu_to_be16((char *)dep - (char *)hdr); |
1201 | xfs_dir2_data_log_entry(tp, bp, dep); | 1198 | xfs_dir2_data_log_entry(tp, bp, dep); |
1202 | name.name = sfep->name; | 1199 | name.name = sfep->name; |
1203 | name.len = sfep->namelen; | 1200 | name.len = sfep->namelen; |
1204 | blp[2 + i].hashval = cpu_to_be32(mp->m_dirnameops-> | 1201 | blp[2 + i].hashval = cpu_to_be32(mp->m_dirnameops-> |
1205 | hashname(&name)); | 1202 | hashname(&name)); |
1206 | blp[2 + i].address = cpu_to_be32(xfs_dir2_byte_to_dataptr(mp, | 1203 | blp[2 + i].address = cpu_to_be32(xfs_dir2_byte_to_dataptr(mp, |
1207 | (char *)dep - (char *)block)); | 1204 | (char *)dep - (char *)hdr)); |
1208 | offset = (int)((char *)(tagp + 1) - (char *)block); | 1205 | offset = (int)((char *)(tagp + 1) - (char *)hdr); |
1209 | if (++i == sfp->count) | 1206 | if (++i == sfp->count) |
1210 | sfep = NULL; | 1207 | sfep = NULL; |
1211 | else | 1208 | else |
diff --git a/fs/xfs/xfs_dir2_block.h b/fs/xfs/xfs_dir2_block.h index 10e689676382..fe91f88f880c 100644 --- a/fs/xfs/xfs_dir2_block.h +++ b/fs/xfs/xfs_dir2_block.h | |||
@@ -61,10 +61,9 @@ typedef struct xfs_dir2_block { | |||
61 | * Pointer to the leaf header embedded in a data block (1-block format) | 61 | * Pointer to the leaf header embedded in a data block (1-block format) |
62 | */ | 62 | */ |
63 | static inline xfs_dir2_block_tail_t * | 63 | static inline xfs_dir2_block_tail_t * |
64 | xfs_dir2_block_tail_p(struct xfs_mount *mp, xfs_dir2_block_t *block) | 64 | xfs_dir2_block_tail_p(struct xfs_mount *mp, xfs_dir2_data_hdr_t *hdr) |
65 | { | 65 | { |
66 | return (((xfs_dir2_block_tail_t *) | 66 | return ((xfs_dir2_block_tail_t *)((char *)hdr + mp->m_dirblksize)) - 1; |
67 | ((char *)(block) + (mp)->m_dirblksize)) - 1); | ||
68 | } | 67 | } |
69 | 68 | ||
70 | /* | 69 | /* |
diff --git a/fs/xfs/xfs_dir2_data.c b/fs/xfs/xfs_dir2_data.c index 921595b84f5b..46ccb83bdab4 100644 --- a/fs/xfs/xfs_dir2_data.c +++ b/fs/xfs/xfs_dir2_data.c | |||
@@ -72,7 +72,7 @@ xfs_dir2_data_check( | |||
72 | bf = d->hdr.bestfree; | 72 | bf = d->hdr.bestfree; |
73 | p = (char *)d->u; | 73 | p = (char *)d->u; |
74 | if (be32_to_cpu(d->hdr.magic) == XFS_DIR2_BLOCK_MAGIC) { | 74 | if (be32_to_cpu(d->hdr.magic) == XFS_DIR2_BLOCK_MAGIC) { |
75 | btp = xfs_dir2_block_tail_p(mp, (xfs_dir2_block_t *)d); | 75 | btp = xfs_dir2_block_tail_p(mp, &d->hdr); |
76 | lep = xfs_dir2_block_leaf_p(btp); | 76 | lep = xfs_dir2_block_leaf_p(btp); |
77 | endp = (char *)lep; | 77 | endp = (char *)lep; |
78 | } else | 78 | } else |
@@ -348,7 +348,7 @@ xfs_dir2_data_freescan( | |||
348 | */ | 348 | */ |
349 | p = (char *)d->u; | 349 | p = (char *)d->u; |
350 | if (be32_to_cpu(d->hdr.magic) == XFS_DIR2_BLOCK_MAGIC) { | 350 | if (be32_to_cpu(d->hdr.magic) == XFS_DIR2_BLOCK_MAGIC) { |
351 | btp = xfs_dir2_block_tail_p(mp, (xfs_dir2_block_t *)d); | 351 | btp = xfs_dir2_block_tail_p(mp, &d->hdr); |
352 | endp = (char *)xfs_dir2_block_leaf_p(btp); | 352 | endp = (char *)xfs_dir2_block_leaf_p(btp); |
353 | } else | 353 | } else |
354 | endp = (char *)d + mp->m_dirblksize; | 354 | endp = (char *)d + mp->m_dirblksize; |
@@ -537,7 +537,7 @@ xfs_dir2_data_make_free( | |||
537 | xfs_dir2_block_tail_t *btp; /* block tail */ | 537 | xfs_dir2_block_tail_t *btp; /* block tail */ |
538 | 538 | ||
539 | ASSERT(be32_to_cpu(d->hdr.magic) == XFS_DIR2_BLOCK_MAGIC); | 539 | ASSERT(be32_to_cpu(d->hdr.magic) == XFS_DIR2_BLOCK_MAGIC); |
540 | btp = xfs_dir2_block_tail_p(mp, (xfs_dir2_block_t *)d); | 540 | btp = xfs_dir2_block_tail_p(mp, &d->hdr); |
541 | endptr = (char *)xfs_dir2_block_leaf_p(btp); | 541 | endptr = (char *)xfs_dir2_block_leaf_p(btp); |
542 | } | 542 | } |
543 | /* | 543 | /* |
diff --git a/fs/xfs/xfs_dir2_leaf.c b/fs/xfs/xfs_dir2_leaf.c index 7f7769ea2be8..1b048dad360f 100644 --- a/fs/xfs/xfs_dir2_leaf.c +++ b/fs/xfs/xfs_dir2_leaf.c | |||
@@ -64,7 +64,7 @@ xfs_dir2_block_to_leaf( | |||
64 | { | 64 | { |
65 | __be16 *bestsp; /* leaf's bestsp entries */ | 65 | __be16 *bestsp; /* leaf's bestsp entries */ |
66 | xfs_dablk_t blkno; /* leaf block's bno */ | 66 | xfs_dablk_t blkno; /* leaf block's bno */ |
67 | xfs_dir2_block_t *block; /* block structure */ | 67 | xfs_dir2_data_hdr_t *hdr; /* block header */ |
68 | xfs_dir2_leaf_entry_t *blp; /* block's leaf entries */ | 68 | xfs_dir2_leaf_entry_t *blp; /* block's leaf entries */ |
69 | xfs_dir2_block_tail_t *btp; /* block's tail */ | 69 | xfs_dir2_block_tail_t *btp; /* block's tail */ |
70 | xfs_inode_t *dp; /* incore directory inode */ | 70 | xfs_inode_t *dp; /* incore directory inode */ |
@@ -101,9 +101,9 @@ xfs_dir2_block_to_leaf( | |||
101 | } | 101 | } |
102 | ASSERT(lbp != NULL); | 102 | ASSERT(lbp != NULL); |
103 | leaf = lbp->data; | 103 | leaf = lbp->data; |
104 | block = dbp->data; | 104 | hdr = dbp->data; |
105 | xfs_dir2_data_check(dp, dbp); | 105 | xfs_dir2_data_check(dp, dbp); |
106 | btp = xfs_dir2_block_tail_p(mp, block); | 106 | btp = xfs_dir2_block_tail_p(mp, hdr); |
107 | blp = xfs_dir2_block_leaf_p(btp); | 107 | blp = xfs_dir2_block_leaf_p(btp); |
108 | /* | 108 | /* |
109 | * Set the counts in the leaf header. | 109 | * Set the counts in the leaf header. |
@@ -123,23 +123,23 @@ xfs_dir2_block_to_leaf( | |||
123 | * tail be free. | 123 | * tail be free. |
124 | */ | 124 | */ |
125 | xfs_dir2_data_make_free(tp, dbp, | 125 | xfs_dir2_data_make_free(tp, dbp, |
126 | (xfs_dir2_data_aoff_t)((char *)blp - (char *)block), | 126 | (xfs_dir2_data_aoff_t)((char *)blp - (char *)hdr), |
127 | (xfs_dir2_data_aoff_t)((char *)block + mp->m_dirblksize - | 127 | (xfs_dir2_data_aoff_t)((char *)hdr + mp->m_dirblksize - |
128 | (char *)blp), | 128 | (char *)blp), |
129 | &needlog, &needscan); | 129 | &needlog, &needscan); |
130 | /* | 130 | /* |
131 | * Fix up the block header, make it a data block. | 131 | * Fix up the block header, make it a data block. |
132 | */ | 132 | */ |
133 | block->hdr.magic = cpu_to_be32(XFS_DIR2_DATA_MAGIC); | 133 | hdr->magic = cpu_to_be32(XFS_DIR2_DATA_MAGIC); |
134 | if (needscan) | 134 | if (needscan) |
135 | xfs_dir2_data_freescan(mp, (xfs_dir2_data_t *)block, &needlog); | 135 | xfs_dir2_data_freescan(mp, (xfs_dir2_data_t *)hdr, &needlog); |
136 | /* | 136 | /* |
137 | * Set up leaf tail and bests table. | 137 | * Set up leaf tail and bests table. |
138 | */ | 138 | */ |
139 | ltp = xfs_dir2_leaf_tail_p(mp, leaf); | 139 | ltp = xfs_dir2_leaf_tail_p(mp, leaf); |
140 | ltp->bestcount = cpu_to_be32(1); | 140 | ltp->bestcount = cpu_to_be32(1); |
141 | bestsp = xfs_dir2_leaf_bests_p(ltp); | 141 | bestsp = xfs_dir2_leaf_bests_p(ltp); |
142 | bestsp[0] = block->hdr.bestfree[0].length; | 142 | bestsp[0] = hdr->bestfree[0].length; |
143 | /* | 143 | /* |
144 | * Log the data header and leaf bests table. | 144 | * Log the data header and leaf bests table. |
145 | */ | 145 | */ |
diff --git a/fs/xfs/xfs_dir2_sf.c b/fs/xfs/xfs_dir2_sf.c index 3a1e3f4e3fa3..515efa5d29ca 100644 --- a/fs/xfs/xfs_dir2_sf.c +++ b/fs/xfs/xfs_dir2_sf.c | |||
@@ -141,7 +141,7 @@ xfs_dir2_sfe_put_ino( | |||
141 | int /* size for sf form */ | 141 | int /* size for sf form */ |
142 | xfs_dir2_block_sfsize( | 142 | xfs_dir2_block_sfsize( |
143 | xfs_inode_t *dp, /* incore inode pointer */ | 143 | xfs_inode_t *dp, /* incore inode pointer */ |
144 | xfs_dir2_block_t *block, /* block directory data */ | 144 | xfs_dir2_data_hdr_t *hdr, /* block directory data */ |
145 | xfs_dir2_sf_hdr_t *sfhp) /* output: header for sf form */ | 145 | xfs_dir2_sf_hdr_t *sfhp) /* output: header for sf form */ |
146 | { | 146 | { |
147 | xfs_dir2_dataptr_t addr; /* data entry address */ | 147 | xfs_dir2_dataptr_t addr; /* data entry address */ |
@@ -161,7 +161,7 @@ xfs_dir2_block_sfsize( | |||
161 | mp = dp->i_mount; | 161 | mp = dp->i_mount; |
162 | 162 | ||
163 | count = i8count = namelen = 0; | 163 | count = i8count = namelen = 0; |
164 | btp = xfs_dir2_block_tail_p(mp, block); | 164 | btp = xfs_dir2_block_tail_p(mp, hdr); |
165 | blp = xfs_dir2_block_leaf_p(btp); | 165 | blp = xfs_dir2_block_leaf_p(btp); |
166 | 166 | ||
167 | /* | 167 | /* |
@@ -174,7 +174,7 @@ xfs_dir2_block_sfsize( | |||
174 | * Calculate the pointer to the entry at hand. | 174 | * Calculate the pointer to the entry at hand. |
175 | */ | 175 | */ |
176 | dep = (xfs_dir2_data_entry_t *) | 176 | dep = (xfs_dir2_data_entry_t *) |
177 | ((char *)block + xfs_dir2_dataptr_to_off(mp, addr)); | 177 | ((char *)hdr + xfs_dir2_dataptr_to_off(mp, addr)); |
178 | /* | 178 | /* |
179 | * Detect . and .., so we can special-case them. | 179 | * Detect . and .., so we can special-case them. |
180 | * . is not included in sf directories. | 180 | * . is not included in sf directories. |
@@ -255,6 +255,7 @@ xfs_dir2_block_to_sf( | |||
255 | ASSERT(error != ENOSPC); | 255 | ASSERT(error != ENOSPC); |
256 | goto out; | 256 | goto out; |
257 | } | 257 | } |
258 | |||
258 | /* | 259 | /* |
259 | * The buffer is now unconditionally gone, whether | 260 | * The buffer is now unconditionally gone, whether |
260 | * xfs_dir2_shrink_inode worked or not. | 261 | * xfs_dir2_shrink_inode worked or not. |
@@ -276,7 +277,7 @@ xfs_dir2_block_to_sf( | |||
276 | /* | 277 | /* |
277 | * Set up to loop over the block's entries. | 278 | * Set up to loop over the block's entries. |
278 | */ | 279 | */ |
279 | btp = xfs_dir2_block_tail_p(mp, block); | 280 | btp = xfs_dir2_block_tail_p(mp, &block->hdr); |
280 | ptr = (char *)block->u; | 281 | ptr = (char *)block->u; |
281 | endptr = (char *)xfs_dir2_block_leaf_p(btp); | 282 | endptr = (char *)xfs_dir2_block_leaf_p(btp); |
282 | sfep = xfs_dir2_sf_firstentry(sfp); | 283 | sfep = xfs_dir2_sf_firstentry(sfp); |
diff --git a/fs/xfs/xfs_dir2_sf.h b/fs/xfs/xfs_dir2_sf.h index 55560bc80ec0..65c5763905c9 100644 --- a/fs/xfs/xfs_dir2_sf.h +++ b/fs/xfs/xfs_dir2_sf.h | |||
@@ -32,7 +32,7 @@ | |||
32 | struct uio; | 32 | struct uio; |
33 | struct xfs_dabuf; | 33 | struct xfs_dabuf; |
34 | struct xfs_da_args; | 34 | struct xfs_da_args; |
35 | struct xfs_dir2_block; | 35 | struct xfs_dir2_data_hdr; |
36 | struct xfs_inode; | 36 | struct xfs_inode; |
37 | struct xfs_mount; | 37 | struct xfs_mount; |
38 | struct xfs_trans; | 38 | struct xfs_trans; |
@@ -136,7 +136,7 @@ extern xfs_ino_t xfs_dir2_sf_get_parent_ino(struct xfs_dir2_sf_hdr *sfp); | |||
136 | extern xfs_ino_t xfs_dir2_sfe_get_ino(struct xfs_dir2_sf_hdr *sfp, | 136 | extern xfs_ino_t xfs_dir2_sfe_get_ino(struct xfs_dir2_sf_hdr *sfp, |
137 | struct xfs_dir2_sf_entry *sfep); | 137 | struct xfs_dir2_sf_entry *sfep); |
138 | extern int xfs_dir2_block_sfsize(struct xfs_inode *dp, | 138 | extern int xfs_dir2_block_sfsize(struct xfs_inode *dp, |
139 | struct xfs_dir2_block *block, | 139 | struct xfs_dir2_data_hdr *block, |
140 | xfs_dir2_sf_hdr_t *sfhp); | 140 | xfs_dir2_sf_hdr_t *sfhp); |
141 | extern int xfs_dir2_block_to_sf(struct xfs_da_args *args, struct xfs_dabuf *bp, | 141 | extern int xfs_dir2_block_to_sf(struct xfs_da_args *args, struct xfs_dabuf *bp, |
142 | int size, xfs_dir2_sf_hdr_t *sfhp); | 142 | int size, xfs_dir2_sf_hdr_t *sfhp); |