aboutsummaryrefslogtreecommitdiffstats
path: root/fs/xfs/xfs_attr_leaf.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_attr_leaf.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_attr_leaf.c')
-rw-r--r--fs/xfs/xfs_attr_leaf.c255
1 files changed, 138 insertions, 117 deletions
diff --git a/fs/xfs/xfs_attr_leaf.c b/fs/xfs/xfs_attr_leaf.c
index 7d89d800f517..d330111ca738 100644
--- a/fs/xfs/xfs_attr_leaf.c
+++ b/fs/xfs/xfs_attr_leaf.c
@@ -54,10 +54,10 @@
54 * Routines used for growing the Btree. 54 * Routines used for growing the Btree.
55 */ 55 */
56STATIC int xfs_attr_leaf_create(xfs_da_args_t *args, xfs_dablk_t which_block, 56STATIC int xfs_attr_leaf_create(xfs_da_args_t *args, xfs_dablk_t which_block,
57 xfs_dabuf_t **bpp); 57 struct xfs_buf **bpp);
58STATIC int xfs_attr_leaf_add_work(xfs_dabuf_t *leaf_buffer, xfs_da_args_t *args, 58STATIC int xfs_attr_leaf_add_work(struct xfs_buf *leaf_buffer,
59 int freemap_index); 59 xfs_da_args_t *args, int freemap_index);
60STATIC void xfs_attr_leaf_compact(xfs_trans_t *trans, xfs_dabuf_t *leaf_buffer); 60STATIC void xfs_attr_leaf_compact(xfs_trans_t *tp, struct xfs_buf *leaf_buffer);
61STATIC void xfs_attr_leaf_rebalance(xfs_da_state_t *state, 61STATIC void xfs_attr_leaf_rebalance(xfs_da_state_t *state,
62 xfs_da_state_blk_t *blk1, 62 xfs_da_state_blk_t *blk1,
63 xfs_da_state_blk_t *blk2); 63 xfs_da_state_blk_t *blk2);
@@ -71,9 +71,9 @@ STATIC int xfs_attr_leaf_figure_balance(xfs_da_state_t *state,
71 * Routines used for shrinking the Btree. 71 * Routines used for shrinking the Btree.
72 */ 72 */
73STATIC int xfs_attr_node_inactive(xfs_trans_t **trans, xfs_inode_t *dp, 73STATIC int xfs_attr_node_inactive(xfs_trans_t **trans, xfs_inode_t *dp,
74 xfs_dabuf_t *bp, int level); 74 struct xfs_buf *bp, int level);
75STATIC int xfs_attr_leaf_inactive(xfs_trans_t **trans, xfs_inode_t *dp, 75STATIC int xfs_attr_leaf_inactive(xfs_trans_t **trans, xfs_inode_t *dp,
76 xfs_dabuf_t *bp); 76 struct xfs_buf *bp);
77STATIC int xfs_attr_leaf_freextent(xfs_trans_t **trans, xfs_inode_t *dp, 77STATIC int xfs_attr_leaf_freextent(xfs_trans_t **trans, xfs_inode_t *dp,
78 xfs_dablk_t blkno, int blkcnt); 78 xfs_dablk_t blkno, int blkcnt);
79 79
@@ -480,7 +480,7 @@ xfs_attr_shortform_to_leaf(xfs_da_args_t *args)
480 char *tmpbuffer; 480 char *tmpbuffer;
481 int error, i, size; 481 int error, i, size;
482 xfs_dablk_t blkno; 482 xfs_dablk_t blkno;
483 xfs_dabuf_t *bp; 483 struct xfs_buf *bp;
484 xfs_ifork_t *ifp; 484 xfs_ifork_t *ifp;
485 485
486 trace_xfs_attr_sf_to_leaf(args); 486 trace_xfs_attr_sf_to_leaf(args);
@@ -550,8 +550,6 @@ xfs_attr_shortform_to_leaf(xfs_da_args_t *args)
550 error = 0; 550 error = 0;
551 551
552out: 552out:
553 if(bp)
554 xfs_da_buf_done(bp);
555 kmem_free(tmpbuffer); 553 kmem_free(tmpbuffer);
556 return(error); 554 return(error);
557} 555}
@@ -737,14 +735,16 @@ xfs_attr_shortform_list(xfs_attr_list_context_t *context)
737 * a shortform attribute list. 735 * a shortform attribute list.
738 */ 736 */
739int 737int
740xfs_attr_shortform_allfit(xfs_dabuf_t *bp, xfs_inode_t *dp) 738xfs_attr_shortform_allfit(
739 struct xfs_buf *bp,
740 struct xfs_inode *dp)
741{ 741{
742 xfs_attr_leafblock_t *leaf; 742 xfs_attr_leafblock_t *leaf;
743 xfs_attr_leaf_entry_t *entry; 743 xfs_attr_leaf_entry_t *entry;
744 xfs_attr_leaf_name_local_t *name_loc; 744 xfs_attr_leaf_name_local_t *name_loc;
745 int bytes, i; 745 int bytes, i;
746 746
747 leaf = bp->data; 747 leaf = bp->b_addr;
748 ASSERT(leaf->hdr.info.magic == cpu_to_be16(XFS_ATTR_LEAF_MAGIC)); 748 ASSERT(leaf->hdr.info.magic == cpu_to_be16(XFS_ATTR_LEAF_MAGIC));
749 749
750 entry = &leaf->entries[0]; 750 entry = &leaf->entries[0];
@@ -774,7 +774,10 @@ xfs_attr_shortform_allfit(xfs_dabuf_t *bp, xfs_inode_t *dp)
774 * Convert a leaf attribute list to shortform attribute list 774 * Convert a leaf attribute list to shortform attribute list
775 */ 775 */
776int 776int
777xfs_attr_leaf_to_shortform(xfs_dabuf_t *bp, xfs_da_args_t *args, int forkoff) 777xfs_attr_leaf_to_shortform(
778 struct xfs_buf *bp,
779 xfs_da_args_t *args,
780 int forkoff)
778{ 781{
779 xfs_attr_leafblock_t *leaf; 782 xfs_attr_leafblock_t *leaf;
780 xfs_attr_leaf_entry_t *entry; 783 xfs_attr_leaf_entry_t *entry;
@@ -791,10 +794,10 @@ xfs_attr_leaf_to_shortform(xfs_dabuf_t *bp, xfs_da_args_t *args, int forkoff)
791 ASSERT(tmpbuffer != NULL); 794 ASSERT(tmpbuffer != NULL);
792 795
793 ASSERT(bp != NULL); 796 ASSERT(bp != NULL);
794 memcpy(tmpbuffer, bp->data, XFS_LBSIZE(dp->i_mount)); 797 memcpy(tmpbuffer, bp->b_addr, XFS_LBSIZE(dp->i_mount));
795 leaf = (xfs_attr_leafblock_t *)tmpbuffer; 798 leaf = (xfs_attr_leafblock_t *)tmpbuffer;
796 ASSERT(leaf->hdr.info.magic == cpu_to_be16(XFS_ATTR_LEAF_MAGIC)); 799 ASSERT(leaf->hdr.info.magic == cpu_to_be16(XFS_ATTR_LEAF_MAGIC));
797 memset(bp->data, 0, XFS_LBSIZE(dp->i_mount)); 800 memset(bp->b_addr, 0, XFS_LBSIZE(dp->i_mount));
798 801
799 /* 802 /*
800 * Clean out the prior contents of the attribute list. 803 * Clean out the prior contents of the attribute list.
@@ -855,7 +858,7 @@ xfs_attr_leaf_to_node(xfs_da_args_t *args)
855 xfs_attr_leafblock_t *leaf; 858 xfs_attr_leafblock_t *leaf;
856 xfs_da_intnode_t *node; 859 xfs_da_intnode_t *node;
857 xfs_inode_t *dp; 860 xfs_inode_t *dp;
858 xfs_dabuf_t *bp1, *bp2; 861 struct xfs_buf *bp1, *bp2;
859 xfs_dablk_t blkno; 862 xfs_dablk_t blkno;
860 int error; 863 int error;
861 864
@@ -877,10 +880,9 @@ xfs_attr_leaf_to_node(xfs_da_args_t *args)
877 if (error) 880 if (error)
878 goto out; 881 goto out;
879 ASSERT(bp2 != NULL); 882 ASSERT(bp2 != NULL);
880 memcpy(bp2->data, bp1->data, XFS_LBSIZE(dp->i_mount)); 883 memcpy(bp2->b_addr, bp1->b_addr, XFS_LBSIZE(dp->i_mount));
881 xfs_da_buf_done(bp1);
882 bp1 = NULL; 884 bp1 = NULL;
883 xfs_da_log_buf(args->trans, bp2, 0, XFS_LBSIZE(dp->i_mount) - 1); 885 xfs_trans_log_buf(args->trans, bp2, 0, XFS_LBSIZE(dp->i_mount) - 1);
884 886
885 /* 887 /*
886 * Set up the new root node. 888 * Set up the new root node.
@@ -888,21 +890,17 @@ xfs_attr_leaf_to_node(xfs_da_args_t *args)
888 error = xfs_da_node_create(args, 0, 1, &bp1, XFS_ATTR_FORK); 890 error = xfs_da_node_create(args, 0, 1, &bp1, XFS_ATTR_FORK);
889 if (error) 891 if (error)
890 goto out; 892 goto out;
891 node = bp1->data; 893 node = bp1->b_addr;
892 leaf = bp2->data; 894 leaf = bp2->b_addr;
893 ASSERT(leaf->hdr.info.magic == cpu_to_be16(XFS_ATTR_LEAF_MAGIC)); 895 ASSERT(leaf->hdr.info.magic == cpu_to_be16(XFS_ATTR_LEAF_MAGIC));
894 /* both on-disk, don't endian-flip twice */ 896 /* both on-disk, don't endian-flip twice */
895 node->btree[0].hashval = 897 node->btree[0].hashval =
896 leaf->entries[be16_to_cpu(leaf->hdr.count)-1 ].hashval; 898 leaf->entries[be16_to_cpu(leaf->hdr.count)-1 ].hashval;
897 node->btree[0].before = cpu_to_be32(blkno); 899 node->btree[0].before = cpu_to_be32(blkno);
898 node->hdr.count = cpu_to_be16(1); 900 node->hdr.count = cpu_to_be16(1);
899 xfs_da_log_buf(args->trans, bp1, 0, XFS_LBSIZE(dp->i_mount) - 1); 901 xfs_trans_log_buf(args->trans, bp1, 0, XFS_LBSIZE(dp->i_mount) - 1);
900 error = 0; 902 error = 0;
901out: 903out:
902 if (bp1)
903 xfs_da_buf_done(bp1);
904 if (bp2)
905 xfs_da_buf_done(bp2);
906 return(error); 904 return(error);
907} 905}
908 906
@@ -916,12 +914,15 @@ out:
916 * or a leaf in a node attribute list. 914 * or a leaf in a node attribute list.
917 */ 915 */
918STATIC int 916STATIC int
919xfs_attr_leaf_create(xfs_da_args_t *args, xfs_dablk_t blkno, xfs_dabuf_t **bpp) 917xfs_attr_leaf_create(
918 xfs_da_args_t *args,
919 xfs_dablk_t blkno,
920 struct xfs_buf **bpp)
920{ 921{
921 xfs_attr_leafblock_t *leaf; 922 xfs_attr_leafblock_t *leaf;
922 xfs_attr_leaf_hdr_t *hdr; 923 xfs_attr_leaf_hdr_t *hdr;
923 xfs_inode_t *dp; 924 xfs_inode_t *dp;
924 xfs_dabuf_t *bp; 925 struct xfs_buf *bp;
925 int error; 926 int error;
926 927
927 trace_xfs_attr_leaf_create(args); 928 trace_xfs_attr_leaf_create(args);
@@ -933,7 +934,7 @@ xfs_attr_leaf_create(xfs_da_args_t *args, xfs_dablk_t blkno, xfs_dabuf_t **bpp)
933 if (error) 934 if (error)
934 return(error); 935 return(error);
935 ASSERT(bp != NULL); 936 ASSERT(bp != NULL);
936 leaf = bp->data; 937 leaf = bp->b_addr;
937 memset((char *)leaf, 0, XFS_LBSIZE(dp->i_mount)); 938 memset((char *)leaf, 0, XFS_LBSIZE(dp->i_mount));
938 hdr = &leaf->hdr; 939 hdr = &leaf->hdr;
939 hdr->info.magic = cpu_to_be16(XFS_ATTR_LEAF_MAGIC); 940 hdr->info.magic = cpu_to_be16(XFS_ATTR_LEAF_MAGIC);
@@ -947,7 +948,7 @@ xfs_attr_leaf_create(xfs_da_args_t *args, xfs_dablk_t blkno, xfs_dabuf_t **bpp)
947 hdr->freemap[0].size = cpu_to_be16(be16_to_cpu(hdr->firstused) - 948 hdr->freemap[0].size = cpu_to_be16(be16_to_cpu(hdr->firstused) -
948 sizeof(xfs_attr_leaf_hdr_t)); 949 sizeof(xfs_attr_leaf_hdr_t));
949 950
950 xfs_da_log_buf(args->trans, bp, 0, XFS_LBSIZE(dp->i_mount) - 1); 951 xfs_trans_log_buf(args->trans, bp, 0, XFS_LBSIZE(dp->i_mount) - 1);
951 952
952 *bpp = bp; 953 *bpp = bp;
953 return(0); 954 return(0);
@@ -1014,7 +1015,9 @@ xfs_attr_leaf_split(xfs_da_state_t *state, xfs_da_state_blk_t *oldblk,
1014 * Add a name to the leaf attribute list structure. 1015 * Add a name to the leaf attribute list structure.
1015 */ 1016 */
1016int 1017int
1017xfs_attr_leaf_add(xfs_dabuf_t *bp, xfs_da_args_t *args) 1018xfs_attr_leaf_add(
1019 struct xfs_buf *bp,
1020 struct xfs_da_args *args)
1018{ 1021{
1019 xfs_attr_leafblock_t *leaf; 1022 xfs_attr_leafblock_t *leaf;
1020 xfs_attr_leaf_hdr_t *hdr; 1023 xfs_attr_leaf_hdr_t *hdr;
@@ -1023,7 +1026,7 @@ xfs_attr_leaf_add(xfs_dabuf_t *bp, xfs_da_args_t *args)
1023 1026
1024 trace_xfs_attr_leaf_add(args); 1027 trace_xfs_attr_leaf_add(args);
1025 1028
1026 leaf = bp->data; 1029 leaf = bp->b_addr;
1027 ASSERT(leaf->hdr.info.magic == cpu_to_be16(XFS_ATTR_LEAF_MAGIC)); 1030 ASSERT(leaf->hdr.info.magic == cpu_to_be16(XFS_ATTR_LEAF_MAGIC));
1028 ASSERT((args->index >= 0) 1031 ASSERT((args->index >= 0)
1029 && (args->index <= be16_to_cpu(leaf->hdr.count))); 1032 && (args->index <= be16_to_cpu(leaf->hdr.count)));
@@ -1085,7 +1088,10 @@ xfs_attr_leaf_add(xfs_dabuf_t *bp, xfs_da_args_t *args)
1085 * Add a name to a leaf attribute list structure. 1088 * Add a name to a leaf attribute list structure.
1086 */ 1089 */
1087STATIC int 1090STATIC int
1088xfs_attr_leaf_add_work(xfs_dabuf_t *bp, xfs_da_args_t *args, int mapindex) 1091xfs_attr_leaf_add_work(
1092 struct xfs_buf *bp,
1093 xfs_da_args_t *args,
1094 int mapindex)
1089{ 1095{
1090 xfs_attr_leafblock_t *leaf; 1096 xfs_attr_leafblock_t *leaf;
1091 xfs_attr_leaf_hdr_t *hdr; 1097 xfs_attr_leaf_hdr_t *hdr;
@@ -1096,7 +1102,7 @@ xfs_attr_leaf_add_work(xfs_dabuf_t *bp, xfs_da_args_t *args, int mapindex)
1096 xfs_mount_t *mp; 1102 xfs_mount_t *mp;
1097 int tmp, i; 1103 int tmp, i;
1098 1104
1099 leaf = bp->data; 1105 leaf = bp->b_addr;
1100 ASSERT(leaf->hdr.info.magic == cpu_to_be16(XFS_ATTR_LEAF_MAGIC)); 1106 ASSERT(leaf->hdr.info.magic == cpu_to_be16(XFS_ATTR_LEAF_MAGIC));
1101 hdr = &leaf->hdr; 1107 hdr = &leaf->hdr;
1102 ASSERT((mapindex >= 0) && (mapindex < XFS_ATTR_LEAF_MAPSIZE)); 1108 ASSERT((mapindex >= 0) && (mapindex < XFS_ATTR_LEAF_MAPSIZE));
@@ -1110,7 +1116,7 @@ xfs_attr_leaf_add_work(xfs_dabuf_t *bp, xfs_da_args_t *args, int mapindex)
1110 tmp = be16_to_cpu(hdr->count) - args->index; 1116 tmp = be16_to_cpu(hdr->count) - args->index;
1111 tmp *= sizeof(xfs_attr_leaf_entry_t); 1117 tmp *= sizeof(xfs_attr_leaf_entry_t);
1112 memmove((char *)(entry+1), (char *)entry, tmp); 1118 memmove((char *)(entry+1), (char *)entry, tmp);
1113 xfs_da_log_buf(args->trans, bp, 1119 xfs_trans_log_buf(args->trans, bp,
1114 XFS_DA_LOGRANGE(leaf, entry, tmp + sizeof(*entry))); 1120 XFS_DA_LOGRANGE(leaf, entry, tmp + sizeof(*entry)));
1115 } 1121 }
1116 be16_add_cpu(&hdr->count, 1); 1122 be16_add_cpu(&hdr->count, 1);
@@ -1142,7 +1148,7 @@ xfs_attr_leaf_add_work(xfs_dabuf_t *bp, xfs_da_args_t *args, int mapindex)
1142 args->index2++; 1148 args->index2++;
1143 } 1149 }
1144 } 1150 }
1145 xfs_da_log_buf(args->trans, bp, 1151 xfs_trans_log_buf(args->trans, bp,
1146 XFS_DA_LOGRANGE(leaf, entry, sizeof(*entry))); 1152 XFS_DA_LOGRANGE(leaf, entry, sizeof(*entry)));
1147 ASSERT((args->index == 0) || 1153 ASSERT((args->index == 0) ||
1148 (be32_to_cpu(entry->hashval) >= be32_to_cpu((entry-1)->hashval))); 1154 (be32_to_cpu(entry->hashval) >= be32_to_cpu((entry-1)->hashval)));
@@ -1174,7 +1180,7 @@ xfs_attr_leaf_add_work(xfs_dabuf_t *bp, xfs_da_args_t *args, int mapindex)
1174 args->rmtblkno = 1; 1180 args->rmtblkno = 1;
1175 args->rmtblkcnt = XFS_B_TO_FSB(mp, args->valuelen); 1181 args->rmtblkcnt = XFS_B_TO_FSB(mp, args->valuelen);
1176 } 1182 }
1177 xfs_da_log_buf(args->trans, bp, 1183 xfs_trans_log_buf(args->trans, bp,
1178 XFS_DA_LOGRANGE(leaf, xfs_attr_leaf_name(leaf, args->index), 1184 XFS_DA_LOGRANGE(leaf, xfs_attr_leaf_name(leaf, args->index),
1179 xfs_attr_leaf_entsize(leaf, args->index))); 1185 xfs_attr_leaf_entsize(leaf, args->index)));
1180 1186
@@ -1198,7 +1204,7 @@ xfs_attr_leaf_add_work(xfs_dabuf_t *bp, xfs_da_args_t *args, int mapindex)
1198 } 1204 }
1199 } 1205 }
1200 be16_add_cpu(&hdr->usedbytes, xfs_attr_leaf_entsize(leaf, args->index)); 1206 be16_add_cpu(&hdr->usedbytes, xfs_attr_leaf_entsize(leaf, args->index));
1201 xfs_da_log_buf(args->trans, bp, 1207 xfs_trans_log_buf(args->trans, bp,
1202 XFS_DA_LOGRANGE(leaf, hdr, sizeof(*hdr))); 1208 XFS_DA_LOGRANGE(leaf, hdr, sizeof(*hdr)));
1203 return(0); 1209 return(0);
1204} 1210}
@@ -1207,7 +1213,9 @@ xfs_attr_leaf_add_work(xfs_dabuf_t *bp, xfs_da_args_t *args, int mapindex)
1207 * Garbage collect a leaf attribute list block by copying it to a new buffer. 1213 * Garbage collect a leaf attribute list block by copying it to a new buffer.
1208 */ 1214 */
1209STATIC void 1215STATIC void
1210xfs_attr_leaf_compact(xfs_trans_t *trans, xfs_dabuf_t *bp) 1216xfs_attr_leaf_compact(
1217 struct xfs_trans *trans,
1218 struct xfs_buf *bp)
1211{ 1219{
1212 xfs_attr_leafblock_t *leaf_s, *leaf_d; 1220 xfs_attr_leafblock_t *leaf_s, *leaf_d;
1213 xfs_attr_leaf_hdr_t *hdr_s, *hdr_d; 1221 xfs_attr_leaf_hdr_t *hdr_s, *hdr_d;
@@ -1217,14 +1225,14 @@ xfs_attr_leaf_compact(xfs_trans_t *trans, xfs_dabuf_t *bp)
1217 mp = trans->t_mountp; 1225 mp = trans->t_mountp;
1218 tmpbuffer = kmem_alloc(XFS_LBSIZE(mp), KM_SLEEP); 1226 tmpbuffer = kmem_alloc(XFS_LBSIZE(mp), KM_SLEEP);
1219 ASSERT(tmpbuffer != NULL); 1227 ASSERT(tmpbuffer != NULL);
1220 memcpy(tmpbuffer, bp->data, XFS_LBSIZE(mp)); 1228 memcpy(tmpbuffer, bp->b_addr, XFS_LBSIZE(mp));
1221 memset(bp->data, 0, XFS_LBSIZE(mp)); 1229 memset(bp->b_addr, 0, XFS_LBSIZE(mp));
1222 1230
1223 /* 1231 /*
1224 * Copy basic information 1232 * Copy basic information
1225 */ 1233 */
1226 leaf_s = (xfs_attr_leafblock_t *)tmpbuffer; 1234 leaf_s = (xfs_attr_leafblock_t *)tmpbuffer;
1227 leaf_d = bp->data; 1235 leaf_d = bp->b_addr;
1228 hdr_s = &leaf_s->hdr; 1236 hdr_s = &leaf_s->hdr;
1229 hdr_d = &leaf_d->hdr; 1237 hdr_d = &leaf_d->hdr;
1230 hdr_d->info = hdr_s->info; /* struct copy */ 1238 hdr_d->info = hdr_s->info; /* struct copy */
@@ -1247,7 +1255,7 @@ xfs_attr_leaf_compact(xfs_trans_t *trans, xfs_dabuf_t *bp)
1247 */ 1255 */
1248 xfs_attr_leaf_moveents(leaf_s, 0, leaf_d, 0, 1256 xfs_attr_leaf_moveents(leaf_s, 0, leaf_d, 0,
1249 be16_to_cpu(hdr_s->count), mp); 1257 be16_to_cpu(hdr_s->count), mp);
1250 xfs_da_log_buf(trans, bp, 0, XFS_LBSIZE(mp) - 1); 1258 xfs_trans_log_buf(trans, bp, 0, XFS_LBSIZE(mp) - 1);
1251 1259
1252 kmem_free(tmpbuffer); 1260 kmem_free(tmpbuffer);
1253} 1261}
@@ -1279,8 +1287,8 @@ xfs_attr_leaf_rebalance(xfs_da_state_t *state, xfs_da_state_blk_t *blk1,
1279 */ 1287 */
1280 ASSERT(blk1->magic == XFS_ATTR_LEAF_MAGIC); 1288 ASSERT(blk1->magic == XFS_ATTR_LEAF_MAGIC);
1281 ASSERT(blk2->magic == XFS_ATTR_LEAF_MAGIC); 1289 ASSERT(blk2->magic == XFS_ATTR_LEAF_MAGIC);
1282 leaf1 = blk1->bp->data; 1290 leaf1 = blk1->bp->b_addr;
1283 leaf2 = blk2->bp->data; 1291 leaf2 = blk2->bp->b_addr;
1284 ASSERT(leaf1->hdr.info.magic == cpu_to_be16(XFS_ATTR_LEAF_MAGIC)); 1292 ASSERT(leaf1->hdr.info.magic == cpu_to_be16(XFS_ATTR_LEAF_MAGIC));
1285 ASSERT(leaf2->hdr.info.magic == cpu_to_be16(XFS_ATTR_LEAF_MAGIC)); 1293 ASSERT(leaf2->hdr.info.magic == cpu_to_be16(XFS_ATTR_LEAF_MAGIC));
1286 args = state->args; 1294 args = state->args;
@@ -1298,8 +1306,8 @@ xfs_attr_leaf_rebalance(xfs_da_state_t *state, xfs_da_state_blk_t *blk1,
1298 tmp_blk = blk1; 1306 tmp_blk = blk1;
1299 blk1 = blk2; 1307 blk1 = blk2;
1300 blk2 = tmp_blk; 1308 blk2 = tmp_blk;
1301 leaf1 = blk1->bp->data; 1309 leaf1 = blk1->bp->b_addr;
1302 leaf2 = blk2->bp->data; 1310 leaf2 = blk2->bp->b_addr;
1303 swap = 1; 1311 swap = 1;
1304 } 1312 }
1305 hdr1 = &leaf1->hdr; 1313 hdr1 = &leaf1->hdr;
@@ -1346,8 +1354,8 @@ xfs_attr_leaf_rebalance(xfs_da_state_t *state, xfs_da_state_blk_t *blk1,
1346 xfs_attr_leaf_moveents(leaf1, be16_to_cpu(hdr1->count) - count, 1354 xfs_attr_leaf_moveents(leaf1, be16_to_cpu(hdr1->count) - count,
1347 leaf2, 0, count, state->mp); 1355 leaf2, 0, count, state->mp);
1348 1356
1349 xfs_da_log_buf(args->trans, blk1->bp, 0, state->blocksize-1); 1357 xfs_trans_log_buf(args->trans, blk1->bp, 0, state->blocksize-1);
1350 xfs_da_log_buf(args->trans, blk2->bp, 0, state->blocksize-1); 1358 xfs_trans_log_buf(args->trans, blk2->bp, 0, state->blocksize-1);
1351 } else if (count > be16_to_cpu(hdr1->count)) { 1359 } else if (count > be16_to_cpu(hdr1->count)) {
1352 /* 1360 /*
1353 * I assert that since all callers pass in an empty 1361 * I assert that since all callers pass in an empty
@@ -1378,8 +1386,8 @@ xfs_attr_leaf_rebalance(xfs_da_state_t *state, xfs_da_state_blk_t *blk1,
1378 xfs_attr_leaf_moveents(leaf2, 0, leaf1, 1386 xfs_attr_leaf_moveents(leaf2, 0, leaf1,
1379 be16_to_cpu(hdr1->count), count, state->mp); 1387 be16_to_cpu(hdr1->count), count, state->mp);
1380 1388
1381 xfs_da_log_buf(args->trans, blk1->bp, 0, state->blocksize-1); 1389 xfs_trans_log_buf(args->trans, blk1->bp, 0, state->blocksize-1);
1382 xfs_da_log_buf(args->trans, blk2->bp, 0, state->blocksize-1); 1390 xfs_trans_log_buf(args->trans, blk2->bp, 0, state->blocksize-1);
1383 } 1391 }
1384 1392
1385 /* 1393 /*
@@ -1448,8 +1456,8 @@ xfs_attr_leaf_figure_balance(xfs_da_state_t *state,
1448 /* 1456 /*
1449 * Set up environment. 1457 * Set up environment.
1450 */ 1458 */
1451 leaf1 = blk1->bp->data; 1459 leaf1 = blk1->bp->b_addr;
1452 leaf2 = blk2->bp->data; 1460 leaf2 = blk2->bp->b_addr;
1453 hdr1 = &leaf1->hdr; 1461 hdr1 = &leaf1->hdr;
1454 hdr2 = &leaf2->hdr; 1462 hdr2 = &leaf2->hdr;
1455 foundit = 0; 1463 foundit = 0;
@@ -1551,7 +1559,7 @@ xfs_attr_leaf_toosmall(xfs_da_state_t *state, int *action)
1551 xfs_da_blkinfo_t *info; 1559 xfs_da_blkinfo_t *info;
1552 int count, bytes, forward, error, retval, i; 1560 int count, bytes, forward, error, retval, i;
1553 xfs_dablk_t blkno; 1561 xfs_dablk_t blkno;
1554 xfs_dabuf_t *bp; 1562 struct xfs_buf *bp;
1555 1563
1556 /* 1564 /*
1557 * Check for the degenerate case of the block being over 50% full. 1565 * Check for the degenerate case of the block being over 50% full.
@@ -1559,7 +1567,7 @@ xfs_attr_leaf_toosmall(xfs_da_state_t *state, int *action)
1559 * to coalesce with a sibling. 1567 * to coalesce with a sibling.
1560 */ 1568 */
1561 blk = &state->path.blk[ state->path.active-1 ]; 1569 blk = &state->path.blk[ state->path.active-1 ];
1562 info = blk->bp->data; 1570 info = blk->bp->b_addr;
1563 ASSERT(info->magic == cpu_to_be16(XFS_ATTR_LEAF_MAGIC)); 1571 ASSERT(info->magic == cpu_to_be16(XFS_ATTR_LEAF_MAGIC));
1564 leaf = (xfs_attr_leafblock_t *)info; 1572 leaf = (xfs_attr_leafblock_t *)info;
1565 count = be16_to_cpu(leaf->hdr.count); 1573 count = be16_to_cpu(leaf->hdr.count);
@@ -1622,13 +1630,13 @@ xfs_attr_leaf_toosmall(xfs_da_state_t *state, int *action)
1622 count = be16_to_cpu(leaf->hdr.count); 1630 count = be16_to_cpu(leaf->hdr.count);
1623 bytes = state->blocksize - (state->blocksize>>2); 1631 bytes = state->blocksize - (state->blocksize>>2);
1624 bytes -= be16_to_cpu(leaf->hdr.usedbytes); 1632 bytes -= be16_to_cpu(leaf->hdr.usedbytes);
1625 leaf = bp->data; 1633 leaf = bp->b_addr;
1626 ASSERT(leaf->hdr.info.magic == cpu_to_be16(XFS_ATTR_LEAF_MAGIC)); 1634 ASSERT(leaf->hdr.info.magic == cpu_to_be16(XFS_ATTR_LEAF_MAGIC));
1627 count += be16_to_cpu(leaf->hdr.count); 1635 count += be16_to_cpu(leaf->hdr.count);
1628 bytes -= be16_to_cpu(leaf->hdr.usedbytes); 1636 bytes -= be16_to_cpu(leaf->hdr.usedbytes);
1629 bytes -= count * sizeof(xfs_attr_leaf_entry_t); 1637 bytes -= count * sizeof(xfs_attr_leaf_entry_t);
1630 bytes -= sizeof(xfs_attr_leaf_hdr_t); 1638 bytes -= sizeof(xfs_attr_leaf_hdr_t);
1631 xfs_da_brelse(state->args->trans, bp); 1639 xfs_trans_brelse(state->args->trans, bp);
1632 if (bytes >= 0) 1640 if (bytes >= 0)
1633 break; /* fits with at least 25% to spare */ 1641 break; /* fits with at least 25% to spare */
1634 } 1642 }
@@ -1666,7 +1674,9 @@ xfs_attr_leaf_toosmall(xfs_da_state_t *state, int *action)
1666 * If two leaves are 37% full, when combined they will leave 25% free. 1674 * If two leaves are 37% full, when combined they will leave 25% free.
1667 */ 1675 */
1668int 1676int
1669xfs_attr_leaf_remove(xfs_dabuf_t *bp, xfs_da_args_t *args) 1677xfs_attr_leaf_remove(
1678 struct xfs_buf *bp,
1679 xfs_da_args_t *args)
1670{ 1680{
1671 xfs_attr_leafblock_t *leaf; 1681 xfs_attr_leafblock_t *leaf;
1672 xfs_attr_leaf_hdr_t *hdr; 1682 xfs_attr_leaf_hdr_t *hdr;
@@ -1676,7 +1686,7 @@ xfs_attr_leaf_remove(xfs_dabuf_t *bp, xfs_da_args_t *args)
1676 int tablesize, tmp, i; 1686 int tablesize, tmp, i;
1677 xfs_mount_t *mp; 1687 xfs_mount_t *mp;
1678 1688
1679 leaf = bp->data; 1689 leaf = bp->b_addr;
1680 ASSERT(leaf->hdr.info.magic == cpu_to_be16(XFS_ATTR_LEAF_MAGIC)); 1690 ASSERT(leaf->hdr.info.magic == cpu_to_be16(XFS_ATTR_LEAF_MAGIC));
1681 hdr = &leaf->hdr; 1691 hdr = &leaf->hdr;
1682 mp = args->trans->t_mountp; 1692 mp = args->trans->t_mountp;
@@ -1769,7 +1779,7 @@ xfs_attr_leaf_remove(xfs_dabuf_t *bp, xfs_da_args_t *args)
1769 */ 1779 */
1770 memset(xfs_attr_leaf_name(leaf, args->index), 0, entsize); 1780 memset(xfs_attr_leaf_name(leaf, args->index), 0, entsize);
1771 be16_add_cpu(&hdr->usedbytes, -entsize); 1781 be16_add_cpu(&hdr->usedbytes, -entsize);
1772 xfs_da_log_buf(args->trans, bp, 1782 xfs_trans_log_buf(args->trans, bp,
1773 XFS_DA_LOGRANGE(leaf, xfs_attr_leaf_name(leaf, args->index), 1783 XFS_DA_LOGRANGE(leaf, xfs_attr_leaf_name(leaf, args->index),
1774 entsize)); 1784 entsize));
1775 1785
@@ -1777,7 +1787,7 @@ xfs_attr_leaf_remove(xfs_dabuf_t *bp, xfs_da_args_t *args)
1777 * sizeof(xfs_attr_leaf_entry_t); 1787 * sizeof(xfs_attr_leaf_entry_t);
1778 memmove((char *)entry, (char *)(entry+1), tmp); 1788 memmove((char *)entry, (char *)(entry+1), tmp);
1779 be16_add_cpu(&hdr->count, -1); 1789 be16_add_cpu(&hdr->count, -1);
1780 xfs_da_log_buf(args->trans, bp, 1790 xfs_trans_log_buf(args->trans, bp,
1781 XFS_DA_LOGRANGE(leaf, entry, tmp + sizeof(*entry))); 1791 XFS_DA_LOGRANGE(leaf, entry, tmp + sizeof(*entry)));
1782 entry = &leaf->entries[be16_to_cpu(hdr->count)]; 1792 entry = &leaf->entries[be16_to_cpu(hdr->count)];
1783 memset((char *)entry, 0, sizeof(xfs_attr_leaf_entry_t)); 1793 memset((char *)entry, 0, sizeof(xfs_attr_leaf_entry_t));
@@ -1807,7 +1817,7 @@ xfs_attr_leaf_remove(xfs_dabuf_t *bp, xfs_da_args_t *args)
1807 } else { 1817 } else {
1808 hdr->holes = 1; /* mark as needing compaction */ 1818 hdr->holes = 1; /* mark as needing compaction */
1809 } 1819 }
1810 xfs_da_log_buf(args->trans, bp, 1820 xfs_trans_log_buf(args->trans, bp,
1811 XFS_DA_LOGRANGE(leaf, hdr, sizeof(*hdr))); 1821 XFS_DA_LOGRANGE(leaf, hdr, sizeof(*hdr)));
1812 1822
1813 /* 1823 /*
@@ -1840,8 +1850,8 @@ xfs_attr_leaf_unbalance(xfs_da_state_t *state, xfs_da_state_blk_t *drop_blk,
1840 mp = state->mp; 1850 mp = state->mp;
1841 ASSERT(drop_blk->magic == XFS_ATTR_LEAF_MAGIC); 1851 ASSERT(drop_blk->magic == XFS_ATTR_LEAF_MAGIC);
1842 ASSERT(save_blk->magic == XFS_ATTR_LEAF_MAGIC); 1852 ASSERT(save_blk->magic == XFS_ATTR_LEAF_MAGIC);
1843 drop_leaf = drop_blk->bp->data; 1853 drop_leaf = drop_blk->bp->b_addr;
1844 save_leaf = save_blk->bp->data; 1854 save_leaf = save_blk->bp->b_addr;
1845 ASSERT(drop_leaf->hdr.info.magic == cpu_to_be16(XFS_ATTR_LEAF_MAGIC)); 1855 ASSERT(drop_leaf->hdr.info.magic == cpu_to_be16(XFS_ATTR_LEAF_MAGIC));
1846 ASSERT(save_leaf->hdr.info.magic == cpu_to_be16(XFS_ATTR_LEAF_MAGIC)); 1856 ASSERT(save_leaf->hdr.info.magic == cpu_to_be16(XFS_ATTR_LEAF_MAGIC));
1847 drop_hdr = &drop_leaf->hdr; 1857 drop_hdr = &drop_leaf->hdr;
@@ -1906,7 +1916,7 @@ xfs_attr_leaf_unbalance(xfs_da_state_t *state, xfs_da_state_blk_t *drop_blk,
1906 kmem_free(tmpbuffer); 1916 kmem_free(tmpbuffer);
1907 } 1917 }
1908 1918
1909 xfs_da_log_buf(state->args->trans, save_blk->bp, 0, 1919 xfs_trans_log_buf(state->args->trans, save_blk->bp, 0,
1910 state->blocksize - 1); 1920 state->blocksize - 1);
1911 1921
1912 /* 1922 /*
@@ -1934,7 +1944,9 @@ xfs_attr_leaf_unbalance(xfs_da_state_t *state, xfs_da_state_blk_t *drop_blk,
1934 * Don't change the args->value unless we find the attribute. 1944 * Don't change the args->value unless we find the attribute.
1935 */ 1945 */
1936int 1946int
1937xfs_attr_leaf_lookup_int(xfs_dabuf_t *bp, xfs_da_args_t *args) 1947xfs_attr_leaf_lookup_int(
1948 struct xfs_buf *bp,
1949 xfs_da_args_t *args)
1938{ 1950{
1939 xfs_attr_leafblock_t *leaf; 1951 xfs_attr_leafblock_t *leaf;
1940 xfs_attr_leaf_entry_t *entry; 1952 xfs_attr_leaf_entry_t *entry;
@@ -1945,7 +1957,7 @@ xfs_attr_leaf_lookup_int(xfs_dabuf_t *bp, xfs_da_args_t *args)
1945 1957
1946 trace_xfs_attr_leaf_lookup(args); 1958 trace_xfs_attr_leaf_lookup(args);
1947 1959
1948 leaf = bp->data; 1960 leaf = bp->b_addr;
1949 ASSERT(leaf->hdr.info.magic == cpu_to_be16(XFS_ATTR_LEAF_MAGIC)); 1961 ASSERT(leaf->hdr.info.magic == cpu_to_be16(XFS_ATTR_LEAF_MAGIC));
1950 ASSERT(be16_to_cpu(leaf->hdr.count) 1962 ASSERT(be16_to_cpu(leaf->hdr.count)
1951 < (XFS_LBSIZE(args->dp->i_mount)/8)); 1963 < (XFS_LBSIZE(args->dp->i_mount)/8));
@@ -2041,7 +2053,9 @@ xfs_attr_leaf_lookup_int(xfs_dabuf_t *bp, xfs_da_args_t *args)
2041 * list structure. 2053 * list structure.
2042 */ 2054 */
2043int 2055int
2044xfs_attr_leaf_getvalue(xfs_dabuf_t *bp, xfs_da_args_t *args) 2056xfs_attr_leaf_getvalue(
2057 struct xfs_buf *bp,
2058 xfs_da_args_t *args)
2045{ 2059{
2046 int valuelen; 2060 int valuelen;
2047 xfs_attr_leafblock_t *leaf; 2061 xfs_attr_leafblock_t *leaf;
@@ -2049,7 +2063,7 @@ xfs_attr_leaf_getvalue(xfs_dabuf_t *bp, xfs_da_args_t *args)
2049 xfs_attr_leaf_name_local_t *name_loc; 2063 xfs_attr_leaf_name_local_t *name_loc;
2050 xfs_attr_leaf_name_remote_t *name_rmt; 2064 xfs_attr_leaf_name_remote_t *name_rmt;
2051 2065
2052 leaf = bp->data; 2066 leaf = bp->b_addr;
2053 ASSERT(leaf->hdr.info.magic == cpu_to_be16(XFS_ATTR_LEAF_MAGIC)); 2067 ASSERT(leaf->hdr.info.magic == cpu_to_be16(XFS_ATTR_LEAF_MAGIC));
2054 ASSERT(be16_to_cpu(leaf->hdr.count) 2068 ASSERT(be16_to_cpu(leaf->hdr.count)
2055 < (XFS_LBSIZE(args->dp->i_mount)/8)); 2069 < (XFS_LBSIZE(args->dp->i_mount)/8));
@@ -2247,12 +2261,14 @@ xfs_attr_leaf_moveents(xfs_attr_leafblock_t *leaf_s, int start_s,
2247 * Return 0 unless leaf2 should go before leaf1. 2261 * Return 0 unless leaf2 should go before leaf1.
2248 */ 2262 */
2249int 2263int
2250xfs_attr_leaf_order(xfs_dabuf_t *leaf1_bp, xfs_dabuf_t *leaf2_bp) 2264xfs_attr_leaf_order(
2265 struct xfs_buf *leaf1_bp,
2266 struct xfs_buf *leaf2_bp)
2251{ 2267{
2252 xfs_attr_leafblock_t *leaf1, *leaf2; 2268 xfs_attr_leafblock_t *leaf1, *leaf2;
2253 2269
2254 leaf1 = leaf1_bp->data; 2270 leaf1 = leaf1_bp->b_addr;
2255 leaf2 = leaf2_bp->data; 2271 leaf2 = leaf2_bp->b_addr;
2256 ASSERT((leaf1->hdr.info.magic == cpu_to_be16(XFS_ATTR_LEAF_MAGIC)) && 2272 ASSERT((leaf1->hdr.info.magic == cpu_to_be16(XFS_ATTR_LEAF_MAGIC)) &&
2257 (leaf2->hdr.info.magic == cpu_to_be16(XFS_ATTR_LEAF_MAGIC))); 2273 (leaf2->hdr.info.magic == cpu_to_be16(XFS_ATTR_LEAF_MAGIC)));
2258 if ((be16_to_cpu(leaf1->hdr.count) > 0) && 2274 if ((be16_to_cpu(leaf1->hdr.count) > 0) &&
@@ -2272,11 +2288,13 @@ xfs_attr_leaf_order(xfs_dabuf_t *leaf1_bp, xfs_dabuf_t *leaf2_bp)
2272 * Pick up the last hashvalue from a leaf block. 2288 * Pick up the last hashvalue from a leaf block.
2273 */ 2289 */
2274xfs_dahash_t 2290xfs_dahash_t
2275xfs_attr_leaf_lasthash(xfs_dabuf_t *bp, int *count) 2291xfs_attr_leaf_lasthash(
2292 struct xfs_buf *bp,
2293 int *count)
2276{ 2294{
2277 xfs_attr_leafblock_t *leaf; 2295 xfs_attr_leafblock_t *leaf;
2278 2296
2279 leaf = bp->data; 2297 leaf = bp->b_addr;
2280 ASSERT(leaf->hdr.info.magic == cpu_to_be16(XFS_ATTR_LEAF_MAGIC)); 2298 ASSERT(leaf->hdr.info.magic == cpu_to_be16(XFS_ATTR_LEAF_MAGIC));
2281 if (count) 2299 if (count)
2282 *count = be16_to_cpu(leaf->hdr.count); 2300 *count = be16_to_cpu(leaf->hdr.count);
@@ -2337,7 +2355,9 @@ xfs_attr_leaf_newentsize(int namelen, int valuelen, int blocksize, int *local)
2337 * Copy out attribute list entries for attr_list(), for leaf attribute lists. 2355 * Copy out attribute list entries for attr_list(), for leaf attribute lists.
2338 */ 2356 */
2339int 2357int
2340xfs_attr_leaf_list_int(xfs_dabuf_t *bp, xfs_attr_list_context_t *context) 2358xfs_attr_leaf_list_int(
2359 struct xfs_buf *bp,
2360 xfs_attr_list_context_t *context)
2341{ 2361{
2342 attrlist_cursor_kern_t *cursor; 2362 attrlist_cursor_kern_t *cursor;
2343 xfs_attr_leafblock_t *leaf; 2363 xfs_attr_leafblock_t *leaf;
@@ -2345,7 +2365,7 @@ xfs_attr_leaf_list_int(xfs_dabuf_t *bp, xfs_attr_list_context_t *context)
2345 int retval, i; 2365 int retval, i;
2346 2366
2347 ASSERT(bp != NULL); 2367 ASSERT(bp != NULL);
2348 leaf = bp->data; 2368 leaf = bp->b_addr;
2349 cursor = context->cursor; 2369 cursor = context->cursor;
2350 cursor->initted = 1; 2370 cursor->initted = 1;
2351 2371
@@ -2463,7 +2483,7 @@ xfs_attr_leaf_clearflag(xfs_da_args_t *args)
2463 xfs_attr_leafblock_t *leaf; 2483 xfs_attr_leafblock_t *leaf;
2464 xfs_attr_leaf_entry_t *entry; 2484 xfs_attr_leaf_entry_t *entry;
2465 xfs_attr_leaf_name_remote_t *name_rmt; 2485 xfs_attr_leaf_name_remote_t *name_rmt;
2466 xfs_dabuf_t *bp; 2486 struct xfs_buf *bp;
2467 int error; 2487 int error;
2468#ifdef DEBUG 2488#ifdef DEBUG
2469 xfs_attr_leaf_name_local_t *name_loc; 2489 xfs_attr_leaf_name_local_t *name_loc;
@@ -2482,7 +2502,7 @@ xfs_attr_leaf_clearflag(xfs_da_args_t *args)
2482 } 2502 }
2483 ASSERT(bp != NULL); 2503 ASSERT(bp != NULL);
2484 2504
2485 leaf = bp->data; 2505 leaf = bp->b_addr;
2486 ASSERT(leaf->hdr.info.magic == cpu_to_be16(XFS_ATTR_LEAF_MAGIC)); 2506 ASSERT(leaf->hdr.info.magic == cpu_to_be16(XFS_ATTR_LEAF_MAGIC));
2487 ASSERT(args->index < be16_to_cpu(leaf->hdr.count)); 2507 ASSERT(args->index < be16_to_cpu(leaf->hdr.count));
2488 ASSERT(args->index >= 0); 2508 ASSERT(args->index >= 0);
@@ -2505,7 +2525,7 @@ xfs_attr_leaf_clearflag(xfs_da_args_t *args)
2505#endif /* DEBUG */ 2525#endif /* DEBUG */
2506 2526
2507 entry->flags &= ~XFS_ATTR_INCOMPLETE; 2527 entry->flags &= ~XFS_ATTR_INCOMPLETE;
2508 xfs_da_log_buf(args->trans, bp, 2528 xfs_trans_log_buf(args->trans, bp,
2509 XFS_DA_LOGRANGE(leaf, entry, sizeof(*entry))); 2529 XFS_DA_LOGRANGE(leaf, entry, sizeof(*entry)));
2510 2530
2511 if (args->rmtblkno) { 2531 if (args->rmtblkno) {
@@ -2513,10 +2533,9 @@ xfs_attr_leaf_clearflag(xfs_da_args_t *args)
2513 name_rmt = xfs_attr_leaf_name_remote(leaf, args->index); 2533 name_rmt = xfs_attr_leaf_name_remote(leaf, args->index);
2514 name_rmt->valueblk = cpu_to_be32(args->rmtblkno); 2534 name_rmt->valueblk = cpu_to_be32(args->rmtblkno);
2515 name_rmt->valuelen = cpu_to_be32(args->valuelen); 2535 name_rmt->valuelen = cpu_to_be32(args->valuelen);
2516 xfs_da_log_buf(args->trans, bp, 2536 xfs_trans_log_buf(args->trans, bp,
2517 XFS_DA_LOGRANGE(leaf, name_rmt, sizeof(*name_rmt))); 2537 XFS_DA_LOGRANGE(leaf, name_rmt, sizeof(*name_rmt)));
2518 } 2538 }
2519 xfs_da_buf_done(bp);
2520 2539
2521 /* 2540 /*
2522 * Commit the flag value change and start the next trans in series. 2541 * Commit the flag value change and start the next trans in series.
@@ -2533,7 +2552,7 @@ xfs_attr_leaf_setflag(xfs_da_args_t *args)
2533 xfs_attr_leafblock_t *leaf; 2552 xfs_attr_leafblock_t *leaf;
2534 xfs_attr_leaf_entry_t *entry; 2553 xfs_attr_leaf_entry_t *entry;
2535 xfs_attr_leaf_name_remote_t *name_rmt; 2554 xfs_attr_leaf_name_remote_t *name_rmt;
2536 xfs_dabuf_t *bp; 2555 struct xfs_buf *bp;
2537 int error; 2556 int error;
2538 2557
2539 trace_xfs_attr_leaf_setflag(args); 2558 trace_xfs_attr_leaf_setflag(args);
@@ -2548,7 +2567,7 @@ xfs_attr_leaf_setflag(xfs_da_args_t *args)
2548 } 2567 }
2549 ASSERT(bp != NULL); 2568 ASSERT(bp != NULL);
2550 2569
2551 leaf = bp->data; 2570 leaf = bp->b_addr;
2552 ASSERT(leaf->hdr.info.magic == cpu_to_be16(XFS_ATTR_LEAF_MAGIC)); 2571 ASSERT(leaf->hdr.info.magic == cpu_to_be16(XFS_ATTR_LEAF_MAGIC));
2553 ASSERT(args->index < be16_to_cpu(leaf->hdr.count)); 2572 ASSERT(args->index < be16_to_cpu(leaf->hdr.count));
2554 ASSERT(args->index >= 0); 2573 ASSERT(args->index >= 0);
@@ -2556,16 +2575,15 @@ xfs_attr_leaf_setflag(xfs_da_args_t *args)
2556 2575
2557 ASSERT((entry->flags & XFS_ATTR_INCOMPLETE) == 0); 2576 ASSERT((entry->flags & XFS_ATTR_INCOMPLETE) == 0);
2558 entry->flags |= XFS_ATTR_INCOMPLETE; 2577 entry->flags |= XFS_ATTR_INCOMPLETE;
2559 xfs_da_log_buf(args->trans, bp, 2578 xfs_trans_log_buf(args->trans, bp,
2560 XFS_DA_LOGRANGE(leaf, entry, sizeof(*entry))); 2579 XFS_DA_LOGRANGE(leaf, entry, sizeof(*entry)));
2561 if ((entry->flags & XFS_ATTR_LOCAL) == 0) { 2580 if ((entry->flags & XFS_ATTR_LOCAL) == 0) {
2562 name_rmt = xfs_attr_leaf_name_remote(leaf, args->index); 2581 name_rmt = xfs_attr_leaf_name_remote(leaf, args->index);
2563 name_rmt->valueblk = 0; 2582 name_rmt->valueblk = 0;
2564 name_rmt->valuelen = 0; 2583 name_rmt->valuelen = 0;
2565 xfs_da_log_buf(args->trans, bp, 2584 xfs_trans_log_buf(args->trans, bp,
2566 XFS_DA_LOGRANGE(leaf, name_rmt, sizeof(*name_rmt))); 2585 XFS_DA_LOGRANGE(leaf, name_rmt, sizeof(*name_rmt)));
2567 } 2586 }
2568 xfs_da_buf_done(bp);
2569 2587
2570 /* 2588 /*
2571 * Commit the flag value change and start the next trans in series. 2589 * Commit the flag value change and start the next trans in series.
@@ -2586,7 +2604,7 @@ xfs_attr_leaf_flipflags(xfs_da_args_t *args)
2586 xfs_attr_leafblock_t *leaf1, *leaf2; 2604 xfs_attr_leafblock_t *leaf1, *leaf2;
2587 xfs_attr_leaf_entry_t *entry1, *entry2; 2605 xfs_attr_leaf_entry_t *entry1, *entry2;
2588 xfs_attr_leaf_name_remote_t *name_rmt; 2606 xfs_attr_leaf_name_remote_t *name_rmt;
2589 xfs_dabuf_t *bp1, *bp2; 2607 struct xfs_buf *bp1, *bp2;
2590 int error; 2608 int error;
2591#ifdef DEBUG 2609#ifdef DEBUG
2592 xfs_attr_leaf_name_local_t *name_loc; 2610 xfs_attr_leaf_name_local_t *name_loc;
@@ -2620,13 +2638,13 @@ xfs_attr_leaf_flipflags(xfs_da_args_t *args)
2620 bp2 = bp1; 2638 bp2 = bp1;
2621 } 2639 }
2622 2640
2623 leaf1 = bp1->data; 2641 leaf1 = bp1->b_addr;
2624 ASSERT(leaf1->hdr.info.magic == cpu_to_be16(XFS_ATTR_LEAF_MAGIC)); 2642 ASSERT(leaf1->hdr.info.magic == cpu_to_be16(XFS_ATTR_LEAF_MAGIC));
2625 ASSERT(args->index < be16_to_cpu(leaf1->hdr.count)); 2643 ASSERT(args->index < be16_to_cpu(leaf1->hdr.count));
2626 ASSERT(args->index >= 0); 2644 ASSERT(args->index >= 0);
2627 entry1 = &leaf1->entries[ args->index ]; 2645 entry1 = &leaf1->entries[ args->index ];
2628 2646
2629 leaf2 = bp2->data; 2647 leaf2 = bp2->b_addr;
2630 ASSERT(leaf2->hdr.info.magic == cpu_to_be16(XFS_ATTR_LEAF_MAGIC)); 2648 ASSERT(leaf2->hdr.info.magic == cpu_to_be16(XFS_ATTR_LEAF_MAGIC));
2631 ASSERT(args->index2 < be16_to_cpu(leaf2->hdr.count)); 2649 ASSERT(args->index2 < be16_to_cpu(leaf2->hdr.count));
2632 ASSERT(args->index2 >= 0); 2650 ASSERT(args->index2 >= 0);
@@ -2660,30 +2678,27 @@ xfs_attr_leaf_flipflags(xfs_da_args_t *args)
2660 ASSERT((entry2->flags & XFS_ATTR_INCOMPLETE) == 0); 2678 ASSERT((entry2->flags & XFS_ATTR_INCOMPLETE) == 0);
2661 2679
2662 entry1->flags &= ~XFS_ATTR_INCOMPLETE; 2680 entry1->flags &= ~XFS_ATTR_INCOMPLETE;
2663 xfs_da_log_buf(args->trans, bp1, 2681 xfs_trans_log_buf(args->trans, bp1,
2664 XFS_DA_LOGRANGE(leaf1, entry1, sizeof(*entry1))); 2682 XFS_DA_LOGRANGE(leaf1, entry1, sizeof(*entry1)));
2665 if (args->rmtblkno) { 2683 if (args->rmtblkno) {
2666 ASSERT((entry1->flags & XFS_ATTR_LOCAL) == 0); 2684 ASSERT((entry1->flags & XFS_ATTR_LOCAL) == 0);
2667 name_rmt = xfs_attr_leaf_name_remote(leaf1, args->index); 2685 name_rmt = xfs_attr_leaf_name_remote(leaf1, args->index);
2668 name_rmt->valueblk = cpu_to_be32(args->rmtblkno); 2686 name_rmt->valueblk = cpu_to_be32(args->rmtblkno);
2669 name_rmt->valuelen = cpu_to_be32(args->valuelen); 2687 name_rmt->valuelen = cpu_to_be32(args->valuelen);
2670 xfs_da_log_buf(args->trans, bp1, 2688 xfs_trans_log_buf(args->trans, bp1,
2671 XFS_DA_LOGRANGE(leaf1, name_rmt, sizeof(*name_rmt))); 2689 XFS_DA_LOGRANGE(leaf1, name_rmt, sizeof(*name_rmt)));
2672 } 2690 }
2673 2691
2674 entry2->flags |= XFS_ATTR_INCOMPLETE; 2692 entry2->flags |= XFS_ATTR_INCOMPLETE;
2675 xfs_da_log_buf(args->trans, bp2, 2693 xfs_trans_log_buf(args->trans, bp2,
2676 XFS_DA_LOGRANGE(leaf2, entry2, sizeof(*entry2))); 2694 XFS_DA_LOGRANGE(leaf2, entry2, sizeof(*entry2)));
2677 if ((entry2->flags & XFS_ATTR_LOCAL) == 0) { 2695 if ((entry2->flags & XFS_ATTR_LOCAL) == 0) {
2678 name_rmt = xfs_attr_leaf_name_remote(leaf2, args->index2); 2696 name_rmt = xfs_attr_leaf_name_remote(leaf2, args->index2);
2679 name_rmt->valueblk = 0; 2697 name_rmt->valueblk = 0;
2680 name_rmt->valuelen = 0; 2698 name_rmt->valuelen = 0;
2681 xfs_da_log_buf(args->trans, bp2, 2699 xfs_trans_log_buf(args->trans, bp2,
2682 XFS_DA_LOGRANGE(leaf2, name_rmt, sizeof(*name_rmt))); 2700 XFS_DA_LOGRANGE(leaf2, name_rmt, sizeof(*name_rmt)));
2683 } 2701 }
2684 xfs_da_buf_done(bp1);
2685 if (bp1 != bp2)
2686 xfs_da_buf_done(bp2);
2687 2702
2688 /* 2703 /*
2689 * Commit the flag value change and start the next trans in series. 2704 * Commit the flag value change and start the next trans in series.
@@ -2706,7 +2721,7 @@ xfs_attr_root_inactive(xfs_trans_t **trans, xfs_inode_t *dp)
2706{ 2721{
2707 xfs_da_blkinfo_t *info; 2722 xfs_da_blkinfo_t *info;
2708 xfs_daddr_t blkno; 2723 xfs_daddr_t blkno;
2709 xfs_dabuf_t *bp; 2724 struct xfs_buf *bp;
2710 int error; 2725 int error;
2711 2726
2712 /* 2727 /*
@@ -2718,20 +2733,20 @@ xfs_attr_root_inactive(xfs_trans_t **trans, xfs_inode_t *dp)
2718 error = xfs_da_read_buf(*trans, dp, 0, -1, &bp, XFS_ATTR_FORK); 2733 error = xfs_da_read_buf(*trans, dp, 0, -1, &bp, XFS_ATTR_FORK);
2719 if (error) 2734 if (error)
2720 return(error); 2735 return(error);
2721 blkno = xfs_da_blkno(bp); 2736 blkno = XFS_BUF_ADDR(bp);
2722 2737
2723 /* 2738 /*
2724 * Invalidate the tree, even if the "tree" is only a single leaf block. 2739 * Invalidate the tree, even if the "tree" is only a single leaf block.
2725 * This is a depth-first traversal! 2740 * This is a depth-first traversal!
2726 */ 2741 */
2727 info = bp->data; 2742 info = bp->b_addr;
2728 if (info->magic == cpu_to_be16(XFS_DA_NODE_MAGIC)) { 2743 if (info->magic == cpu_to_be16(XFS_DA_NODE_MAGIC)) {
2729 error = xfs_attr_node_inactive(trans, dp, bp, 1); 2744 error = xfs_attr_node_inactive(trans, dp, bp, 1);
2730 } else if (info->magic == cpu_to_be16(XFS_ATTR_LEAF_MAGIC)) { 2745 } else if (info->magic == cpu_to_be16(XFS_ATTR_LEAF_MAGIC)) {
2731 error = xfs_attr_leaf_inactive(trans, dp, bp); 2746 error = xfs_attr_leaf_inactive(trans, dp, bp);
2732 } else { 2747 } else {
2733 error = XFS_ERROR(EIO); 2748 error = XFS_ERROR(EIO);
2734 xfs_da_brelse(*trans, bp); 2749 xfs_trans_brelse(*trans, bp);
2735 } 2750 }
2736 if (error) 2751 if (error)
2737 return(error); 2752 return(error);
@@ -2742,7 +2757,7 @@ xfs_attr_root_inactive(xfs_trans_t **trans, xfs_inode_t *dp)
2742 error = xfs_da_get_buf(*trans, dp, 0, blkno, &bp, XFS_ATTR_FORK); 2757 error = xfs_da_get_buf(*trans, dp, 0, blkno, &bp, XFS_ATTR_FORK);
2743 if (error) 2758 if (error)
2744 return(error); 2759 return(error);
2745 xfs_da_binval(*trans, bp); /* remove from cache */ 2760 xfs_trans_binval(*trans, bp); /* remove from cache */
2746 /* 2761 /*
2747 * Commit the invalidate and start the next transaction. 2762 * Commit the invalidate and start the next transaction.
2748 */ 2763 */
@@ -2756,34 +2771,37 @@ xfs_attr_root_inactive(xfs_trans_t **trans, xfs_inode_t *dp)
2756 * We're doing a depth-first traversal in order to invalidate everything. 2771 * We're doing a depth-first traversal in order to invalidate everything.
2757 */ 2772 */
2758STATIC int 2773STATIC int
2759xfs_attr_node_inactive(xfs_trans_t **trans, xfs_inode_t *dp, xfs_dabuf_t *bp, 2774xfs_attr_node_inactive(
2760 int level) 2775 struct xfs_trans **trans,
2776 struct xfs_inode *dp,
2777 struct xfs_buf *bp,
2778 int level)
2761{ 2779{
2762 xfs_da_blkinfo_t *info; 2780 xfs_da_blkinfo_t *info;
2763 xfs_da_intnode_t *node; 2781 xfs_da_intnode_t *node;
2764 xfs_dablk_t child_fsb; 2782 xfs_dablk_t child_fsb;
2765 xfs_daddr_t parent_blkno, child_blkno; 2783 xfs_daddr_t parent_blkno, child_blkno;
2766 int error, count, i; 2784 int error, count, i;
2767 xfs_dabuf_t *child_bp; 2785 struct xfs_buf *child_bp;
2768 2786
2769 /* 2787 /*
2770 * Since this code is recursive (gasp!) we must protect ourselves. 2788 * Since this code is recursive (gasp!) we must protect ourselves.
2771 */ 2789 */
2772 if (level > XFS_DA_NODE_MAXDEPTH) { 2790 if (level > XFS_DA_NODE_MAXDEPTH) {
2773 xfs_da_brelse(*trans, bp); /* no locks for later trans */ 2791 xfs_trans_brelse(*trans, bp); /* no locks for later trans */
2774 return(XFS_ERROR(EIO)); 2792 return(XFS_ERROR(EIO));
2775 } 2793 }
2776 2794
2777 node = bp->data; 2795 node = bp->b_addr;
2778 ASSERT(node->hdr.info.magic == cpu_to_be16(XFS_DA_NODE_MAGIC)); 2796 ASSERT(node->hdr.info.magic == cpu_to_be16(XFS_DA_NODE_MAGIC));
2779 parent_blkno = xfs_da_blkno(bp); /* save for re-read later */ 2797 parent_blkno = XFS_BUF_ADDR(bp); /* save for re-read later */
2780 count = be16_to_cpu(node->hdr.count); 2798 count = be16_to_cpu(node->hdr.count);
2781 if (!count) { 2799 if (!count) {
2782 xfs_da_brelse(*trans, bp); 2800 xfs_trans_brelse(*trans, bp);
2783 return(0); 2801 return(0);
2784 } 2802 }
2785 child_fsb = be32_to_cpu(node->btree[0].before); 2803 child_fsb = be32_to_cpu(node->btree[0].before);
2786 xfs_da_brelse(*trans, bp); /* no locks for later trans */ 2804 xfs_trans_brelse(*trans, bp); /* no locks for later trans */
2787 2805
2788 /* 2806 /*
2789 * If this is the node level just above the leaves, simply loop 2807 * If this is the node level just above the leaves, simply loop
@@ -2803,12 +2821,12 @@ xfs_attr_node_inactive(xfs_trans_t **trans, xfs_inode_t *dp, xfs_dabuf_t *bp,
2803 return(error); 2821 return(error);
2804 if (child_bp) { 2822 if (child_bp) {
2805 /* save for re-read later */ 2823 /* save for re-read later */
2806 child_blkno = xfs_da_blkno(child_bp); 2824 child_blkno = XFS_BUF_ADDR(child_bp);
2807 2825
2808 /* 2826 /*
2809 * Invalidate the subtree, however we have to. 2827 * Invalidate the subtree, however we have to.
2810 */ 2828 */
2811 info = child_bp->data; 2829 info = child_bp->b_addr;
2812 if (info->magic == cpu_to_be16(XFS_DA_NODE_MAGIC)) { 2830 if (info->magic == cpu_to_be16(XFS_DA_NODE_MAGIC)) {
2813 error = xfs_attr_node_inactive(trans, dp, 2831 error = xfs_attr_node_inactive(trans, dp,
2814 child_bp, level+1); 2832 child_bp, level+1);
@@ -2817,7 +2835,7 @@ xfs_attr_node_inactive(xfs_trans_t **trans, xfs_inode_t *dp, xfs_dabuf_t *bp,
2817 child_bp); 2835 child_bp);
2818 } else { 2836 } else {
2819 error = XFS_ERROR(EIO); 2837 error = XFS_ERROR(EIO);
2820 xfs_da_brelse(*trans, child_bp); 2838 xfs_trans_brelse(*trans, child_bp);
2821 } 2839 }
2822 if (error) 2840 if (error)
2823 return(error); 2841 return(error);
@@ -2830,7 +2848,7 @@ xfs_attr_node_inactive(xfs_trans_t **trans, xfs_inode_t *dp, xfs_dabuf_t *bp,
2830 &child_bp, XFS_ATTR_FORK); 2848 &child_bp, XFS_ATTR_FORK);
2831 if (error) 2849 if (error)
2832 return(error); 2850 return(error);
2833 xfs_da_binval(*trans, child_bp); 2851 xfs_trans_binval(*trans, child_bp);
2834 } 2852 }
2835 2853
2836 /* 2854 /*
@@ -2843,7 +2861,7 @@ xfs_attr_node_inactive(xfs_trans_t **trans, xfs_inode_t *dp, xfs_dabuf_t *bp,
2843 if (error) 2861 if (error)
2844 return(error); 2862 return(error);
2845 child_fsb = be32_to_cpu(node->btree[i+1].before); 2863 child_fsb = be32_to_cpu(node->btree[i+1].before);
2846 xfs_da_brelse(*trans, bp); 2864 xfs_trans_brelse(*trans, bp);
2847 } 2865 }
2848 /* 2866 /*
2849 * Atomically commit the whole invalidate stuff. 2867 * Atomically commit the whole invalidate stuff.
@@ -2863,7 +2881,10 @@ xfs_attr_node_inactive(xfs_trans_t **trans, xfs_inode_t *dp, xfs_dabuf_t *bp,
2863 * caught holding something that the logging code wants to flush to disk. 2881 * caught holding something that the logging code wants to flush to disk.
2864 */ 2882 */
2865STATIC int 2883STATIC int
2866xfs_attr_leaf_inactive(xfs_trans_t **trans, xfs_inode_t *dp, xfs_dabuf_t *bp) 2884xfs_attr_leaf_inactive(
2885 struct xfs_trans **trans,
2886 struct xfs_inode *dp,
2887 struct xfs_buf *bp)
2867{ 2888{
2868 xfs_attr_leafblock_t *leaf; 2889 xfs_attr_leafblock_t *leaf;
2869 xfs_attr_leaf_entry_t *entry; 2890 xfs_attr_leaf_entry_t *entry;
@@ -2871,7 +2892,7 @@ xfs_attr_leaf_inactive(xfs_trans_t **trans, xfs_inode_t *dp, xfs_dabuf_t *bp)
2871 xfs_attr_inactive_list_t *list, *lp; 2892 xfs_attr_inactive_list_t *list, *lp;
2872 int error, count, size, tmp, i; 2893 int error, count, size, tmp, i;
2873 2894
2874 leaf = bp->data; 2895 leaf = bp->b_addr;
2875 ASSERT(leaf->hdr.info.magic == cpu_to_be16(XFS_ATTR_LEAF_MAGIC)); 2896 ASSERT(leaf->hdr.info.magic == cpu_to_be16(XFS_ATTR_LEAF_MAGIC));
2876 2897
2877 /* 2898 /*
@@ -2892,7 +2913,7 @@ xfs_attr_leaf_inactive(xfs_trans_t **trans, xfs_inode_t *dp, xfs_dabuf_t *bp)
2892 * If there are no "remote" values, we're done. 2913 * If there are no "remote" values, we're done.
2893 */ 2914 */
2894 if (count == 0) { 2915 if (count == 0) {
2895 xfs_da_brelse(*trans, bp); 2916 xfs_trans_brelse(*trans, bp);
2896 return(0); 2917 return(0);
2897 } 2918 }
2898 2919
@@ -2919,7 +2940,7 @@ xfs_attr_leaf_inactive(xfs_trans_t **trans, xfs_inode_t *dp, xfs_dabuf_t *bp)
2919 } 2940 }
2920 } 2941 }
2921 } 2942 }
2922 xfs_da_brelse(*trans, bp); /* unlock for trans. in freextent() */ 2943 xfs_trans_brelse(*trans, bp); /* unlock for trans. in freextent() */
2923 2944
2924 /* 2945 /*
2925 * Invalidate each of the "remote" value extents. 2946 * Invalidate each of the "remote" value extents.