aboutsummaryrefslogtreecommitdiffstats
path: root/fs/xfs/xfs_dir2_block.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/xfs/xfs_dir2_block.c')
-rw-r--r--fs/xfs/xfs_dir2_block.c118
1 files changed, 51 insertions, 67 deletions
diff --git a/fs/xfs/xfs_dir2_block.c b/fs/xfs/xfs_dir2_block.c
index 586732f2d80d..e93ca8f054f4 100644
--- a/fs/xfs/xfs_dir2_block.c
+++ b/fs/xfs/xfs_dir2_block.c
@@ -37,10 +37,10 @@
37/* 37/*
38 * Local function prototypes. 38 * Local function prototypes.
39 */ 39 */
40static void xfs_dir2_block_log_leaf(xfs_trans_t *tp, xfs_dabuf_t *bp, int first, 40static void xfs_dir2_block_log_leaf(xfs_trans_t *tp, struct xfs_buf *bp,
41 int last); 41 int first, int last);
42static void xfs_dir2_block_log_tail(xfs_trans_t *tp, xfs_dabuf_t *bp); 42static void xfs_dir2_block_log_tail(xfs_trans_t *tp, struct xfs_buf *bp);
43static int xfs_dir2_block_lookup_int(xfs_da_args_t *args, xfs_dabuf_t **bpp, 43static int xfs_dir2_block_lookup_int(xfs_da_args_t *args, struct xfs_buf **bpp,
44 int *entno); 44 int *entno);
45static int xfs_dir2_block_sort(const void *a, const void *b); 45static int xfs_dir2_block_sort(const void *a, const void *b);
46 46
@@ -66,7 +66,7 @@ xfs_dir2_block_addname(
66 xfs_dir2_data_free_t *bf; /* bestfree table in block */ 66 xfs_dir2_data_free_t *bf; /* bestfree table in block */
67 xfs_dir2_data_hdr_t *hdr; /* block header */ 67 xfs_dir2_data_hdr_t *hdr; /* block header */
68 xfs_dir2_leaf_entry_t *blp; /* block leaf entries */ 68 xfs_dir2_leaf_entry_t *blp; /* block leaf entries */
69 xfs_dabuf_t *bp; /* buffer for block */ 69 struct xfs_buf *bp; /* buffer for block */
70 xfs_dir2_block_tail_t *btp; /* block tail */ 70 xfs_dir2_block_tail_t *btp; /* block tail */
71 int compact; /* need to compact leaf ents */ 71 int compact; /* need to compact leaf ents */
72 xfs_dir2_data_entry_t *dep; /* block data entry */ 72 xfs_dir2_data_entry_t *dep; /* block data entry */
@@ -102,14 +102,14 @@ xfs_dir2_block_addname(
102 return error; 102 return error;
103 } 103 }
104 ASSERT(bp != NULL); 104 ASSERT(bp != NULL);
105 hdr = bp->data; 105 hdr = bp->b_addr;
106 /* 106 /*
107 * Check the magic number, corrupted if wrong. 107 * Check the magic number, corrupted if wrong.
108 */ 108 */
109 if (unlikely(hdr->magic != cpu_to_be32(XFS_DIR2_BLOCK_MAGIC))) { 109 if (unlikely(hdr->magic != cpu_to_be32(XFS_DIR2_BLOCK_MAGIC))) {
110 XFS_CORRUPTION_ERROR("xfs_dir2_block_addname", 110 XFS_CORRUPTION_ERROR("xfs_dir2_block_addname",
111 XFS_ERRLEVEL_LOW, mp, hdr); 111 XFS_ERRLEVEL_LOW, mp, hdr);
112 xfs_da_brelse(tp, bp); 112 xfs_trans_brelse(tp, bp);
113 return XFS_ERROR(EFSCORRUPTED); 113 return XFS_ERROR(EFSCORRUPTED);
114 } 114 }
115 len = xfs_dir2_data_entsize(args->namelen); 115 len = xfs_dir2_data_entsize(args->namelen);
@@ -212,7 +212,7 @@ xfs_dir2_block_addname(
212 * If this isn't a real add, we're done with the buffer. 212 * If this isn't a real add, we're done with the buffer.
213 */ 213 */
214 if (args->op_flags & XFS_DA_OP_JUSTCHECK) 214 if (args->op_flags & XFS_DA_OP_JUSTCHECK)
215 xfs_da_brelse(tp, bp); 215 xfs_trans_brelse(tp, bp);
216 /* 216 /*
217 * If we don't have space for the new entry & leaf ... 217 * If we don't have space for the new entry & leaf ...
218 */ 218 */
@@ -228,7 +228,6 @@ xfs_dir2_block_addname(
228 * Then add the new entry in that format. 228 * Then add the new entry in that format.
229 */ 229 */
230 error = xfs_dir2_block_to_leaf(args, bp); 230 error = xfs_dir2_block_to_leaf(args, bp);
231 xfs_da_buf_done(bp);
232 if (error) 231 if (error)
233 return error; 232 return error;
234 return xfs_dir2_leaf_addname(args); 233 return xfs_dir2_leaf_addname(args);
@@ -422,7 +421,6 @@ xfs_dir2_block_addname(
422 xfs_dir2_block_log_tail(tp, bp); 421 xfs_dir2_block_log_tail(tp, bp);
423 xfs_dir2_data_log_entry(tp, bp, dep); 422 xfs_dir2_data_log_entry(tp, bp, dep);
424 xfs_dir2_data_check(dp, bp); 423 xfs_dir2_data_check(dp, bp);
425 xfs_da_buf_done(bp);
426 return 0; 424 return 0;
427} 425}
428 426
@@ -437,7 +435,7 @@ xfs_dir2_block_getdents(
437 filldir_t filldir) 435 filldir_t filldir)
438{ 436{
439 xfs_dir2_data_hdr_t *hdr; /* block header */ 437 xfs_dir2_data_hdr_t *hdr; /* block header */
440 xfs_dabuf_t *bp; /* buffer for block */ 438 struct xfs_buf *bp; /* buffer for block */
441 xfs_dir2_block_tail_t *btp; /* block tail */ 439 xfs_dir2_block_tail_t *btp; /* block tail */
442 xfs_dir2_data_entry_t *dep; /* block data entry */ 440 xfs_dir2_data_entry_t *dep; /* block data entry */
443 xfs_dir2_data_unused_t *dup; /* block unused entry */ 441 xfs_dir2_data_unused_t *dup; /* block unused entry */
@@ -469,7 +467,7 @@ xfs_dir2_block_getdents(
469 * We'll skip entries before this. 467 * We'll skip entries before this.
470 */ 468 */
471 wantoff = xfs_dir2_dataptr_to_off(mp, *offset); 469 wantoff = xfs_dir2_dataptr_to_off(mp, *offset);
472 hdr = bp->data; 470 hdr = bp->b_addr;
473 xfs_dir2_data_check(dp, bp); 471 xfs_dir2_data_check(dp, bp);
474 /* 472 /*
475 * Set up values for the loop. 473 * Set up values for the loop.
@@ -514,7 +512,7 @@ xfs_dir2_block_getdents(
514 cook & 0x7fffffff, be64_to_cpu(dep->inumber), 512 cook & 0x7fffffff, be64_to_cpu(dep->inumber),
515 DT_UNKNOWN)) { 513 DT_UNKNOWN)) {
516 *offset = cook & 0x7fffffff; 514 *offset = cook & 0x7fffffff;
517 xfs_da_brelse(NULL, bp); 515 xfs_trans_brelse(NULL, bp);
518 return 0; 516 return 0;
519 } 517 }
520 } 518 }
@@ -525,7 +523,7 @@ xfs_dir2_block_getdents(
525 */ 523 */
526 *offset = xfs_dir2_db_off_to_dataptr(mp, mp->m_dirdatablk + 1, 0) & 524 *offset = xfs_dir2_db_off_to_dataptr(mp, mp->m_dirdatablk + 1, 0) &
527 0x7fffffff; 525 0x7fffffff;
528 xfs_da_brelse(NULL, bp); 526 xfs_trans_brelse(NULL, bp);
529 return 0; 527 return 0;
530} 528}
531 529
@@ -535,17 +533,17 @@ xfs_dir2_block_getdents(
535static void 533static void
536xfs_dir2_block_log_leaf( 534xfs_dir2_block_log_leaf(
537 xfs_trans_t *tp, /* transaction structure */ 535 xfs_trans_t *tp, /* transaction structure */
538 xfs_dabuf_t *bp, /* block buffer */ 536 struct xfs_buf *bp, /* block buffer */
539 int first, /* index of first logged leaf */ 537 int first, /* index of first logged leaf */
540 int last) /* index of last logged leaf */ 538 int last) /* index of last logged leaf */
541{ 539{
542 xfs_dir2_data_hdr_t *hdr = bp->data; 540 xfs_dir2_data_hdr_t *hdr = bp->b_addr;
543 xfs_dir2_leaf_entry_t *blp; 541 xfs_dir2_leaf_entry_t *blp;
544 xfs_dir2_block_tail_t *btp; 542 xfs_dir2_block_tail_t *btp;
545 543
546 btp = xfs_dir2_block_tail_p(tp->t_mountp, hdr); 544 btp = xfs_dir2_block_tail_p(tp->t_mountp, hdr);
547 blp = xfs_dir2_block_leaf_p(btp); 545 blp = xfs_dir2_block_leaf_p(btp);
548 xfs_da_log_buf(tp, bp, (uint)((char *)&blp[first] - (char *)hdr), 546 xfs_trans_log_buf(tp, bp, (uint)((char *)&blp[first] - (char *)hdr),
549 (uint)((char *)&blp[last + 1] - (char *)hdr - 1)); 547 (uint)((char *)&blp[last + 1] - (char *)hdr - 1));
550} 548}
551 549
@@ -555,13 +553,13 @@ xfs_dir2_block_log_leaf(
555static void 553static void
556xfs_dir2_block_log_tail( 554xfs_dir2_block_log_tail(
557 xfs_trans_t *tp, /* transaction structure */ 555 xfs_trans_t *tp, /* transaction structure */
558 xfs_dabuf_t *bp) /* block buffer */ 556 struct xfs_buf *bp) /* block buffer */
559{ 557{
560 xfs_dir2_data_hdr_t *hdr = bp->data; 558 xfs_dir2_data_hdr_t *hdr = bp->b_addr;
561 xfs_dir2_block_tail_t *btp; 559 xfs_dir2_block_tail_t *btp;
562 560
563 btp = xfs_dir2_block_tail_p(tp->t_mountp, hdr); 561 btp = xfs_dir2_block_tail_p(tp->t_mountp, hdr);
564 xfs_da_log_buf(tp, bp, (uint)((char *)btp - (char *)hdr), 562 xfs_trans_log_buf(tp, bp, (uint)((char *)btp - (char *)hdr),
565 (uint)((char *)(btp + 1) - (char *)hdr - 1)); 563 (uint)((char *)(btp + 1) - (char *)hdr - 1));
566} 564}
567 565
@@ -575,7 +573,7 @@ xfs_dir2_block_lookup(
575{ 573{
576 xfs_dir2_data_hdr_t *hdr; /* block header */ 574 xfs_dir2_data_hdr_t *hdr; /* block header */
577 xfs_dir2_leaf_entry_t *blp; /* block leaf entries */ 575 xfs_dir2_leaf_entry_t *blp; /* block leaf entries */
578 xfs_dabuf_t *bp; /* block buffer */ 576 struct xfs_buf *bp; /* block buffer */
579 xfs_dir2_block_tail_t *btp; /* block tail */ 577 xfs_dir2_block_tail_t *btp; /* block tail */
580 xfs_dir2_data_entry_t *dep; /* block data entry */ 578 xfs_dir2_data_entry_t *dep; /* block data entry */
581 xfs_inode_t *dp; /* incore inode */ 579 xfs_inode_t *dp; /* incore inode */
@@ -593,7 +591,7 @@ xfs_dir2_block_lookup(
593 return error; 591 return error;
594 dp = args->dp; 592 dp = args->dp;
595 mp = dp->i_mount; 593 mp = dp->i_mount;
596 hdr = bp->data; 594 hdr = bp->b_addr;
597 xfs_dir2_data_check(dp, bp); 595 xfs_dir2_data_check(dp, bp);
598 btp = xfs_dir2_block_tail_p(mp, hdr); 596 btp = xfs_dir2_block_tail_p(mp, hdr);
599 blp = xfs_dir2_block_leaf_p(btp); 597 blp = xfs_dir2_block_leaf_p(btp);
@@ -607,7 +605,7 @@ xfs_dir2_block_lookup(
607 */ 605 */
608 args->inumber = be64_to_cpu(dep->inumber); 606 args->inumber = be64_to_cpu(dep->inumber);
609 error = xfs_dir_cilookup_result(args, dep->name, dep->namelen); 607 error = xfs_dir_cilookup_result(args, dep->name, dep->namelen);
610 xfs_da_brelse(args->trans, bp); 608 xfs_trans_brelse(args->trans, bp);
611 return XFS_ERROR(error); 609 return XFS_ERROR(error);
612} 610}
613 611
@@ -617,13 +615,13 @@ xfs_dir2_block_lookup(
617static int /* error */ 615static int /* error */
618xfs_dir2_block_lookup_int( 616xfs_dir2_block_lookup_int(
619 xfs_da_args_t *args, /* dir lookup arguments */ 617 xfs_da_args_t *args, /* dir lookup arguments */
620 xfs_dabuf_t **bpp, /* returned block buffer */ 618 struct xfs_buf **bpp, /* returned block buffer */
621 int *entno) /* returned entry number */ 619 int *entno) /* returned entry number */
622{ 620{
623 xfs_dir2_dataptr_t addr; /* data entry address */ 621 xfs_dir2_dataptr_t addr; /* data entry address */
624 xfs_dir2_data_hdr_t *hdr; /* block header */ 622 xfs_dir2_data_hdr_t *hdr; /* block header */
625 xfs_dir2_leaf_entry_t *blp; /* block leaf entries */ 623 xfs_dir2_leaf_entry_t *blp; /* block leaf entries */
626 xfs_dabuf_t *bp; /* block buffer */ 624 struct xfs_buf *bp; /* block buffer */
627 xfs_dir2_block_tail_t *btp; /* block tail */ 625 xfs_dir2_block_tail_t *btp; /* block tail */
628 xfs_dir2_data_entry_t *dep; /* block data entry */ 626 xfs_dir2_data_entry_t *dep; /* block data entry */
629 xfs_inode_t *dp; /* incore inode */ 627 xfs_inode_t *dp; /* incore inode */
@@ -647,7 +645,7 @@ xfs_dir2_block_lookup_int(
647 return error; 645 return error;
648 } 646 }
649 ASSERT(bp != NULL); 647 ASSERT(bp != NULL);
650 hdr = bp->data; 648 hdr = bp->b_addr;
651 xfs_dir2_data_check(dp, bp); 649 xfs_dir2_data_check(dp, bp);
652 btp = xfs_dir2_block_tail_p(mp, hdr); 650 btp = xfs_dir2_block_tail_p(mp, hdr);
653 blp = xfs_dir2_block_leaf_p(btp); 651 blp = xfs_dir2_block_leaf_p(btp);
@@ -666,7 +664,7 @@ xfs_dir2_block_lookup_int(
666 high = mid - 1; 664 high = mid - 1;
667 if (low > high) { 665 if (low > high) {
668 ASSERT(args->op_flags & XFS_DA_OP_OKNOENT); 666 ASSERT(args->op_flags & XFS_DA_OP_OKNOENT);
669 xfs_da_brelse(tp, bp); 667 xfs_trans_brelse(tp, bp);
670 return XFS_ERROR(ENOENT); 668 return XFS_ERROR(ENOENT);
671 } 669 }
672 } 670 }
@@ -714,7 +712,7 @@ xfs_dir2_block_lookup_int(
714 /* 712 /*
715 * No match, release the buffer and return ENOENT. 713 * No match, release the buffer and return ENOENT.
716 */ 714 */
717 xfs_da_brelse(tp, bp); 715 xfs_trans_brelse(tp, bp);
718 return XFS_ERROR(ENOENT); 716 return XFS_ERROR(ENOENT);
719} 717}
720 718
@@ -728,7 +726,7 @@ xfs_dir2_block_removename(
728{ 726{
729 xfs_dir2_data_hdr_t *hdr; /* block header */ 727 xfs_dir2_data_hdr_t *hdr; /* block header */
730 xfs_dir2_leaf_entry_t *blp; /* block leaf pointer */ 728 xfs_dir2_leaf_entry_t *blp; /* block leaf pointer */
731 xfs_dabuf_t *bp; /* block buffer */ 729 struct xfs_buf *bp; /* block buffer */
732 xfs_dir2_block_tail_t *btp; /* block tail */ 730 xfs_dir2_block_tail_t *btp; /* block tail */
733 xfs_dir2_data_entry_t *dep; /* block data entry */ 731 xfs_dir2_data_entry_t *dep; /* block data entry */
734 xfs_inode_t *dp; /* incore inode */ 732 xfs_inode_t *dp; /* incore inode */
@@ -753,7 +751,7 @@ xfs_dir2_block_removename(
753 dp = args->dp; 751 dp = args->dp;
754 tp = args->trans; 752 tp = args->trans;
755 mp = dp->i_mount; 753 mp = dp->i_mount;
756 hdr = bp->data; 754 hdr = bp->b_addr;
757 btp = xfs_dir2_block_tail_p(mp, hdr); 755 btp = xfs_dir2_block_tail_p(mp, hdr);
758 blp = xfs_dir2_block_leaf_p(btp); 756 blp = xfs_dir2_block_leaf_p(btp);
759 /* 757 /*
@@ -790,10 +788,9 @@ xfs_dir2_block_removename(
790 * See if the size as a shortform is good enough. 788 * See if the size as a shortform is good enough.
791 */ 789 */
792 size = xfs_dir2_block_sfsize(dp, hdr, &sfh); 790 size = xfs_dir2_block_sfsize(dp, hdr, &sfh);
793 if (size > XFS_IFORK_DSIZE(dp)) { 791 if (size > XFS_IFORK_DSIZE(dp))
794 xfs_da_buf_done(bp);
795 return 0; 792 return 0;
796 } 793
797 /* 794 /*
798 * If it works, do the conversion. 795 * If it works, do the conversion.
799 */ 796 */
@@ -810,7 +807,7 @@ xfs_dir2_block_replace(
810{ 807{
811 xfs_dir2_data_hdr_t *hdr; /* block header */ 808 xfs_dir2_data_hdr_t *hdr; /* block header */
812 xfs_dir2_leaf_entry_t *blp; /* block leaf entries */ 809 xfs_dir2_leaf_entry_t *blp; /* block leaf entries */
813 xfs_dabuf_t *bp; /* block buffer */ 810 struct xfs_buf *bp; /* block buffer */
814 xfs_dir2_block_tail_t *btp; /* block tail */ 811 xfs_dir2_block_tail_t *btp; /* block tail */
815 xfs_dir2_data_entry_t *dep; /* block data entry */ 812 xfs_dir2_data_entry_t *dep; /* block data entry */
816 xfs_inode_t *dp; /* incore inode */ 813 xfs_inode_t *dp; /* incore inode */
@@ -829,7 +826,7 @@ xfs_dir2_block_replace(
829 } 826 }
830 dp = args->dp; 827 dp = args->dp;
831 mp = dp->i_mount; 828 mp = dp->i_mount;
832 hdr = bp->data; 829 hdr = bp->b_addr;
833 btp = xfs_dir2_block_tail_p(mp, hdr); 830 btp = xfs_dir2_block_tail_p(mp, hdr);
834 blp = xfs_dir2_block_leaf_p(btp); 831 blp = xfs_dir2_block_leaf_p(btp);
835 /* 832 /*
@@ -844,7 +841,6 @@ xfs_dir2_block_replace(
844 dep->inumber = cpu_to_be64(args->inumber); 841 dep->inumber = cpu_to_be64(args->inumber);
845 xfs_dir2_data_log_entry(args->trans, bp, dep); 842 xfs_dir2_data_log_entry(args->trans, bp, dep);
846 xfs_dir2_data_check(dp, bp); 843 xfs_dir2_data_check(dp, bp);
847 xfs_da_buf_done(bp);
848 return 0; 844 return 0;
849} 845}
850 846
@@ -871,8 +867,8 @@ xfs_dir2_block_sort(
871int /* error */ 867int /* error */
872xfs_dir2_leaf_to_block( 868xfs_dir2_leaf_to_block(
873 xfs_da_args_t *args, /* operation arguments */ 869 xfs_da_args_t *args, /* operation arguments */
874 xfs_dabuf_t *lbp, /* leaf buffer */ 870 struct xfs_buf *lbp, /* leaf buffer */
875 xfs_dabuf_t *dbp) /* data buffer */ 871 struct xfs_buf *dbp) /* data buffer */
876{ 872{
877 __be16 *bestsp; /* leaf bests table */ 873 __be16 *bestsp; /* leaf bests table */
878 xfs_dir2_data_hdr_t *hdr; /* block header */ 874 xfs_dir2_data_hdr_t *hdr; /* block header */
@@ -898,7 +894,7 @@ xfs_dir2_leaf_to_block(
898 dp = args->dp; 894 dp = args->dp;
899 tp = args->trans; 895 tp = args->trans;
900 mp = dp->i_mount; 896 mp = dp->i_mount;
901 leaf = lbp->data; 897 leaf = lbp->b_addr;
902 ASSERT(leaf->hdr.info.magic == cpu_to_be16(XFS_DIR2_LEAF1_MAGIC)); 898 ASSERT(leaf->hdr.info.magic == cpu_to_be16(XFS_DIR2_LEAF1_MAGIC));
903 ltp = xfs_dir2_leaf_tail_p(mp, leaf); 899 ltp = xfs_dir2_leaf_tail_p(mp, leaf);
904 /* 900 /*
@@ -914,11 +910,9 @@ xfs_dir2_leaf_to_block(
914 if ((error = 910 if ((error =
915 xfs_dir2_leaf_trim_data(args, lbp, 911 xfs_dir2_leaf_trim_data(args, lbp,
916 (xfs_dir2_db_t)(be32_to_cpu(ltp->bestcount) - 1)))) 912 (xfs_dir2_db_t)(be32_to_cpu(ltp->bestcount) - 1))))
917 goto out; 913 return error;
918 } else { 914 } else
919 error = 0; 915 return 0;
920 goto out;
921 }
922 } 916 }
923 /* 917 /*
924 * Read the data block if we don't already have it, give up if it fails. 918 * Read the data block if we don't already have it, give up if it fails.
@@ -926,9 +920,9 @@ xfs_dir2_leaf_to_block(
926 if (dbp == NULL && 920 if (dbp == NULL &&
927 (error = xfs_da_read_buf(tp, dp, mp->m_dirdatablk, -1, &dbp, 921 (error = xfs_da_read_buf(tp, dp, mp->m_dirdatablk, -1, &dbp,
928 XFS_DATA_FORK))) { 922 XFS_DATA_FORK))) {
929 goto out; 923 return error;
930 } 924 }
931 hdr = dbp->data; 925 hdr = dbp->b_addr;
932 ASSERT(hdr->magic == cpu_to_be32(XFS_DIR2_DATA_MAGIC)); 926 ASSERT(hdr->magic == cpu_to_be32(XFS_DIR2_DATA_MAGIC));
933 /* 927 /*
934 * Size of the "leaf" area in the block. 928 * Size of the "leaf" area in the block.
@@ -944,10 +938,9 @@ xfs_dir2_leaf_to_block(
944 * If it's not free or is too short we can't do it. 938 * If it's not free or is too short we can't do it.
945 */ 939 */
946 if (be16_to_cpu(dup->freetag) != XFS_DIR2_DATA_FREE_TAG || 940 if (be16_to_cpu(dup->freetag) != XFS_DIR2_DATA_FREE_TAG ||
947 be16_to_cpu(dup->length) < size) { 941 be16_to_cpu(dup->length) < size)
948 error = 0; 942 return 0;
949 goto out; 943
950 }
951 /* 944 /*
952 * Start converting it to block form. 945 * Start converting it to block form.
953 */ 946 */
@@ -989,25 +982,17 @@ xfs_dir2_leaf_to_block(
989 * Pitch the old leaf block. 982 * Pitch the old leaf block.
990 */ 983 */
991 error = xfs_da_shrink_inode(args, mp->m_dirleafblk, lbp); 984 error = xfs_da_shrink_inode(args, mp->m_dirleafblk, lbp);
992 lbp = NULL; 985 if (error)
993 if (error) { 986 return error;
994 goto out; 987
995 }
996 /* 988 /*
997 * Now see if the resulting block can be shrunken to shortform. 989 * Now see if the resulting block can be shrunken to shortform.
998 */ 990 */
999 size = xfs_dir2_block_sfsize(dp, hdr, &sfh); 991 size = xfs_dir2_block_sfsize(dp, hdr, &sfh);
1000 if (size > XFS_IFORK_DSIZE(dp)) { 992 if (size > XFS_IFORK_DSIZE(dp))
1001 error = 0; 993 return 0;
1002 goto out; 994
1003 }
1004 return xfs_dir2_block_to_sf(args, dbp, size, &sfh); 995 return xfs_dir2_block_to_sf(args, dbp, size, &sfh);
1005out:
1006 if (lbp)
1007 xfs_da_buf_done(lbp);
1008 if (dbp)
1009 xfs_da_buf_done(dbp);
1010 return error;
1011} 996}
1012 997
1013/* 998/*
@@ -1020,7 +1005,7 @@ xfs_dir2_sf_to_block(
1020 xfs_dir2_db_t blkno; /* dir-relative block # (0) */ 1005 xfs_dir2_db_t blkno; /* dir-relative block # (0) */
1021 xfs_dir2_data_hdr_t *hdr; /* block header */ 1006 xfs_dir2_data_hdr_t *hdr; /* block header */
1022 xfs_dir2_leaf_entry_t *blp; /* block leaf entries */ 1007 xfs_dir2_leaf_entry_t *blp; /* block leaf entries */
1023 xfs_dabuf_t *bp; /* block buffer */ 1008 struct xfs_buf *bp; /* block buffer */
1024 xfs_dir2_block_tail_t *btp; /* block tail pointer */ 1009 xfs_dir2_block_tail_t *btp; /* block tail pointer */
1025 xfs_dir2_data_entry_t *dep; /* data entry pointer */ 1010 xfs_dir2_data_entry_t *dep; /* data entry pointer */
1026 xfs_inode_t *dp; /* incore directory inode */ 1011 xfs_inode_t *dp; /* incore directory inode */
@@ -1088,7 +1073,7 @@ xfs_dir2_sf_to_block(
1088 kmem_free(sfp); 1073 kmem_free(sfp);
1089 return error; 1074 return error;
1090 } 1075 }
1091 hdr = bp->data; 1076 hdr = bp->b_addr;
1092 hdr->magic = cpu_to_be32(XFS_DIR2_BLOCK_MAGIC); 1077 hdr->magic = cpu_to_be32(XFS_DIR2_BLOCK_MAGIC);
1093 /* 1078 /*
1094 * Compute size of block "tail" area. 1079 * Compute size of block "tail" area.
@@ -1217,6 +1202,5 @@ xfs_dir2_sf_to_block(
1217 xfs_dir2_block_log_leaf(tp, bp, 0, be32_to_cpu(btp->count) - 1); 1202 xfs_dir2_block_log_leaf(tp, bp, 0, be32_to_cpu(btp->count) - 1);
1218 xfs_dir2_block_log_tail(tp, bp); 1203 xfs_dir2_block_log_tail(tp, bp);
1219 xfs_dir2_data_check(dp, bp); 1204 xfs_dir2_data_check(dp, bp);
1220 xfs_da_buf_done(bp);
1221 return 0; 1205 return 0;
1222} 1206}