aboutsummaryrefslogtreecommitdiffstats
path: root/fs
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
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')
-rw-r--r--fs/xfs/xfs_attr.c78
-rw-r--r--fs/xfs/xfs_attr_leaf.c255
-rw-r--r--fs/xfs/xfs_attr_leaf.h21
-rw-r--r--fs/xfs/xfs_da_btree.c337
-rw-r--r--fs/xfs/xfs_da_btree.h32
-rw-r--r--fs/xfs/xfs_dir2.c4
-rw-r--r--fs/xfs/xfs_dir2_block.c118
-rw-r--r--fs/xfs/xfs_dir2_data.c50
-rw-r--r--fs/xfs/xfs_dir2_leaf.c191
-rw-r--r--fs/xfs/xfs_dir2_node.c236
-rw-r--r--fs/xfs/xfs_dir2_priv.h46
-rw-r--r--fs/xfs/xfs_dir2_sf.c4
-rw-r--r--fs/xfs/xfs_super.c9
13 files changed, 602 insertions, 779 deletions
diff --git a/fs/xfs/xfs_attr.c b/fs/xfs/xfs_attr.c
index a17ff01b5adf..0ca1f0be62d2 100644
--- a/fs/xfs/xfs_attr.c
+++ b/fs/xfs/xfs_attr.c
@@ -893,7 +893,7 @@ STATIC int
893xfs_attr_leaf_addname(xfs_da_args_t *args) 893xfs_attr_leaf_addname(xfs_da_args_t *args)
894{ 894{
895 xfs_inode_t *dp; 895 xfs_inode_t *dp;
896 xfs_dabuf_t *bp; 896 struct xfs_buf *bp;
897 int retval, error, committed, forkoff; 897 int retval, error, committed, forkoff;
898 898
899 trace_xfs_attr_leaf_addname(args); 899 trace_xfs_attr_leaf_addname(args);
@@ -915,11 +915,11 @@ xfs_attr_leaf_addname(xfs_da_args_t *args)
915 */ 915 */
916 retval = xfs_attr_leaf_lookup_int(bp, args); 916 retval = xfs_attr_leaf_lookup_int(bp, args);
917 if ((args->flags & ATTR_REPLACE) && (retval == ENOATTR)) { 917 if ((args->flags & ATTR_REPLACE) && (retval == ENOATTR)) {
918 xfs_da_brelse(args->trans, bp); 918 xfs_trans_brelse(args->trans, bp);
919 return(retval); 919 return(retval);
920 } else if (retval == EEXIST) { 920 } else if (retval == EEXIST) {
921 if (args->flags & ATTR_CREATE) { /* pure create op */ 921 if (args->flags & ATTR_CREATE) { /* pure create op */
922 xfs_da_brelse(args->trans, bp); 922 xfs_trans_brelse(args->trans, bp);
923 return(retval); 923 return(retval);
924 } 924 }
925 925
@@ -937,7 +937,6 @@ xfs_attr_leaf_addname(xfs_da_args_t *args)
937 * if required. 937 * if required.
938 */ 938 */
939 retval = xfs_attr_leaf_add(bp, args); 939 retval = xfs_attr_leaf_add(bp, args);
940 xfs_da_buf_done(bp);
941 if (retval == ENOSPC) { 940 if (retval == ENOSPC) {
942 /* 941 /*
943 * Promote the attribute list to the Btree format, then 942 * Promote the attribute list to the Btree format, then
@@ -1065,8 +1064,7 @@ xfs_attr_leaf_addname(xfs_da_args_t *args)
1065 */ 1064 */
1066 if (committed) 1065 if (committed)
1067 xfs_trans_ijoin(args->trans, dp, 0); 1066 xfs_trans_ijoin(args->trans, dp, 0);
1068 } else 1067 }
1069 xfs_da_buf_done(bp);
1070 1068
1071 /* 1069 /*
1072 * Commit the remove and start the next trans in series. 1070 * Commit the remove and start the next trans in series.
@@ -1092,7 +1090,7 @@ STATIC int
1092xfs_attr_leaf_removename(xfs_da_args_t *args) 1090xfs_attr_leaf_removename(xfs_da_args_t *args)
1093{ 1091{
1094 xfs_inode_t *dp; 1092 xfs_inode_t *dp;
1095 xfs_dabuf_t *bp; 1093 struct xfs_buf *bp;
1096 int error, committed, forkoff; 1094 int error, committed, forkoff;
1097 1095
1098 trace_xfs_attr_leaf_removename(args); 1096 trace_xfs_attr_leaf_removename(args);
@@ -1111,7 +1109,7 @@ xfs_attr_leaf_removename(xfs_da_args_t *args)
1111 ASSERT(bp != NULL); 1109 ASSERT(bp != NULL);
1112 error = xfs_attr_leaf_lookup_int(bp, args); 1110 error = xfs_attr_leaf_lookup_int(bp, args);
1113 if (error == ENOATTR) { 1111 if (error == ENOATTR) {
1114 xfs_da_brelse(args->trans, bp); 1112 xfs_trans_brelse(args->trans, bp);
1115 return(error); 1113 return(error);
1116 } 1114 }
1117 1115
@@ -1141,8 +1139,7 @@ xfs_attr_leaf_removename(xfs_da_args_t *args)
1141 */ 1139 */
1142 if (committed) 1140 if (committed)
1143 xfs_trans_ijoin(args->trans, dp, 0); 1141 xfs_trans_ijoin(args->trans, dp, 0);
1144 } else 1142 }
1145 xfs_da_buf_done(bp);
1146 return(0); 1143 return(0);
1147} 1144}
1148 1145
@@ -1155,7 +1152,7 @@ xfs_attr_leaf_removename(xfs_da_args_t *args)
1155STATIC int 1152STATIC int
1156xfs_attr_leaf_get(xfs_da_args_t *args) 1153xfs_attr_leaf_get(xfs_da_args_t *args)
1157{ 1154{
1158 xfs_dabuf_t *bp; 1155 struct xfs_buf *bp;
1159 int error; 1156 int error;
1160 1157
1161 args->blkno = 0; 1158 args->blkno = 0;
@@ -1167,11 +1164,11 @@ xfs_attr_leaf_get(xfs_da_args_t *args)
1167 1164
1168 error = xfs_attr_leaf_lookup_int(bp, args); 1165 error = xfs_attr_leaf_lookup_int(bp, args);
1169 if (error != EEXIST) { 1166 if (error != EEXIST) {
1170 xfs_da_brelse(args->trans, bp); 1167 xfs_trans_brelse(args->trans, bp);
1171 return(error); 1168 return(error);
1172 } 1169 }
1173 error = xfs_attr_leaf_getvalue(bp, args); 1170 error = xfs_attr_leaf_getvalue(bp, args);
1174 xfs_da_brelse(args->trans, bp); 1171 xfs_trans_brelse(args->trans, bp);
1175 if (!error && (args->rmtblkno > 0) && !(args->flags & ATTR_KERNOVAL)) { 1172 if (!error && (args->rmtblkno > 0) && !(args->flags & ATTR_KERNOVAL)) {
1176 error = xfs_attr_rmtval_get(args); 1173 error = xfs_attr_rmtval_get(args);
1177 } 1174 }
@@ -1186,23 +1183,23 @@ xfs_attr_leaf_list(xfs_attr_list_context_t *context)
1186{ 1183{
1187 xfs_attr_leafblock_t *leaf; 1184 xfs_attr_leafblock_t *leaf;
1188 int error; 1185 int error;
1189 xfs_dabuf_t *bp; 1186 struct xfs_buf *bp;
1190 1187
1191 context->cursor->blkno = 0; 1188 context->cursor->blkno = 0;
1192 error = xfs_da_read_buf(NULL, context->dp, 0, -1, &bp, XFS_ATTR_FORK); 1189 error = xfs_da_read_buf(NULL, context->dp, 0, -1, &bp, XFS_ATTR_FORK);
1193 if (error) 1190 if (error)
1194 return XFS_ERROR(error); 1191 return XFS_ERROR(error);
1195 ASSERT(bp != NULL); 1192 ASSERT(bp != NULL);
1196 leaf = bp->data; 1193 leaf = bp->b_addr;
1197 if (unlikely(leaf->hdr.info.magic != cpu_to_be16(XFS_ATTR_LEAF_MAGIC))) { 1194 if (unlikely(leaf->hdr.info.magic != cpu_to_be16(XFS_ATTR_LEAF_MAGIC))) {
1198 XFS_CORRUPTION_ERROR("xfs_attr_leaf_list", XFS_ERRLEVEL_LOW, 1195 XFS_CORRUPTION_ERROR("xfs_attr_leaf_list", XFS_ERRLEVEL_LOW,
1199 context->dp->i_mount, leaf); 1196 context->dp->i_mount, leaf);
1200 xfs_da_brelse(NULL, bp); 1197 xfs_trans_brelse(NULL, bp);
1201 return XFS_ERROR(EFSCORRUPTED); 1198 return XFS_ERROR(EFSCORRUPTED);
1202 } 1199 }
1203 1200
1204 error = xfs_attr_leaf_list_int(bp, context); 1201 error = xfs_attr_leaf_list_int(bp, context);
1205 xfs_da_brelse(NULL, bp); 1202 xfs_trans_brelse(NULL, bp);
1206 return XFS_ERROR(error); 1203 return XFS_ERROR(error);
1207} 1204}
1208 1205
@@ -1489,7 +1486,7 @@ xfs_attr_node_removename(xfs_da_args_t *args)
1489 xfs_da_state_t *state; 1486 xfs_da_state_t *state;
1490 xfs_da_state_blk_t *blk; 1487 xfs_da_state_blk_t *blk;
1491 xfs_inode_t *dp; 1488 xfs_inode_t *dp;
1492 xfs_dabuf_t *bp; 1489 struct xfs_buf *bp;
1493 int retval, error, committed, forkoff; 1490 int retval, error, committed, forkoff;
1494 1491
1495 trace_xfs_attr_node_removename(args); 1492 trace_xfs_attr_node_removename(args);
@@ -1601,14 +1598,13 @@ xfs_attr_node_removename(xfs_da_args_t *args)
1601 */ 1598 */
1602 ASSERT(state->path.active == 1); 1599 ASSERT(state->path.active == 1);
1603 ASSERT(state->path.blk[0].bp); 1600 ASSERT(state->path.blk[0].bp);
1604 xfs_da_buf_done(state->path.blk[0].bp);
1605 state->path.blk[0].bp = NULL; 1601 state->path.blk[0].bp = NULL;
1606 1602
1607 error = xfs_da_read_buf(args->trans, args->dp, 0, -1, &bp, 1603 error = xfs_da_read_buf(args->trans, args->dp, 0, -1, &bp,
1608 XFS_ATTR_FORK); 1604 XFS_ATTR_FORK);
1609 if (error) 1605 if (error)
1610 goto out; 1606 goto out;
1611 ASSERT((((xfs_attr_leafblock_t *)bp->data)->hdr.info.magic) == 1607 ASSERT((((xfs_attr_leafblock_t *)bp->b_addr)->hdr.info.magic) ==
1612 cpu_to_be16(XFS_ATTR_LEAF_MAGIC)); 1608 cpu_to_be16(XFS_ATTR_LEAF_MAGIC));
1613 1609
1614 if ((forkoff = xfs_attr_shortform_allfit(bp, dp))) { 1610 if ((forkoff = xfs_attr_shortform_allfit(bp, dp))) {
@@ -1635,7 +1631,7 @@ xfs_attr_node_removename(xfs_da_args_t *args)
1635 if (committed) 1631 if (committed)
1636 xfs_trans_ijoin(args->trans, dp, 0); 1632 xfs_trans_ijoin(args->trans, dp, 0);
1637 } else 1633 } else
1638 xfs_da_brelse(args->trans, bp); 1634 xfs_trans_brelse(args->trans, bp);
1639 } 1635 }
1640 error = 0; 1636 error = 0;
1641 1637
@@ -1665,8 +1661,7 @@ xfs_attr_fillstate(xfs_da_state_t *state)
1665 ASSERT((path->active >= 0) && (path->active < XFS_DA_NODE_MAXDEPTH)); 1661 ASSERT((path->active >= 0) && (path->active < XFS_DA_NODE_MAXDEPTH));
1666 for (blk = path->blk, level = 0; level < path->active; blk++, level++) { 1662 for (blk = path->blk, level = 0; level < path->active; blk++, level++) {
1667 if (blk->bp) { 1663 if (blk->bp) {
1668 blk->disk_blkno = xfs_da_blkno(blk->bp); 1664 blk->disk_blkno = XFS_BUF_ADDR(blk->bp);
1669 xfs_da_buf_done(blk->bp);
1670 blk->bp = NULL; 1665 blk->bp = NULL;
1671 } else { 1666 } else {
1672 blk->disk_blkno = 0; 1667 blk->disk_blkno = 0;
@@ -1681,8 +1676,7 @@ xfs_attr_fillstate(xfs_da_state_t *state)
1681 ASSERT((path->active >= 0) && (path->active < XFS_DA_NODE_MAXDEPTH)); 1676 ASSERT((path->active >= 0) && (path->active < XFS_DA_NODE_MAXDEPTH));
1682 for (blk = path->blk, level = 0; level < path->active; blk++, level++) { 1677 for (blk = path->blk, level = 0; level < path->active; blk++, level++) {
1683 if (blk->bp) { 1678 if (blk->bp) {
1684 blk->disk_blkno = xfs_da_blkno(blk->bp); 1679 blk->disk_blkno = XFS_BUF_ADDR(blk->bp);
1685 xfs_da_buf_done(blk->bp);
1686 blk->bp = NULL; 1680 blk->bp = NULL;
1687 } else { 1681 } else {
1688 blk->disk_blkno = 0; 1682 blk->disk_blkno = 0;
@@ -1792,7 +1786,7 @@ xfs_attr_node_get(xfs_da_args_t *args)
1792 * If not in a transaction, we have to release all the buffers. 1786 * If not in a transaction, we have to release all the buffers.
1793 */ 1787 */
1794 for (i = 0; i < state->path.active; i++) { 1788 for (i = 0; i < state->path.active; i++) {
1795 xfs_da_brelse(args->trans, state->path.blk[i].bp); 1789 xfs_trans_brelse(args->trans, state->path.blk[i].bp);
1796 state->path.blk[i].bp = NULL; 1790 state->path.blk[i].bp = NULL;
1797 } 1791 }
1798 1792
@@ -1808,7 +1802,7 @@ xfs_attr_node_list(xfs_attr_list_context_t *context)
1808 xfs_da_intnode_t *node; 1802 xfs_da_intnode_t *node;
1809 xfs_da_node_entry_t *btree; 1803 xfs_da_node_entry_t *btree;
1810 int error, i; 1804 int error, i;
1811 xfs_dabuf_t *bp; 1805 struct xfs_buf *bp;
1812 1806
1813 cursor = context->cursor; 1807 cursor = context->cursor;
1814 cursor->initted = 1; 1808 cursor->initted = 1;
@@ -1825,30 +1819,30 @@ xfs_attr_node_list(xfs_attr_list_context_t *context)
1825 if ((error != 0) && (error != EFSCORRUPTED)) 1819 if ((error != 0) && (error != EFSCORRUPTED))
1826 return(error); 1820 return(error);
1827 if (bp) { 1821 if (bp) {
1828 node = bp->data; 1822 node = bp->b_addr;
1829 switch (be16_to_cpu(node->hdr.info.magic)) { 1823 switch (be16_to_cpu(node->hdr.info.magic)) {
1830 case XFS_DA_NODE_MAGIC: 1824 case XFS_DA_NODE_MAGIC:
1831 trace_xfs_attr_list_wrong_blk(context); 1825 trace_xfs_attr_list_wrong_blk(context);
1832 xfs_da_brelse(NULL, bp); 1826 xfs_trans_brelse(NULL, bp);
1833 bp = NULL; 1827 bp = NULL;
1834 break; 1828 break;
1835 case XFS_ATTR_LEAF_MAGIC: 1829 case XFS_ATTR_LEAF_MAGIC:
1836 leaf = bp->data; 1830 leaf = bp->b_addr;
1837 if (cursor->hashval > be32_to_cpu(leaf->entries[ 1831 if (cursor->hashval > be32_to_cpu(leaf->entries[
1838 be16_to_cpu(leaf->hdr.count)-1].hashval)) { 1832 be16_to_cpu(leaf->hdr.count)-1].hashval)) {
1839 trace_xfs_attr_list_wrong_blk(context); 1833 trace_xfs_attr_list_wrong_blk(context);
1840 xfs_da_brelse(NULL, bp); 1834 xfs_trans_brelse(NULL, bp);
1841 bp = NULL; 1835 bp = NULL;
1842 } else if (cursor->hashval <= 1836 } else if (cursor->hashval <=
1843 be32_to_cpu(leaf->entries[0].hashval)) { 1837 be32_to_cpu(leaf->entries[0].hashval)) {
1844 trace_xfs_attr_list_wrong_blk(context); 1838 trace_xfs_attr_list_wrong_blk(context);
1845 xfs_da_brelse(NULL, bp); 1839 xfs_trans_brelse(NULL, bp);
1846 bp = NULL; 1840 bp = NULL;
1847 } 1841 }
1848 break; 1842 break;
1849 default: 1843 default:
1850 trace_xfs_attr_list_wrong_blk(context); 1844 trace_xfs_attr_list_wrong_blk(context);
1851 xfs_da_brelse(NULL, bp); 1845 xfs_trans_brelse(NULL, bp);
1852 bp = NULL; 1846 bp = NULL;
1853 } 1847 }
1854 } 1848 }
@@ -1873,7 +1867,7 @@ xfs_attr_node_list(xfs_attr_list_context_t *context)
1873 context->dp->i_mount); 1867 context->dp->i_mount);
1874 return(XFS_ERROR(EFSCORRUPTED)); 1868 return(XFS_ERROR(EFSCORRUPTED));
1875 } 1869 }
1876 node = bp->data; 1870 node = bp->b_addr;
1877 if (node->hdr.info.magic == 1871 if (node->hdr.info.magic ==
1878 cpu_to_be16(XFS_ATTR_LEAF_MAGIC)) 1872 cpu_to_be16(XFS_ATTR_LEAF_MAGIC))
1879 break; 1873 break;
@@ -1883,7 +1877,7 @@ xfs_attr_node_list(xfs_attr_list_context_t *context)
1883 XFS_ERRLEVEL_LOW, 1877 XFS_ERRLEVEL_LOW,
1884 context->dp->i_mount, 1878 context->dp->i_mount,
1885 node); 1879 node);
1886 xfs_da_brelse(NULL, bp); 1880 xfs_trans_brelse(NULL, bp);
1887 return(XFS_ERROR(EFSCORRUPTED)); 1881 return(XFS_ERROR(EFSCORRUPTED));
1888 } 1882 }
1889 btree = node->btree; 1883 btree = node->btree;
@@ -1898,10 +1892,10 @@ xfs_attr_node_list(xfs_attr_list_context_t *context)
1898 } 1892 }
1899 } 1893 }
1900 if (i == be16_to_cpu(node->hdr.count)) { 1894 if (i == be16_to_cpu(node->hdr.count)) {
1901 xfs_da_brelse(NULL, bp); 1895 xfs_trans_brelse(NULL, bp);
1902 return(0); 1896 return(0);
1903 } 1897 }
1904 xfs_da_brelse(NULL, bp); 1898 xfs_trans_brelse(NULL, bp);
1905 } 1899 }
1906 } 1900 }
1907 ASSERT(bp != NULL); 1901 ASSERT(bp != NULL);
@@ -1912,24 +1906,24 @@ xfs_attr_node_list(xfs_attr_list_context_t *context)
1912 * adding the information. 1906 * adding the information.
1913 */ 1907 */
1914 for (;;) { 1908 for (;;) {
1915 leaf = bp->data; 1909 leaf = bp->b_addr;
1916 if (unlikely(leaf->hdr.info.magic != 1910 if (unlikely(leaf->hdr.info.magic !=
1917 cpu_to_be16(XFS_ATTR_LEAF_MAGIC))) { 1911 cpu_to_be16(XFS_ATTR_LEAF_MAGIC))) {
1918 XFS_CORRUPTION_ERROR("xfs_attr_node_list(4)", 1912 XFS_CORRUPTION_ERROR("xfs_attr_node_list(4)",
1919 XFS_ERRLEVEL_LOW, 1913 XFS_ERRLEVEL_LOW,
1920 context->dp->i_mount, leaf); 1914 context->dp->i_mount, leaf);
1921 xfs_da_brelse(NULL, bp); 1915 xfs_trans_brelse(NULL, bp);
1922 return(XFS_ERROR(EFSCORRUPTED)); 1916 return(XFS_ERROR(EFSCORRUPTED));
1923 } 1917 }
1924 error = xfs_attr_leaf_list_int(bp, context); 1918 error = xfs_attr_leaf_list_int(bp, context);
1925 if (error) { 1919 if (error) {
1926 xfs_da_brelse(NULL, bp); 1920 xfs_trans_brelse(NULL, bp);
1927 return error; 1921 return error;
1928 } 1922 }
1929 if (context->seen_enough || leaf->hdr.info.forw == 0) 1923 if (context->seen_enough || leaf->hdr.info.forw == 0)
1930 break; 1924 break;
1931 cursor->blkno = be32_to_cpu(leaf->hdr.info.forw); 1925 cursor->blkno = be32_to_cpu(leaf->hdr.info.forw);
1932 xfs_da_brelse(NULL, bp); 1926 xfs_trans_brelse(NULL, bp);
1933 error = xfs_da_read_buf(NULL, context->dp, cursor->blkno, -1, 1927 error = xfs_da_read_buf(NULL, context->dp, cursor->blkno, -1,
1934 &bp, XFS_ATTR_FORK); 1928 &bp, XFS_ATTR_FORK);
1935 if (error) 1929 if (error)
@@ -1941,7 +1935,7 @@ xfs_attr_node_list(xfs_attr_list_context_t *context)
1941 return(XFS_ERROR(EFSCORRUPTED)); 1935 return(XFS_ERROR(EFSCORRUPTED));
1942 } 1936 }
1943 } 1937 }
1944 xfs_da_brelse(NULL, bp); 1938 xfs_trans_brelse(NULL, bp);
1945 return(0); 1939 return(0);
1946} 1940}
1947 1941
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.
diff --git a/fs/xfs/xfs_attr_leaf.h b/fs/xfs/xfs_attr_leaf.h
index 9c7d22fdcf4d..dea17722945e 100644
--- a/fs/xfs/xfs_attr_leaf.h
+++ b/fs/xfs/xfs_attr_leaf.h
@@ -31,7 +31,6 @@
31struct attrlist; 31struct attrlist;
32struct attrlist_cursor_kern; 32struct attrlist_cursor_kern;
33struct xfs_attr_list_context; 33struct xfs_attr_list_context;
34struct xfs_dabuf;
35struct xfs_da_args; 34struct xfs_da_args;
36struct xfs_da_state; 35struct xfs_da_state;
37struct xfs_da_state_blk; 36struct xfs_da_state_blk;
@@ -215,7 +214,7 @@ int xfs_attr_shortform_getvalue(struct xfs_da_args *args);
215int xfs_attr_shortform_to_leaf(struct xfs_da_args *args); 214int xfs_attr_shortform_to_leaf(struct xfs_da_args *args);
216int xfs_attr_shortform_remove(struct xfs_da_args *args); 215int xfs_attr_shortform_remove(struct xfs_da_args *args);
217int xfs_attr_shortform_list(struct xfs_attr_list_context *context); 216int xfs_attr_shortform_list(struct xfs_attr_list_context *context);
218int xfs_attr_shortform_allfit(struct xfs_dabuf *bp, struct xfs_inode *dp); 217int xfs_attr_shortform_allfit(struct xfs_buf *bp, struct xfs_inode *dp);
219int xfs_attr_shortform_bytesfit(xfs_inode_t *dp, int bytes); 218int xfs_attr_shortform_bytesfit(xfs_inode_t *dp, int bytes);
220 219
221 220
@@ -223,7 +222,7 @@ int xfs_attr_shortform_bytesfit(xfs_inode_t *dp, int bytes);
223 * Internal routines when attribute fork size == XFS_LBSIZE(mp). 222 * Internal routines when attribute fork size == XFS_LBSIZE(mp).
224 */ 223 */
225int xfs_attr_leaf_to_node(struct xfs_da_args *args); 224int xfs_attr_leaf_to_node(struct xfs_da_args *args);
226int xfs_attr_leaf_to_shortform(struct xfs_dabuf *bp, 225int xfs_attr_leaf_to_shortform(struct xfs_buf *bp,
227 struct xfs_da_args *args, int forkoff); 226 struct xfs_da_args *args, int forkoff);
228int xfs_attr_leaf_clearflag(struct xfs_da_args *args); 227int xfs_attr_leaf_clearflag(struct xfs_da_args *args);
229int xfs_attr_leaf_setflag(struct xfs_da_args *args); 228int xfs_attr_leaf_setflag(struct xfs_da_args *args);
@@ -235,14 +234,14 @@ int xfs_attr_leaf_flipflags(xfs_da_args_t *args);
235int xfs_attr_leaf_split(struct xfs_da_state *state, 234int xfs_attr_leaf_split(struct xfs_da_state *state,
236 struct xfs_da_state_blk *oldblk, 235 struct xfs_da_state_blk *oldblk,
237 struct xfs_da_state_blk *newblk); 236 struct xfs_da_state_blk *newblk);
238int xfs_attr_leaf_lookup_int(struct xfs_dabuf *leaf, 237int xfs_attr_leaf_lookup_int(struct xfs_buf *leaf,
239 struct xfs_da_args *args); 238 struct xfs_da_args *args);
240int xfs_attr_leaf_getvalue(struct xfs_dabuf *bp, struct xfs_da_args *args); 239int xfs_attr_leaf_getvalue(struct xfs_buf *bp, struct xfs_da_args *args);
241int xfs_attr_leaf_add(struct xfs_dabuf *leaf_buffer, 240int xfs_attr_leaf_add(struct xfs_buf *leaf_buffer,
242 struct xfs_da_args *args); 241 struct xfs_da_args *args);
243int xfs_attr_leaf_remove(struct xfs_dabuf *leaf_buffer, 242int xfs_attr_leaf_remove(struct xfs_buf *leaf_buffer,
244 struct xfs_da_args *args); 243 struct xfs_da_args *args);
245int xfs_attr_leaf_list_int(struct xfs_dabuf *bp, 244int xfs_attr_leaf_list_int(struct xfs_buf *bp,
246 struct xfs_attr_list_context *context); 245 struct xfs_attr_list_context *context);
247 246
248/* 247/*
@@ -257,9 +256,9 @@ int xfs_attr_root_inactive(struct xfs_trans **trans, struct xfs_inode *dp);
257/* 256/*
258 * Utility routines. 257 * Utility routines.
259 */ 258 */
260xfs_dahash_t xfs_attr_leaf_lasthash(struct xfs_dabuf *bp, int *count); 259xfs_dahash_t xfs_attr_leaf_lasthash(struct xfs_buf *bp, int *count);
261int xfs_attr_leaf_order(struct xfs_dabuf *leaf1_bp, 260int xfs_attr_leaf_order(struct xfs_buf *leaf1_bp,
262 struct xfs_dabuf *leaf2_bp); 261 struct xfs_buf *leaf2_bp);
263int xfs_attr_leaf_newentsize(int namelen, int valuelen, int blocksize, 262int xfs_attr_leaf_newentsize(int namelen, int valuelen, int blocksize,
264 int *local); 263 int *local);
265#endif /* __XFS_ATTR_LEAF_H__ */ 264#endif /* __XFS_ATTR_LEAF_H__ */
diff --git a/fs/xfs/xfs_da_btree.c b/fs/xfs/xfs_da_btree.c
index 76e5dbaa95ea..7bfb7dd334fc 100644
--- a/fs/xfs/xfs_da_btree.c
+++ b/fs/xfs/xfs_da_btree.c
@@ -83,9 +83,9 @@ STATIC void xfs_da_node_unbalance(xfs_da_state_t *state,
83/* 83/*
84 * Utility routines. 84 * Utility routines.
85 */ 85 */
86STATIC uint xfs_da_node_lasthash(xfs_dabuf_t *bp, int *count); 86STATIC uint xfs_da_node_lasthash(struct xfs_buf *bp, int *count);
87STATIC int xfs_da_node_order(xfs_dabuf_t *node1_bp, xfs_dabuf_t *node2_bp); 87STATIC int xfs_da_node_order(struct xfs_buf *node1_bp,
88STATIC xfs_dabuf_t *xfs_da_buf_make(xfs_buf_t *bp); 88 struct xfs_buf *node2_bp);
89STATIC int xfs_da_blk_unlink(xfs_da_state_t *state, 89STATIC int xfs_da_blk_unlink(xfs_da_state_t *state,
90 xfs_da_state_blk_t *drop_blk, 90 xfs_da_state_blk_t *drop_blk,
91 xfs_da_state_blk_t *save_blk); 91 xfs_da_state_blk_t *save_blk);
@@ -100,10 +100,10 @@ STATIC void xfs_da_state_kill_altpath(xfs_da_state_t *state);
100 */ 100 */
101int 101int
102xfs_da_node_create(xfs_da_args_t *args, xfs_dablk_t blkno, int level, 102xfs_da_node_create(xfs_da_args_t *args, xfs_dablk_t blkno, int level,
103 xfs_dabuf_t **bpp, int whichfork) 103 struct xfs_buf **bpp, int whichfork)
104{ 104{
105 xfs_da_intnode_t *node; 105 xfs_da_intnode_t *node;
106 xfs_dabuf_t *bp; 106 struct xfs_buf *bp;
107 int error; 107 int error;
108 xfs_trans_t *tp; 108 xfs_trans_t *tp;
109 109
@@ -114,7 +114,7 @@ xfs_da_node_create(xfs_da_args_t *args, xfs_dablk_t blkno, int level,
114 if (error) 114 if (error)
115 return(error); 115 return(error);
116 ASSERT(bp != NULL); 116 ASSERT(bp != NULL);
117 node = bp->data; 117 node = bp->b_addr;
118 node->hdr.info.forw = 0; 118 node->hdr.info.forw = 0;
119 node->hdr.info.back = 0; 119 node->hdr.info.back = 0;
120 node->hdr.info.magic = cpu_to_be16(XFS_DA_NODE_MAGIC); 120 node->hdr.info.magic = cpu_to_be16(XFS_DA_NODE_MAGIC);
@@ -122,7 +122,7 @@ xfs_da_node_create(xfs_da_args_t *args, xfs_dablk_t blkno, int level,
122 node->hdr.count = 0; 122 node->hdr.count = 0;
123 node->hdr.level = cpu_to_be16(level); 123 node->hdr.level = cpu_to_be16(level);
124 124
125 xfs_da_log_buf(tp, bp, 125 xfs_trans_log_buf(tp, bp,
126 XFS_DA_LOGRANGE(node, &node->hdr, sizeof(node->hdr))); 126 XFS_DA_LOGRANGE(node, &node->hdr, sizeof(node->hdr)));
127 127
128 *bpp = bp; 128 *bpp = bp;
@@ -138,7 +138,7 @@ xfs_da_split(xfs_da_state_t *state)
138{ 138{
139 xfs_da_state_blk_t *oldblk, *newblk, *addblk; 139 xfs_da_state_blk_t *oldblk, *newblk, *addblk;
140 xfs_da_intnode_t *node; 140 xfs_da_intnode_t *node;
141 xfs_dabuf_t *bp; 141 struct xfs_buf *bp;
142 int max, action, error, i; 142 int max, action, error, i;
143 143
144 trace_xfs_da_split(state->args); 144 trace_xfs_da_split(state->args);
@@ -203,7 +203,6 @@ xfs_da_split(xfs_da_state_t *state)
203 case XFS_DA_NODE_MAGIC: 203 case XFS_DA_NODE_MAGIC:
204 error = xfs_da_node_split(state, oldblk, newblk, addblk, 204 error = xfs_da_node_split(state, oldblk, newblk, addblk,
205 max - i, &action); 205 max - i, &action);
206 xfs_da_buf_done(addblk->bp);
207 addblk->bp = NULL; 206 addblk->bp = NULL;
208 if (error) 207 if (error)
209 return(error); /* GROT: dir is inconsistent */ 208 return(error); /* GROT: dir is inconsistent */
@@ -221,13 +220,6 @@ xfs_da_split(xfs_da_state_t *state)
221 * Update the btree to show the new hashval for this child. 220 * Update the btree to show the new hashval for this child.
222 */ 221 */
223 xfs_da_fixhashpath(state, &state->path); 222 xfs_da_fixhashpath(state, &state->path);
224 /*
225 * If we won't need this block again, it's getting dropped
226 * from the active path by the loop control, so we need
227 * to mark it done now.
228 */
229 if (i > 0 || !addblk)
230 xfs_da_buf_done(oldblk->bp);
231 } 223 }
232 if (!addblk) 224 if (!addblk)
233 return(0); 225 return(0);
@@ -239,8 +231,6 @@ xfs_da_split(xfs_da_state_t *state)
239 oldblk = &state->path.blk[0]; 231 oldblk = &state->path.blk[0];
240 error = xfs_da_root_split(state, oldblk, addblk); 232 error = xfs_da_root_split(state, oldblk, addblk);
241 if (error) { 233 if (error) {
242 xfs_da_buf_done(oldblk->bp);
243 xfs_da_buf_done(addblk->bp);
244 addblk->bp = NULL; 234 addblk->bp = NULL;
245 return(error); /* GROT: dir is inconsistent */ 235 return(error); /* GROT: dir is inconsistent */
246 } 236 }
@@ -252,7 +242,7 @@ xfs_da_split(xfs_da_state_t *state)
252 * and the original block 0 could be at any position in the list. 242 * and the original block 0 could be at any position in the list.
253 */ 243 */
254 244
255 node = oldblk->bp->data; 245 node = oldblk->bp->b_addr;
256 if (node->hdr.info.forw) { 246 if (node->hdr.info.forw) {
257 if (be32_to_cpu(node->hdr.info.forw) == addblk->blkno) { 247 if (be32_to_cpu(node->hdr.info.forw) == addblk->blkno) {
258 bp = addblk->bp; 248 bp = addblk->bp;
@@ -260,13 +250,13 @@ xfs_da_split(xfs_da_state_t *state)
260 ASSERT(state->extravalid); 250 ASSERT(state->extravalid);
261 bp = state->extrablk.bp; 251 bp = state->extrablk.bp;
262 } 252 }
263 node = bp->data; 253 node = bp->b_addr;
264 node->hdr.info.back = cpu_to_be32(oldblk->blkno); 254 node->hdr.info.back = cpu_to_be32(oldblk->blkno);
265 xfs_da_log_buf(state->args->trans, bp, 255 xfs_trans_log_buf(state->args->trans, bp,
266 XFS_DA_LOGRANGE(node, &node->hdr.info, 256 XFS_DA_LOGRANGE(node, &node->hdr.info,
267 sizeof(node->hdr.info))); 257 sizeof(node->hdr.info)));
268 } 258 }
269 node = oldblk->bp->data; 259 node = oldblk->bp->b_addr;
270 if (node->hdr.info.back) { 260 if (node->hdr.info.back) {
271 if (be32_to_cpu(node->hdr.info.back) == addblk->blkno) { 261 if (be32_to_cpu(node->hdr.info.back) == addblk->blkno) {
272 bp = addblk->bp; 262 bp = addblk->bp;
@@ -274,14 +264,12 @@ xfs_da_split(xfs_da_state_t *state)
274 ASSERT(state->extravalid); 264 ASSERT(state->extravalid);
275 bp = state->extrablk.bp; 265 bp = state->extrablk.bp;
276 } 266 }
277 node = bp->data; 267 node = bp->b_addr;
278 node->hdr.info.forw = cpu_to_be32(oldblk->blkno); 268 node->hdr.info.forw = cpu_to_be32(oldblk->blkno);
279 xfs_da_log_buf(state->args->trans, bp, 269 xfs_trans_log_buf(state->args->trans, bp,
280 XFS_DA_LOGRANGE(node, &node->hdr.info, 270 XFS_DA_LOGRANGE(node, &node->hdr.info,
281 sizeof(node->hdr.info))); 271 sizeof(node->hdr.info)));
282 } 272 }
283 xfs_da_buf_done(oldblk->bp);
284 xfs_da_buf_done(addblk->bp);
285 addblk->bp = NULL; 273 addblk->bp = NULL;
286 return(0); 274 return(0);
287} 275}
@@ -298,7 +286,7 @@ xfs_da_root_split(xfs_da_state_t *state, xfs_da_state_blk_t *blk1,
298 xfs_da_intnode_t *node, *oldroot; 286 xfs_da_intnode_t *node, *oldroot;
299 xfs_da_args_t *args; 287 xfs_da_args_t *args;
300 xfs_dablk_t blkno; 288 xfs_dablk_t blkno;
301 xfs_dabuf_t *bp; 289 struct xfs_buf *bp;
302 int error, size; 290 int error, size;
303 xfs_inode_t *dp; 291 xfs_inode_t *dp;
304 xfs_trans_t *tp; 292 xfs_trans_t *tp;
@@ -323,8 +311,8 @@ xfs_da_root_split(xfs_da_state_t *state, xfs_da_state_blk_t *blk1,
323 if (error) 311 if (error)
324 return(error); 312 return(error);
325 ASSERT(bp != NULL); 313 ASSERT(bp != NULL);
326 node = bp->data; 314 node = bp->b_addr;
327 oldroot = blk1->bp->data; 315 oldroot = blk1->bp->b_addr;
328 if (oldroot->hdr.info.magic == cpu_to_be16(XFS_DA_NODE_MAGIC)) { 316 if (oldroot->hdr.info.magic == cpu_to_be16(XFS_DA_NODE_MAGIC)) {
329 size = (int)((char *)&oldroot->btree[be16_to_cpu(oldroot->hdr.count)] - 317 size = (int)((char *)&oldroot->btree[be16_to_cpu(oldroot->hdr.count)] -
330 (char *)oldroot); 318 (char *)oldroot);
@@ -335,8 +323,7 @@ xfs_da_root_split(xfs_da_state_t *state, xfs_da_state_blk_t *blk1,
335 (char *)leaf); 323 (char *)leaf);
336 } 324 }
337 memcpy(node, oldroot, size); 325 memcpy(node, oldroot, size);
338 xfs_da_log_buf(tp, bp, 0, size - 1); 326 xfs_trans_log_buf(tp, bp, 0, size - 1);
339 xfs_da_buf_done(blk1->bp);
340 blk1->bp = bp; 327 blk1->bp = bp;
341 blk1->blkno = blkno; 328 blk1->blkno = blkno;
342 329
@@ -348,7 +335,7 @@ xfs_da_root_split(xfs_da_state_t *state, xfs_da_state_blk_t *blk1,
348 be16_to_cpu(node->hdr.level) + 1, &bp, args->whichfork); 335 be16_to_cpu(node->hdr.level) + 1, &bp, args->whichfork);
349 if (error) 336 if (error)
350 return(error); 337 return(error);
351 node = bp->data; 338 node = bp->b_addr;
352 node->btree[0].hashval = cpu_to_be32(blk1->hashval); 339 node->btree[0].hashval = cpu_to_be32(blk1->hashval);
353 node->btree[0].before = cpu_to_be32(blk1->blkno); 340 node->btree[0].before = cpu_to_be32(blk1->blkno);
354 node->btree[1].hashval = cpu_to_be32(blk2->hashval); 341 node->btree[1].hashval = cpu_to_be32(blk2->hashval);
@@ -365,10 +352,9 @@ xfs_da_root_split(xfs_da_state_t *state, xfs_da_state_blk_t *blk1,
365#endif 352#endif
366 353
367 /* Header is already logged by xfs_da_node_create */ 354 /* Header is already logged by xfs_da_node_create */
368 xfs_da_log_buf(tp, bp, 355 xfs_trans_log_buf(tp, bp,
369 XFS_DA_LOGRANGE(node, node->btree, 356 XFS_DA_LOGRANGE(node, node->btree,
370 sizeof(xfs_da_node_entry_t) * 2)); 357 sizeof(xfs_da_node_entry_t) * 2));
371 xfs_da_buf_done(bp);
372 358
373 return(0); 359 return(0);
374} 360}
@@ -389,7 +375,7 @@ xfs_da_node_split(xfs_da_state_t *state, xfs_da_state_blk_t *oldblk,
389 375
390 trace_xfs_da_node_split(state->args); 376 trace_xfs_da_node_split(state->args);
391 377
392 node = oldblk->bp->data; 378 node = oldblk->bp->b_addr;
393 ASSERT(node->hdr.info.magic == cpu_to_be16(XFS_DA_NODE_MAGIC)); 379 ASSERT(node->hdr.info.magic == cpu_to_be16(XFS_DA_NODE_MAGIC));
394 380
395 /* 381 /*
@@ -436,7 +422,7 @@ xfs_da_node_split(xfs_da_state_t *state, xfs_da_state_blk_t *oldblk,
436 * 422 *
437 * If we had double-split op below us, then add the extra block too. 423 * If we had double-split op below us, then add the extra block too.
438 */ 424 */
439 node = oldblk->bp->data; 425 node = oldblk->bp->b_addr;
440 if (oldblk->index <= be16_to_cpu(node->hdr.count)) { 426 if (oldblk->index <= be16_to_cpu(node->hdr.count)) {
441 oldblk->index++; 427 oldblk->index++;
442 xfs_da_node_add(state, oldblk, addblk); 428 xfs_da_node_add(state, oldblk, addblk);
@@ -477,8 +463,8 @@ xfs_da_node_rebalance(xfs_da_state_t *state, xfs_da_state_blk_t *blk1,
477 463
478 trace_xfs_da_node_rebalance(state->args); 464 trace_xfs_da_node_rebalance(state->args);
479 465
480 node1 = blk1->bp->data; 466 node1 = blk1->bp->b_addr;
481 node2 = blk2->bp->data; 467 node2 = blk2->bp->b_addr;
482 /* 468 /*
483 * Figure out how many entries need to move, and in which direction. 469 * Figure out how many entries need to move, and in which direction.
484 * Swap the nodes around if that makes it simpler. 470 * Swap the nodes around if that makes it simpler.
@@ -532,7 +518,7 @@ xfs_da_node_rebalance(xfs_da_state_t *state, xfs_da_state_blk_t *blk1,
532 btree_d = &node1->btree[be16_to_cpu(node1->hdr.count)]; 518 btree_d = &node1->btree[be16_to_cpu(node1->hdr.count)];
533 memcpy(btree_d, btree_s, tmp); 519 memcpy(btree_d, btree_s, tmp);
534 be16_add_cpu(&node1->hdr.count, count); 520 be16_add_cpu(&node1->hdr.count, count);
535 xfs_da_log_buf(tp, blk1->bp, 521 xfs_trans_log_buf(tp, blk1->bp,
536 XFS_DA_LOGRANGE(node1, btree_d, tmp)); 522 XFS_DA_LOGRANGE(node1, btree_d, tmp));
537 523
538 /* 524 /*
@@ -549,9 +535,9 @@ xfs_da_node_rebalance(xfs_da_state_t *state, xfs_da_state_blk_t *blk1,
549 /* 535 /*
550 * Log header of node 1 and all current bits of node 2. 536 * Log header of node 1 and all current bits of node 2.
551 */ 537 */
552 xfs_da_log_buf(tp, blk1->bp, 538 xfs_trans_log_buf(tp, blk1->bp,
553 XFS_DA_LOGRANGE(node1, &node1->hdr, sizeof(node1->hdr))); 539 XFS_DA_LOGRANGE(node1, &node1->hdr, sizeof(node1->hdr)));
554 xfs_da_log_buf(tp, blk2->bp, 540 xfs_trans_log_buf(tp, blk2->bp,
555 XFS_DA_LOGRANGE(node2, &node2->hdr, 541 XFS_DA_LOGRANGE(node2, &node2->hdr,
556 sizeof(node2->hdr) + 542 sizeof(node2->hdr) +
557 sizeof(node2->btree[0]) * be16_to_cpu(node2->hdr.count))); 543 sizeof(node2->btree[0]) * be16_to_cpu(node2->hdr.count)));
@@ -560,8 +546,8 @@ xfs_da_node_rebalance(xfs_da_state_t *state, xfs_da_state_blk_t *blk1,
560 * Record the last hashval from each block for upward propagation. 546 * Record the last hashval from each block for upward propagation.
561 * (note: don't use the swapped node pointers) 547 * (note: don't use the swapped node pointers)
562 */ 548 */
563 node1 = blk1->bp->data; 549 node1 = blk1->bp->b_addr;
564 node2 = blk2->bp->data; 550 node2 = blk2->bp->b_addr;
565 blk1->hashval = be32_to_cpu(node1->btree[be16_to_cpu(node1->hdr.count)-1].hashval); 551 blk1->hashval = be32_to_cpu(node1->btree[be16_to_cpu(node1->hdr.count)-1].hashval);
566 blk2->hashval = be32_to_cpu(node2->btree[be16_to_cpu(node2->hdr.count)-1].hashval); 552 blk2->hashval = be32_to_cpu(node2->btree[be16_to_cpu(node2->hdr.count)-1].hashval);
567 553
@@ -587,7 +573,7 @@ xfs_da_node_add(xfs_da_state_t *state, xfs_da_state_blk_t *oldblk,
587 573
588 trace_xfs_da_node_add(state->args); 574 trace_xfs_da_node_add(state->args);
589 575
590 node = oldblk->bp->data; 576 node = oldblk->bp->b_addr;
591 ASSERT(node->hdr.info.magic == cpu_to_be16(XFS_DA_NODE_MAGIC)); 577 ASSERT(node->hdr.info.magic == cpu_to_be16(XFS_DA_NODE_MAGIC));
592 ASSERT((oldblk->index >= 0) && (oldblk->index <= be16_to_cpu(node->hdr.count))); 578 ASSERT((oldblk->index >= 0) && (oldblk->index <= be16_to_cpu(node->hdr.count)));
593 ASSERT(newblk->blkno != 0); 579 ASSERT(newblk->blkno != 0);
@@ -606,10 +592,10 @@ xfs_da_node_add(xfs_da_state_t *state, xfs_da_state_blk_t *oldblk,
606 } 592 }
607 btree->hashval = cpu_to_be32(newblk->hashval); 593 btree->hashval = cpu_to_be32(newblk->hashval);
608 btree->before = cpu_to_be32(newblk->blkno); 594 btree->before = cpu_to_be32(newblk->blkno);
609 xfs_da_log_buf(state->args->trans, oldblk->bp, 595 xfs_trans_log_buf(state->args->trans, oldblk->bp,
610 XFS_DA_LOGRANGE(node, btree, tmp + sizeof(*btree))); 596 XFS_DA_LOGRANGE(node, btree, tmp + sizeof(*btree)));
611 be16_add_cpu(&node->hdr.count, 1); 597 be16_add_cpu(&node->hdr.count, 1);
612 xfs_da_log_buf(state->args->trans, oldblk->bp, 598 xfs_trans_log_buf(state->args->trans, oldblk->bp,
613 XFS_DA_LOGRANGE(node, &node->hdr, sizeof(node->hdr))); 599 XFS_DA_LOGRANGE(node, &node->hdr, sizeof(node->hdr)));
614 600
615 /* 601 /*
@@ -735,7 +721,7 @@ xfs_da_root_join(xfs_da_state_t *state, xfs_da_state_blk_t *root_blk)
735 xfs_da_intnode_t *oldroot; 721 xfs_da_intnode_t *oldroot;
736 xfs_da_args_t *args; 722 xfs_da_args_t *args;
737 xfs_dablk_t child; 723 xfs_dablk_t child;
738 xfs_dabuf_t *bp; 724 struct xfs_buf *bp;
739 int error; 725 int error;
740 726
741 trace_xfs_da_root_join(state->args); 727 trace_xfs_da_root_join(state->args);
@@ -743,7 +729,7 @@ xfs_da_root_join(xfs_da_state_t *state, xfs_da_state_blk_t *root_blk)
743 args = state->args; 729 args = state->args;
744 ASSERT(args != NULL); 730 ASSERT(args != NULL);
745 ASSERT(root_blk->magic == XFS_DA_NODE_MAGIC); 731 ASSERT(root_blk->magic == XFS_DA_NODE_MAGIC);
746 oldroot = root_blk->bp->data; 732 oldroot = root_blk->bp->b_addr;
747 ASSERT(oldroot->hdr.info.magic == cpu_to_be16(XFS_DA_NODE_MAGIC)); 733 ASSERT(oldroot->hdr.info.magic == cpu_to_be16(XFS_DA_NODE_MAGIC));
748 ASSERT(!oldroot->hdr.info.forw); 734 ASSERT(!oldroot->hdr.info.forw);
749 ASSERT(!oldroot->hdr.info.back); 735 ASSERT(!oldroot->hdr.info.back);
@@ -765,11 +751,11 @@ xfs_da_root_join(xfs_da_state_t *state, xfs_da_state_blk_t *root_blk)
765 if (error) 751 if (error)
766 return(error); 752 return(error);
767 ASSERT(bp != NULL); 753 ASSERT(bp != NULL);
768 xfs_da_blkinfo_onlychild_validate(bp->data, 754 xfs_da_blkinfo_onlychild_validate(bp->b_addr,
769 be16_to_cpu(oldroot->hdr.level)); 755 be16_to_cpu(oldroot->hdr.level));
770 756
771 memcpy(root_blk->bp->data, bp->data, state->blocksize); 757 memcpy(root_blk->bp->b_addr, bp->b_addr, state->blocksize);
772 xfs_da_log_buf(args->trans, root_blk->bp, 0, state->blocksize - 1); 758 xfs_trans_log_buf(args->trans, root_blk->bp, 0, state->blocksize - 1);
773 error = xfs_da_shrink_inode(args, child, bp); 759 error = xfs_da_shrink_inode(args, child, bp);
774 return(error); 760 return(error);
775} 761}
@@ -791,7 +777,7 @@ xfs_da_node_toosmall(xfs_da_state_t *state, int *action)
791 xfs_da_blkinfo_t *info; 777 xfs_da_blkinfo_t *info;
792 int count, forward, error, retval, i; 778 int count, forward, error, retval, i;
793 xfs_dablk_t blkno; 779 xfs_dablk_t blkno;
794 xfs_dabuf_t *bp; 780 struct xfs_buf *bp;
795 781
796 /* 782 /*
797 * Check for the degenerate case of the block being over 50% full. 783 * Check for the degenerate case of the block being over 50% full.
@@ -799,7 +785,7 @@ xfs_da_node_toosmall(xfs_da_state_t *state, int *action)
799 * to coalesce with a sibling. 785 * to coalesce with a sibling.
800 */ 786 */
801 blk = &state->path.blk[ state->path.active-1 ]; 787 blk = &state->path.blk[ state->path.active-1 ];
802 info = blk->bp->data; 788 info = blk->bp->b_addr;
803 ASSERT(info->magic == cpu_to_be16(XFS_DA_NODE_MAGIC)); 789 ASSERT(info->magic == cpu_to_be16(XFS_DA_NODE_MAGIC));
804 node = (xfs_da_intnode_t *)info; 790 node = (xfs_da_intnode_t *)info;
805 count = be16_to_cpu(node->hdr.count); 791 count = be16_to_cpu(node->hdr.count);
@@ -859,10 +845,10 @@ xfs_da_node_toosmall(xfs_da_state_t *state, int *action)
859 count = state->node_ents; 845 count = state->node_ents;
860 count -= state->node_ents >> 2; 846 count -= state->node_ents >> 2;
861 count -= be16_to_cpu(node->hdr.count); 847 count -= be16_to_cpu(node->hdr.count);
862 node = bp->data; 848 node = bp->b_addr;
863 ASSERT(node->hdr.info.magic == cpu_to_be16(XFS_DA_NODE_MAGIC)); 849 ASSERT(node->hdr.info.magic == cpu_to_be16(XFS_DA_NODE_MAGIC));
864 count -= be16_to_cpu(node->hdr.count); 850 count -= be16_to_cpu(node->hdr.count);
865 xfs_da_brelse(state->args->trans, bp); 851 xfs_trans_brelse(state->args->trans, bp);
866 if (count >= 0) 852 if (count >= 0)
867 break; /* fits with at least 25% to spare */ 853 break; /* fits with at least 25% to spare */
868 } 854 }
@@ -934,14 +920,14 @@ xfs_da_fixhashpath(xfs_da_state_t *state, xfs_da_state_path_t *path)
934 break; 920 break;
935 } 921 }
936 for (blk--, level--; level >= 0; blk--, level--) { 922 for (blk--, level--; level >= 0; blk--, level--) {
937 node = blk->bp->data; 923 node = blk->bp->b_addr;
938 ASSERT(node->hdr.info.magic == cpu_to_be16(XFS_DA_NODE_MAGIC)); 924 ASSERT(node->hdr.info.magic == cpu_to_be16(XFS_DA_NODE_MAGIC));
939 btree = &node->btree[ blk->index ]; 925 btree = &node->btree[ blk->index ];
940 if (be32_to_cpu(btree->hashval) == lasthash) 926 if (be32_to_cpu(btree->hashval) == lasthash)
941 break; 927 break;
942 blk->hashval = lasthash; 928 blk->hashval = lasthash;
943 btree->hashval = cpu_to_be32(lasthash); 929 btree->hashval = cpu_to_be32(lasthash);
944 xfs_da_log_buf(state->args->trans, blk->bp, 930 xfs_trans_log_buf(state->args->trans, blk->bp,
945 XFS_DA_LOGRANGE(node, btree, sizeof(*btree))); 931 XFS_DA_LOGRANGE(node, btree, sizeof(*btree)));
946 932
947 lasthash = be32_to_cpu(node->btree[be16_to_cpu(node->hdr.count)-1].hashval); 933 lasthash = be32_to_cpu(node->btree[be16_to_cpu(node->hdr.count)-1].hashval);
@@ -960,7 +946,7 @@ xfs_da_node_remove(xfs_da_state_t *state, xfs_da_state_blk_t *drop_blk)
960 946
961 trace_xfs_da_node_remove(state->args); 947 trace_xfs_da_node_remove(state->args);
962 948
963 node = drop_blk->bp->data; 949 node = drop_blk->bp->b_addr;
964 ASSERT(drop_blk->index < be16_to_cpu(node->hdr.count)); 950 ASSERT(drop_blk->index < be16_to_cpu(node->hdr.count));
965 ASSERT(drop_blk->index >= 0); 951 ASSERT(drop_blk->index >= 0);
966 952
@@ -972,15 +958,15 @@ xfs_da_node_remove(xfs_da_state_t *state, xfs_da_state_blk_t *drop_blk)
972 tmp = be16_to_cpu(node->hdr.count) - drop_blk->index - 1; 958 tmp = be16_to_cpu(node->hdr.count) - drop_blk->index - 1;
973 tmp *= (uint)sizeof(xfs_da_node_entry_t); 959 tmp *= (uint)sizeof(xfs_da_node_entry_t);
974 memmove(btree, btree + 1, tmp); 960 memmove(btree, btree + 1, tmp);
975 xfs_da_log_buf(state->args->trans, drop_blk->bp, 961 xfs_trans_log_buf(state->args->trans, drop_blk->bp,
976 XFS_DA_LOGRANGE(node, btree, tmp)); 962 XFS_DA_LOGRANGE(node, btree, tmp));
977 btree = &node->btree[be16_to_cpu(node->hdr.count)-1]; 963 btree = &node->btree[be16_to_cpu(node->hdr.count)-1];
978 } 964 }
979 memset((char *)btree, 0, sizeof(xfs_da_node_entry_t)); 965 memset((char *)btree, 0, sizeof(xfs_da_node_entry_t));
980 xfs_da_log_buf(state->args->trans, drop_blk->bp, 966 xfs_trans_log_buf(state->args->trans, drop_blk->bp,
981 XFS_DA_LOGRANGE(node, btree, sizeof(*btree))); 967 XFS_DA_LOGRANGE(node, btree, sizeof(*btree)));
982 be16_add_cpu(&node->hdr.count, -1); 968 be16_add_cpu(&node->hdr.count, -1);
983 xfs_da_log_buf(state->args->trans, drop_blk->bp, 969 xfs_trans_log_buf(state->args->trans, drop_blk->bp,
984 XFS_DA_LOGRANGE(node, &node->hdr, sizeof(node->hdr))); 970 XFS_DA_LOGRANGE(node, &node->hdr, sizeof(node->hdr)));
985 971
986 /* 972 /*
@@ -1005,8 +991,8 @@ xfs_da_node_unbalance(xfs_da_state_t *state, xfs_da_state_blk_t *drop_blk,
1005 991
1006 trace_xfs_da_node_unbalance(state->args); 992 trace_xfs_da_node_unbalance(state->args);
1007 993
1008 drop_node = drop_blk->bp->data; 994 drop_node = drop_blk->bp->b_addr;
1009 save_node = save_blk->bp->data; 995 save_node = save_blk->bp->b_addr;
1010 ASSERT(drop_node->hdr.info.magic == cpu_to_be16(XFS_DA_NODE_MAGIC)); 996 ASSERT(drop_node->hdr.info.magic == cpu_to_be16(XFS_DA_NODE_MAGIC));
1011 ASSERT(save_node->hdr.info.magic == cpu_to_be16(XFS_DA_NODE_MAGIC)); 997 ASSERT(save_node->hdr.info.magic == cpu_to_be16(XFS_DA_NODE_MAGIC));
1012 tp = state->args->trans; 998 tp = state->args->trans;
@@ -1023,13 +1009,13 @@ xfs_da_node_unbalance(xfs_da_state_t *state, xfs_da_state_blk_t *drop_blk,
1023 tmp = be16_to_cpu(save_node->hdr.count) * (uint)sizeof(xfs_da_node_entry_t); 1009 tmp = be16_to_cpu(save_node->hdr.count) * (uint)sizeof(xfs_da_node_entry_t);
1024 memmove(btree, &save_node->btree[0], tmp); 1010 memmove(btree, &save_node->btree[0], tmp);
1025 btree = &save_node->btree[0]; 1011 btree = &save_node->btree[0];
1026 xfs_da_log_buf(tp, save_blk->bp, 1012 xfs_trans_log_buf(tp, save_blk->bp,
1027 XFS_DA_LOGRANGE(save_node, btree, 1013 XFS_DA_LOGRANGE(save_node, btree,
1028 (be16_to_cpu(save_node->hdr.count) + be16_to_cpu(drop_node->hdr.count)) * 1014 (be16_to_cpu(save_node->hdr.count) + be16_to_cpu(drop_node->hdr.count)) *
1029 sizeof(xfs_da_node_entry_t))); 1015 sizeof(xfs_da_node_entry_t)));
1030 } else { 1016 } else {
1031 btree = &save_node->btree[be16_to_cpu(save_node->hdr.count)]; 1017 btree = &save_node->btree[be16_to_cpu(save_node->hdr.count)];
1032 xfs_da_log_buf(tp, save_blk->bp, 1018 xfs_trans_log_buf(tp, save_blk->bp,
1033 XFS_DA_LOGRANGE(save_node, btree, 1019 XFS_DA_LOGRANGE(save_node, btree,
1034 be16_to_cpu(drop_node->hdr.count) * 1020 be16_to_cpu(drop_node->hdr.count) *
1035 sizeof(xfs_da_node_entry_t))); 1021 sizeof(xfs_da_node_entry_t)));
@@ -1042,7 +1028,7 @@ xfs_da_node_unbalance(xfs_da_state_t *state, xfs_da_state_blk_t *drop_blk,
1042 memcpy(btree, &drop_node->btree[0], tmp); 1028 memcpy(btree, &drop_node->btree[0], tmp);
1043 be16_add_cpu(&save_node->hdr.count, be16_to_cpu(drop_node->hdr.count)); 1029 be16_add_cpu(&save_node->hdr.count, be16_to_cpu(drop_node->hdr.count));
1044 1030
1045 xfs_da_log_buf(tp, save_blk->bp, 1031 xfs_trans_log_buf(tp, save_blk->bp,
1046 XFS_DA_LOGRANGE(save_node, &save_node->hdr, 1032 XFS_DA_LOGRANGE(save_node, &save_node->hdr,
1047 sizeof(save_node->hdr))); 1033 sizeof(save_node->hdr)));
1048 1034
@@ -1100,7 +1086,7 @@ xfs_da_node_lookup_int(xfs_da_state_t *state, int *result)
1100 state->path.active--; 1086 state->path.active--;
1101 return(error); 1087 return(error);
1102 } 1088 }
1103 curr = blk->bp->data; 1089 curr = blk->bp->b_addr;
1104 blk->magic = be16_to_cpu(curr->magic); 1090 blk->magic = be16_to_cpu(curr->magic);
1105 ASSERT(blk->magic == XFS_DA_NODE_MAGIC || 1091 ASSERT(blk->magic == XFS_DA_NODE_MAGIC ||
1106 blk->magic == XFS_DIR2_LEAFN_MAGIC || 1092 blk->magic == XFS_DIR2_LEAFN_MAGIC ||
@@ -1110,7 +1096,7 @@ xfs_da_node_lookup_int(xfs_da_state_t *state, int *result)
1110 * Search an intermediate node for a match. 1096 * Search an intermediate node for a match.
1111 */ 1097 */
1112 if (blk->magic == XFS_DA_NODE_MAGIC) { 1098 if (blk->magic == XFS_DA_NODE_MAGIC) {
1113 node = blk->bp->data; 1099 node = blk->bp->b_addr;
1114 max = be16_to_cpu(node->hdr.count); 1100 max = be16_to_cpu(node->hdr.count);
1115 blk->hashval = be32_to_cpu(node->btree[max-1].hashval); 1101 blk->hashval = be32_to_cpu(node->btree[max-1].hashval);
1116 1102
@@ -1216,15 +1202,15 @@ xfs_da_blk_link(xfs_da_state_t *state, xfs_da_state_blk_t *old_blk,
1216 xfs_da_blkinfo_t *old_info, *new_info, *tmp_info; 1202 xfs_da_blkinfo_t *old_info, *new_info, *tmp_info;
1217 xfs_da_args_t *args; 1203 xfs_da_args_t *args;
1218 int before=0, error; 1204 int before=0, error;
1219 xfs_dabuf_t *bp; 1205 struct xfs_buf *bp;
1220 1206
1221 /* 1207 /*
1222 * Set up environment. 1208 * Set up environment.
1223 */ 1209 */
1224 args = state->args; 1210 args = state->args;
1225 ASSERT(args != NULL); 1211 ASSERT(args != NULL);
1226 old_info = old_blk->bp->data; 1212 old_info = old_blk->bp->b_addr;
1227 new_info = new_blk->bp->data; 1213 new_info = new_blk->bp->b_addr;
1228 ASSERT(old_blk->magic == XFS_DA_NODE_MAGIC || 1214 ASSERT(old_blk->magic == XFS_DA_NODE_MAGIC ||
1229 old_blk->magic == XFS_DIR2_LEAFN_MAGIC || 1215 old_blk->magic == XFS_DIR2_LEAFN_MAGIC ||
1230 old_blk->magic == XFS_ATTR_LEAF_MAGIC); 1216 old_blk->magic == XFS_ATTR_LEAF_MAGIC);
@@ -1261,12 +1247,11 @@ xfs_da_blk_link(xfs_da_state_t *state, xfs_da_state_blk_t *old_blk,
1261 if (error) 1247 if (error)
1262 return(error); 1248 return(error);
1263 ASSERT(bp != NULL); 1249 ASSERT(bp != NULL);
1264 tmp_info = bp->data; 1250 tmp_info = bp->b_addr;
1265 ASSERT(be16_to_cpu(tmp_info->magic) == be16_to_cpu(old_info->magic)); 1251 ASSERT(be16_to_cpu(tmp_info->magic) == be16_to_cpu(old_info->magic));
1266 ASSERT(be32_to_cpu(tmp_info->forw) == old_blk->blkno); 1252 ASSERT(be32_to_cpu(tmp_info->forw) == old_blk->blkno);
1267 tmp_info->forw = cpu_to_be32(new_blk->blkno); 1253 tmp_info->forw = cpu_to_be32(new_blk->blkno);
1268 xfs_da_log_buf(args->trans, bp, 0, sizeof(*tmp_info)-1); 1254 xfs_trans_log_buf(args->trans, bp, 0, sizeof(*tmp_info)-1);
1269 xfs_da_buf_done(bp);
1270 } 1255 }
1271 old_info->back = cpu_to_be32(new_blk->blkno); 1256 old_info->back = cpu_to_be32(new_blk->blkno);
1272 } else { 1257 } else {
@@ -1283,18 +1268,17 @@ xfs_da_blk_link(xfs_da_state_t *state, xfs_da_state_blk_t *old_blk,
1283 if (error) 1268 if (error)
1284 return(error); 1269 return(error);
1285 ASSERT(bp != NULL); 1270 ASSERT(bp != NULL);
1286 tmp_info = bp->data; 1271 tmp_info = bp->b_addr;
1287 ASSERT(tmp_info->magic == old_info->magic); 1272 ASSERT(tmp_info->magic == old_info->magic);
1288 ASSERT(be32_to_cpu(tmp_info->back) == old_blk->blkno); 1273 ASSERT(be32_to_cpu(tmp_info->back) == old_blk->blkno);
1289 tmp_info->back = cpu_to_be32(new_blk->blkno); 1274 tmp_info->back = cpu_to_be32(new_blk->blkno);
1290 xfs_da_log_buf(args->trans, bp, 0, sizeof(*tmp_info)-1); 1275 xfs_trans_log_buf(args->trans, bp, 0, sizeof(*tmp_info)-1);
1291 xfs_da_buf_done(bp);
1292 } 1276 }
1293 old_info->forw = cpu_to_be32(new_blk->blkno); 1277 old_info->forw = cpu_to_be32(new_blk->blkno);
1294 } 1278 }
1295 1279
1296 xfs_da_log_buf(args->trans, old_blk->bp, 0, sizeof(*tmp_info) - 1); 1280 xfs_trans_log_buf(args->trans, old_blk->bp, 0, sizeof(*tmp_info) - 1);
1297 xfs_da_log_buf(args->trans, new_blk->bp, 0, sizeof(*tmp_info) - 1); 1281 xfs_trans_log_buf(args->trans, new_blk->bp, 0, sizeof(*tmp_info) - 1);
1298 return(0); 1282 return(0);
1299} 1283}
1300 1284
@@ -1302,12 +1286,14 @@ xfs_da_blk_link(xfs_da_state_t *state, xfs_da_state_blk_t *old_blk,
1302 * Compare two intermediate nodes for "order". 1286 * Compare two intermediate nodes for "order".
1303 */ 1287 */
1304STATIC int 1288STATIC int
1305xfs_da_node_order(xfs_dabuf_t *node1_bp, xfs_dabuf_t *node2_bp) 1289xfs_da_node_order(
1290 struct xfs_buf *node1_bp,
1291 struct xfs_buf *node2_bp)
1306{ 1292{
1307 xfs_da_intnode_t *node1, *node2; 1293 xfs_da_intnode_t *node1, *node2;
1308 1294
1309 node1 = node1_bp->data; 1295 node1 = node1_bp->b_addr;
1310 node2 = node2_bp->data; 1296 node2 = node2_bp->b_addr;
1311 ASSERT(node1->hdr.info.magic == cpu_to_be16(XFS_DA_NODE_MAGIC) && 1297 ASSERT(node1->hdr.info.magic == cpu_to_be16(XFS_DA_NODE_MAGIC) &&
1312 node2->hdr.info.magic == cpu_to_be16(XFS_DA_NODE_MAGIC)); 1298 node2->hdr.info.magic == cpu_to_be16(XFS_DA_NODE_MAGIC));
1313 if ((be16_to_cpu(node1->hdr.count) > 0) && (be16_to_cpu(node2->hdr.count) > 0) && 1299 if ((be16_to_cpu(node1->hdr.count) > 0) && (be16_to_cpu(node2->hdr.count) > 0) &&
@@ -1324,11 +1310,13 @@ xfs_da_node_order(xfs_dabuf_t *node1_bp, xfs_dabuf_t *node2_bp)
1324 * Pick up the last hashvalue from an intermediate node. 1310 * Pick up the last hashvalue from an intermediate node.
1325 */ 1311 */
1326STATIC uint 1312STATIC uint
1327xfs_da_node_lasthash(xfs_dabuf_t *bp, int *count) 1313xfs_da_node_lasthash(
1314 struct xfs_buf *bp,
1315 int *count)
1328{ 1316{
1329 xfs_da_intnode_t *node; 1317 xfs_da_intnode_t *node;
1330 1318
1331 node = bp->data; 1319 node = bp->b_addr;
1332 ASSERT(node->hdr.info.magic == cpu_to_be16(XFS_DA_NODE_MAGIC)); 1320 ASSERT(node->hdr.info.magic == cpu_to_be16(XFS_DA_NODE_MAGIC));
1333 if (count) 1321 if (count)
1334 *count = be16_to_cpu(node->hdr.count); 1322 *count = be16_to_cpu(node->hdr.count);
@@ -1346,7 +1334,7 @@ xfs_da_blk_unlink(xfs_da_state_t *state, xfs_da_state_blk_t *drop_blk,
1346{ 1334{
1347 xfs_da_blkinfo_t *drop_info, *save_info, *tmp_info; 1335 xfs_da_blkinfo_t *drop_info, *save_info, *tmp_info;
1348 xfs_da_args_t *args; 1336 xfs_da_args_t *args;
1349 xfs_dabuf_t *bp; 1337 struct xfs_buf *bp;
1350 int error; 1338 int error;
1351 1339
1352 /* 1340 /*
@@ -1354,8 +1342,8 @@ xfs_da_blk_unlink(xfs_da_state_t *state, xfs_da_state_blk_t *drop_blk,
1354 */ 1342 */
1355 args = state->args; 1343 args = state->args;
1356 ASSERT(args != NULL); 1344 ASSERT(args != NULL);
1357 save_info = save_blk->bp->data; 1345 save_info = save_blk->bp->b_addr;
1358 drop_info = drop_blk->bp->data; 1346 drop_info = drop_blk->bp->b_addr;
1359 ASSERT(save_blk->magic == XFS_DA_NODE_MAGIC || 1347 ASSERT(save_blk->magic == XFS_DA_NODE_MAGIC ||
1360 save_blk->magic == XFS_DIR2_LEAFN_MAGIC || 1348 save_blk->magic == XFS_DIR2_LEAFN_MAGIC ||
1361 save_blk->magic == XFS_ATTR_LEAF_MAGIC); 1349 save_blk->magic == XFS_ATTR_LEAF_MAGIC);
@@ -1380,13 +1368,12 @@ xfs_da_blk_unlink(xfs_da_state_t *state, xfs_da_state_blk_t *drop_blk,
1380 if (error) 1368 if (error)
1381 return(error); 1369 return(error);
1382 ASSERT(bp != NULL); 1370 ASSERT(bp != NULL);
1383 tmp_info = bp->data; 1371 tmp_info = bp->b_addr;
1384 ASSERT(tmp_info->magic == save_info->magic); 1372 ASSERT(tmp_info->magic == save_info->magic);
1385 ASSERT(be32_to_cpu(tmp_info->forw) == drop_blk->blkno); 1373 ASSERT(be32_to_cpu(tmp_info->forw) == drop_blk->blkno);
1386 tmp_info->forw = cpu_to_be32(save_blk->blkno); 1374 tmp_info->forw = cpu_to_be32(save_blk->blkno);
1387 xfs_da_log_buf(args->trans, bp, 0, 1375 xfs_trans_log_buf(args->trans, bp, 0,
1388 sizeof(*tmp_info) - 1); 1376 sizeof(*tmp_info) - 1);
1389 xfs_da_buf_done(bp);
1390 } 1377 }
1391 } else { 1378 } else {
1392 trace_xfs_da_unlink_forward(args); 1379 trace_xfs_da_unlink_forward(args);
@@ -1398,17 +1385,16 @@ xfs_da_blk_unlink(xfs_da_state_t *state, xfs_da_state_blk_t *drop_blk,
1398 if (error) 1385 if (error)
1399 return(error); 1386 return(error);
1400 ASSERT(bp != NULL); 1387 ASSERT(bp != NULL);
1401 tmp_info = bp->data; 1388 tmp_info = bp->b_addr;
1402 ASSERT(tmp_info->magic == save_info->magic); 1389 ASSERT(tmp_info->magic == save_info->magic);
1403 ASSERT(be32_to_cpu(tmp_info->back) == drop_blk->blkno); 1390 ASSERT(be32_to_cpu(tmp_info->back) == drop_blk->blkno);
1404 tmp_info->back = cpu_to_be32(save_blk->blkno); 1391 tmp_info->back = cpu_to_be32(save_blk->blkno);
1405 xfs_da_log_buf(args->trans, bp, 0, 1392 xfs_trans_log_buf(args->trans, bp, 0,
1406 sizeof(*tmp_info) - 1); 1393 sizeof(*tmp_info) - 1);
1407 xfs_da_buf_done(bp);
1408 } 1394 }
1409 } 1395 }
1410 1396
1411 xfs_da_log_buf(args->trans, save_blk->bp, 0, sizeof(*save_info) - 1); 1397 xfs_trans_log_buf(args->trans, save_blk->bp, 0, sizeof(*save_info) - 1);
1412 return(0); 1398 return(0);
1413} 1399}
1414 1400
@@ -1443,7 +1429,7 @@ xfs_da_path_shift(xfs_da_state_t *state, xfs_da_state_path_t *path,
1443 level = (path->active-1) - 1; /* skip bottom layer in path */ 1429 level = (path->active-1) - 1; /* skip bottom layer in path */
1444 for (blk = &path->blk[level]; level >= 0; blk--, level--) { 1430 for (blk = &path->blk[level]; level >= 0; blk--, level--) {
1445 ASSERT(blk->bp != NULL); 1431 ASSERT(blk->bp != NULL);
1446 node = blk->bp->data; 1432 node = blk->bp->b_addr;
1447 ASSERT(node->hdr.info.magic == cpu_to_be16(XFS_DA_NODE_MAGIC)); 1433 ASSERT(node->hdr.info.magic == cpu_to_be16(XFS_DA_NODE_MAGIC));
1448 if (forward && (blk->index < be16_to_cpu(node->hdr.count)-1)) { 1434 if (forward && (blk->index < be16_to_cpu(node->hdr.count)-1)) {
1449 blk->index++; 1435 blk->index++;
@@ -1471,7 +1457,7 @@ xfs_da_path_shift(xfs_da_state_t *state, xfs_da_state_path_t *path,
1471 * (if it's dirty, trans won't actually let go) 1457 * (if it's dirty, trans won't actually let go)
1472 */ 1458 */
1473 if (release) 1459 if (release)
1474 xfs_da_brelse(args->trans, blk->bp); 1460 xfs_trans_brelse(args->trans, blk->bp);
1475 1461
1476 /* 1462 /*
1477 * Read the next child block. 1463 * Read the next child block.
@@ -1482,7 +1468,7 @@ xfs_da_path_shift(xfs_da_state_t *state, xfs_da_state_path_t *path,
1482 if (error) 1468 if (error)
1483 return(error); 1469 return(error);
1484 ASSERT(blk->bp != NULL); 1470 ASSERT(blk->bp != NULL);
1485 info = blk->bp->data; 1471 info = blk->bp->b_addr;
1486 ASSERT(info->magic == cpu_to_be16(XFS_DA_NODE_MAGIC) || 1472 ASSERT(info->magic == cpu_to_be16(XFS_DA_NODE_MAGIC) ||
1487 info->magic == cpu_to_be16(XFS_DIR2_LEAFN_MAGIC) || 1473 info->magic == cpu_to_be16(XFS_DIR2_LEAFN_MAGIC) ||
1488 info->magic == cpu_to_be16(XFS_ATTR_LEAF_MAGIC)); 1474 info->magic == cpu_to_be16(XFS_ATTR_LEAF_MAGIC));
@@ -1702,11 +1688,13 @@ xfs_da_grow_inode(
1702 * a bmap btree split to do that. 1688 * a bmap btree split to do that.
1703 */ 1689 */
1704STATIC int 1690STATIC int
1705xfs_da_swap_lastblock(xfs_da_args_t *args, xfs_dablk_t *dead_blknop, 1691xfs_da_swap_lastblock(
1706 xfs_dabuf_t **dead_bufp) 1692 xfs_da_args_t *args,
1693 xfs_dablk_t *dead_blknop,
1694 struct xfs_buf **dead_bufp)
1707{ 1695{
1708 xfs_dablk_t dead_blkno, last_blkno, sib_blkno, par_blkno; 1696 xfs_dablk_t dead_blkno, last_blkno, sib_blkno, par_blkno;
1709 xfs_dabuf_t *dead_buf, *last_buf, *sib_buf, *par_buf; 1697 struct xfs_buf *dead_buf, *last_buf, *sib_buf, *par_buf;
1710 xfs_fileoff_t lastoff; 1698 xfs_fileoff_t lastoff;
1711 xfs_inode_t *ip; 1699 xfs_inode_t *ip;
1712 xfs_trans_t *tp; 1700 xfs_trans_t *tp;
@@ -1744,9 +1732,9 @@ xfs_da_swap_lastblock(xfs_da_args_t *args, xfs_dablk_t *dead_blknop,
1744 /* 1732 /*
1745 * Copy the last block into the dead buffer and log it. 1733 * Copy the last block into the dead buffer and log it.
1746 */ 1734 */
1747 memcpy(dead_buf->data, last_buf->data, mp->m_dirblksize); 1735 memcpy(dead_buf->b_addr, last_buf->b_addr, mp->m_dirblksize);
1748 xfs_da_log_buf(tp, dead_buf, 0, mp->m_dirblksize - 1); 1736 xfs_trans_log_buf(tp, dead_buf, 0, mp->m_dirblksize - 1);
1749 dead_info = dead_buf->data; 1737 dead_info = dead_buf->b_addr;
1750 /* 1738 /*
1751 * Get values from the moved block. 1739 * Get values from the moved block.
1752 */ 1740 */
@@ -1767,7 +1755,7 @@ xfs_da_swap_lastblock(xfs_da_args_t *args, xfs_dablk_t *dead_blknop,
1767 if ((sib_blkno = be32_to_cpu(dead_info->back))) { 1755 if ((sib_blkno = be32_to_cpu(dead_info->back))) {
1768 if ((error = xfs_da_read_buf(tp, ip, sib_blkno, -1, &sib_buf, w))) 1756 if ((error = xfs_da_read_buf(tp, ip, sib_blkno, -1, &sib_buf, w)))
1769 goto done; 1757 goto done;
1770 sib_info = sib_buf->data; 1758 sib_info = sib_buf->b_addr;
1771 if (unlikely( 1759 if (unlikely(
1772 be32_to_cpu(sib_info->forw) != last_blkno || 1760 be32_to_cpu(sib_info->forw) != last_blkno ||
1773 sib_info->magic != dead_info->magic)) { 1761 sib_info->magic != dead_info->magic)) {
@@ -1777,10 +1765,9 @@ xfs_da_swap_lastblock(xfs_da_args_t *args, xfs_dablk_t *dead_blknop,
1777 goto done; 1765 goto done;
1778 } 1766 }
1779 sib_info->forw = cpu_to_be32(dead_blkno); 1767 sib_info->forw = cpu_to_be32(dead_blkno);
1780 xfs_da_log_buf(tp, sib_buf, 1768 xfs_trans_log_buf(tp, sib_buf,
1781 XFS_DA_LOGRANGE(sib_info, &sib_info->forw, 1769 XFS_DA_LOGRANGE(sib_info, &sib_info->forw,
1782 sizeof(sib_info->forw))); 1770 sizeof(sib_info->forw)));
1783 xfs_da_buf_done(sib_buf);
1784 sib_buf = NULL; 1771 sib_buf = NULL;
1785 } 1772 }
1786 /* 1773 /*
@@ -1789,7 +1776,7 @@ xfs_da_swap_lastblock(xfs_da_args_t *args, xfs_dablk_t *dead_blknop,
1789 if ((sib_blkno = be32_to_cpu(dead_info->forw))) { 1776 if ((sib_blkno = be32_to_cpu(dead_info->forw))) {
1790 if ((error = xfs_da_read_buf(tp, ip, sib_blkno, -1, &sib_buf, w))) 1777 if ((error = xfs_da_read_buf(tp, ip, sib_blkno, -1, &sib_buf, w)))
1791 goto done; 1778 goto done;
1792 sib_info = sib_buf->data; 1779 sib_info = sib_buf->b_addr;
1793 if (unlikely( 1780 if (unlikely(
1794 be32_to_cpu(sib_info->back) != last_blkno || 1781 be32_to_cpu(sib_info->back) != last_blkno ||
1795 sib_info->magic != dead_info->magic)) { 1782 sib_info->magic != dead_info->magic)) {
@@ -1799,10 +1786,9 @@ xfs_da_swap_lastblock(xfs_da_args_t *args, xfs_dablk_t *dead_blknop,
1799 goto done; 1786 goto done;
1800 } 1787 }
1801 sib_info->back = cpu_to_be32(dead_blkno); 1788 sib_info->back = cpu_to_be32(dead_blkno);
1802 xfs_da_log_buf(tp, sib_buf, 1789 xfs_trans_log_buf(tp, sib_buf,
1803 XFS_DA_LOGRANGE(sib_info, &sib_info->back, 1790 XFS_DA_LOGRANGE(sib_info, &sib_info->back,
1804 sizeof(sib_info->back))); 1791 sizeof(sib_info->back)));
1805 xfs_da_buf_done(sib_buf);
1806 sib_buf = NULL; 1792 sib_buf = NULL;
1807 } 1793 }
1808 par_blkno = mp->m_dirleafblk; 1794 par_blkno = mp->m_dirleafblk;
@@ -1813,7 +1799,7 @@ xfs_da_swap_lastblock(xfs_da_args_t *args, xfs_dablk_t *dead_blknop,
1813 for (;;) { 1799 for (;;) {
1814 if ((error = xfs_da_read_buf(tp, ip, par_blkno, -1, &par_buf, w))) 1800 if ((error = xfs_da_read_buf(tp, ip, par_blkno, -1, &par_buf, w)))
1815 goto done; 1801 goto done;
1816 par_node = par_buf->data; 1802 par_node = par_buf->b_addr;
1817 if (unlikely(par_node->hdr.info.magic != 1803 if (unlikely(par_node->hdr.info.magic !=
1818 cpu_to_be16(XFS_DA_NODE_MAGIC) || 1804 cpu_to_be16(XFS_DA_NODE_MAGIC) ||
1819 (level >= 0 && level != be16_to_cpu(par_node->hdr.level) + 1))) { 1805 (level >= 0 && level != be16_to_cpu(par_node->hdr.level) + 1))) {
@@ -1837,7 +1823,7 @@ xfs_da_swap_lastblock(xfs_da_args_t *args, xfs_dablk_t *dead_blknop,
1837 par_blkno = be32_to_cpu(par_node->btree[entno].before); 1823 par_blkno = be32_to_cpu(par_node->btree[entno].before);
1838 if (level == dead_level + 1) 1824 if (level == dead_level + 1)
1839 break; 1825 break;
1840 xfs_da_brelse(tp, par_buf); 1826 xfs_trans_brelse(tp, par_buf);
1841 par_buf = NULL; 1827 par_buf = NULL;
1842 } 1828 }
1843 /* 1829 /*
@@ -1853,7 +1839,7 @@ xfs_da_swap_lastblock(xfs_da_args_t *args, xfs_dablk_t *dead_blknop,
1853 if (entno < be16_to_cpu(par_node->hdr.count)) 1839 if (entno < be16_to_cpu(par_node->hdr.count))
1854 break; 1840 break;
1855 par_blkno = be32_to_cpu(par_node->hdr.info.forw); 1841 par_blkno = be32_to_cpu(par_node->hdr.info.forw);
1856 xfs_da_brelse(tp, par_buf); 1842 xfs_trans_brelse(tp, par_buf);
1857 par_buf = NULL; 1843 par_buf = NULL;
1858 if (unlikely(par_blkno == 0)) { 1844 if (unlikely(par_blkno == 0)) {
1859 XFS_ERROR_REPORT("xfs_da_swap_lastblock(6)", 1845 XFS_ERROR_REPORT("xfs_da_swap_lastblock(6)",
@@ -1863,7 +1849,7 @@ xfs_da_swap_lastblock(xfs_da_args_t *args, xfs_dablk_t *dead_blknop,
1863 } 1849 }
1864 if ((error = xfs_da_read_buf(tp, ip, par_blkno, -1, &par_buf, w))) 1850 if ((error = xfs_da_read_buf(tp, ip, par_blkno, -1, &par_buf, w)))
1865 goto done; 1851 goto done;
1866 par_node = par_buf->data; 1852 par_node = par_buf->b_addr;
1867 if (unlikely( 1853 if (unlikely(
1868 be16_to_cpu(par_node->hdr.level) != level || 1854 be16_to_cpu(par_node->hdr.level) != level ||
1869 par_node->hdr.info.magic != cpu_to_be16(XFS_DA_NODE_MAGIC))) { 1855 par_node->hdr.info.magic != cpu_to_be16(XFS_DA_NODE_MAGIC))) {
@@ -1878,20 +1864,18 @@ xfs_da_swap_lastblock(xfs_da_args_t *args, xfs_dablk_t *dead_blknop,
1878 * Update the parent entry pointing to the moved block. 1864 * Update the parent entry pointing to the moved block.
1879 */ 1865 */
1880 par_node->btree[entno].before = cpu_to_be32(dead_blkno); 1866 par_node->btree[entno].before = cpu_to_be32(dead_blkno);
1881 xfs_da_log_buf(tp, par_buf, 1867 xfs_trans_log_buf(tp, par_buf,
1882 XFS_DA_LOGRANGE(par_node, &par_node->btree[entno].before, 1868 XFS_DA_LOGRANGE(par_node, &par_node->btree[entno].before,
1883 sizeof(par_node->btree[entno].before))); 1869 sizeof(par_node->btree[entno].before)));
1884 xfs_da_buf_done(par_buf);
1885 xfs_da_buf_done(dead_buf);
1886 *dead_blknop = last_blkno; 1870 *dead_blknop = last_blkno;
1887 *dead_bufp = last_buf; 1871 *dead_bufp = last_buf;
1888 return 0; 1872 return 0;
1889done: 1873done:
1890 if (par_buf) 1874 if (par_buf)
1891 xfs_da_brelse(tp, par_buf); 1875 xfs_trans_brelse(tp, par_buf);
1892 if (sib_buf) 1876 if (sib_buf)
1893 xfs_da_brelse(tp, sib_buf); 1877 xfs_trans_brelse(tp, sib_buf);
1894 xfs_da_brelse(tp, last_buf); 1878 xfs_trans_brelse(tp, last_buf);
1895 return error; 1879 return error;
1896} 1880}
1897 1881
@@ -1899,8 +1883,10 @@ done:
1899 * Remove a btree block from a directory or attribute. 1883 * Remove a btree block from a directory or attribute.
1900 */ 1884 */
1901int 1885int
1902xfs_da_shrink_inode(xfs_da_args_t *args, xfs_dablk_t dead_blkno, 1886xfs_da_shrink_inode(
1903 xfs_dabuf_t *dead_buf) 1887 xfs_da_args_t *args,
1888 xfs_dablk_t dead_blkno,
1889 struct xfs_buf *dead_buf)
1904{ 1890{
1905 xfs_inode_t *dp; 1891 xfs_inode_t *dp;
1906 int done, error, w, count; 1892 int done, error, w, count;
@@ -1935,7 +1921,7 @@ xfs_da_shrink_inode(xfs_da_args_t *args, xfs_dablk_t dead_blkno,
1935 break; 1921 break;
1936 } 1922 }
1937 } 1923 }
1938 xfs_da_binval(tp, dead_buf); 1924 xfs_trans_binval(tp, dead_buf);
1939 return error; 1925 return error;
1940} 1926}
1941 1927
@@ -2099,7 +2085,7 @@ xfs_da_get_buf(
2099 struct xfs_inode *dp, 2085 struct xfs_inode *dp,
2100 xfs_dablk_t bno, 2086 xfs_dablk_t bno,
2101 xfs_daddr_t mappedbno, 2087 xfs_daddr_t mappedbno,
2102 xfs_dabuf_t **bpp, 2088 struct xfs_buf **bpp,
2103 int whichfork) 2089 int whichfork)
2104{ 2090{
2105 struct xfs_buf *bp; 2091 struct xfs_buf *bp;
@@ -2128,7 +2114,7 @@ xfs_da_get_buf(
2128 goto out_free; 2114 goto out_free;
2129 } 2115 }
2130 2116
2131 *bpp = xfs_da_buf_make(bp); 2117 *bpp = bp;
2132 2118
2133out_free: 2119out_free:
2134 if (mapp != &map) 2120 if (mapp != &map)
@@ -2146,7 +2132,7 @@ xfs_da_read_buf(
2146 struct xfs_inode *dp, 2132 struct xfs_inode *dp,
2147 xfs_dablk_t bno, 2133 xfs_dablk_t bno,
2148 xfs_daddr_t mappedbno, 2134 xfs_daddr_t mappedbno,
2149 xfs_dabuf_t **bpp, 2135 struct xfs_buf **bpp,
2150 int whichfork) 2136 int whichfork)
2151{ 2137{
2152 struct xfs_buf *bp; 2138 struct xfs_buf *bp;
@@ -2178,16 +2164,14 @@ xfs_da_read_buf(
2178 else 2164 else
2179 xfs_buf_set_ref(bp, XFS_DIR_BTREE_REF); 2165 xfs_buf_set_ref(bp, XFS_DIR_BTREE_REF);
2180 2166
2181 *bpp = xfs_da_buf_make(bp);
2182
2183 /* 2167 /*
2184 * This verification code will be moved to a CRC verification callback 2168 * This verification code will be moved to a CRC verification callback
2185 * function so just leave it here unchanged until then. 2169 * function so just leave it here unchanged until then.
2186 */ 2170 */
2187 { 2171 {
2188 xfs_dir2_data_hdr_t *hdr = (*bpp)->data; 2172 xfs_dir2_data_hdr_t *hdr = bp->b_addr;
2189 xfs_dir2_free_t *free = (*bpp)->data; 2173 xfs_dir2_free_t *free = bp->b_addr;
2190 xfs_da_blkinfo_t *info = (*bpp)->data; 2174 xfs_da_blkinfo_t *info = bp->b_addr;
2191 uint magic, magic1; 2175 uint magic, magic1;
2192 struct xfs_mount *mp = dp->i_mount; 2176 struct xfs_mount *mp = dp->i_mount;
2193 2177
@@ -2207,11 +2191,11 @@ xfs_da_read_buf(
2207 XFS_CORRUPTION_ERROR("xfs_da_do_buf(2)", 2191 XFS_CORRUPTION_ERROR("xfs_da_do_buf(2)",
2208 XFS_ERRLEVEL_LOW, mp, info); 2192 XFS_ERRLEVEL_LOW, mp, info);
2209 error = XFS_ERROR(EFSCORRUPTED); 2193 error = XFS_ERROR(EFSCORRUPTED);
2210 xfs_da_brelse(trans, *bpp); 2194 xfs_trans_brelse(trans, bp);
2211 goto out_free; 2195 goto out_free;
2212 } 2196 }
2213 } 2197 }
2214 2198 *bpp = bp;
2215out_free: 2199out_free:
2216 if (mapp != &map) 2200 if (mapp != &map)
2217 kmem_free(mapp); 2201 kmem_free(mapp);
@@ -2259,7 +2243,6 @@ out_free:
2259} 2243}
2260 2244
2261kmem_zone_t *xfs_da_state_zone; /* anchor for state struct zone */ 2245kmem_zone_t *xfs_da_state_zone; /* anchor for state struct zone */
2262kmem_zone_t *xfs_dabuf_zone; /* dabuf zone */
2263 2246
2264/* 2247/*
2265 * Allocate a dir-state structure. 2248 * Allocate a dir-state structure.
@@ -2279,13 +2262,8 @@ xfs_da_state_kill_altpath(xfs_da_state_t *state)
2279{ 2262{
2280 int i; 2263 int i;
2281 2264
2282 for (i = 0; i < state->altpath.active; i++) { 2265 for (i = 0; i < state->altpath.active; i++)
2283 if (state->altpath.blk[i].bp) { 2266 state->altpath.blk[i].bp = NULL;
2284 if (state->altpath.blk[i].bp != state->path.blk[i].bp)
2285 xfs_da_buf_done(state->altpath.blk[i].bp);
2286 state->altpath.blk[i].bp = NULL;
2287 }
2288 }
2289 state->altpath.active = 0; 2267 state->altpath.active = 0;
2290} 2268}
2291 2269
@@ -2295,88 +2273,9 @@ xfs_da_state_kill_altpath(xfs_da_state_t *state)
2295void 2273void
2296xfs_da_state_free(xfs_da_state_t *state) 2274xfs_da_state_free(xfs_da_state_t *state)
2297{ 2275{
2298 int i;
2299
2300 xfs_da_state_kill_altpath(state); 2276 xfs_da_state_kill_altpath(state);
2301 for (i = 0; i < state->path.active; i++) {
2302 if (state->path.blk[i].bp)
2303 xfs_da_buf_done(state->path.blk[i].bp);
2304 }
2305 if (state->extravalid && state->extrablk.bp)
2306 xfs_da_buf_done(state->extrablk.bp);
2307#ifdef DEBUG 2277#ifdef DEBUG
2308 memset((char *)state, 0, sizeof(*state)); 2278 memset((char *)state, 0, sizeof(*state));
2309#endif /* DEBUG */ 2279#endif /* DEBUG */
2310 kmem_zone_free(xfs_da_state_zone, state); 2280 kmem_zone_free(xfs_da_state_zone, state);
2311} 2281}
2312
2313/*
2314 * Create a dabuf.
2315 */
2316/* ARGSUSED */
2317STATIC xfs_dabuf_t *
2318xfs_da_buf_make(xfs_buf_t *bp)
2319{
2320 xfs_dabuf_t *dabuf;
2321
2322 dabuf = kmem_zone_alloc(xfs_dabuf_zone, KM_NOFS);
2323 dabuf->bbcount = bp->b_length;
2324 dabuf->data = bp->b_addr;
2325 dabuf->bp = bp;
2326 return dabuf;
2327}
2328
2329/*
2330 * Release a dabuf.
2331 */
2332void
2333xfs_da_buf_done(xfs_dabuf_t *dabuf)
2334{
2335 ASSERT(dabuf->data && dabuf->bbcount && dabuf->bp);
2336 kmem_zone_free(xfs_dabuf_zone, dabuf);
2337}
2338
2339/*
2340 * Log transaction from a dabuf.
2341 */
2342void
2343xfs_da_log_buf(xfs_trans_t *tp, xfs_dabuf_t *dabuf, uint first, uint last)
2344{
2345 ASSERT(dabuf->data && dabuf->bbcount && dabuf->bp);
2346 ASSERT(dabuf->data == dabuf->bp->b_addr);
2347 xfs_trans_log_buf(tp, dabuf->bp, first, last);
2348}
2349
2350/*
2351 * Release dabuf from a transaction.
2352 * Have to free up the dabuf before the buffers are released,
2353 * since the synchronization on the dabuf is really the lock on the buffer.
2354 */
2355void
2356xfs_da_brelse(xfs_trans_t *tp, xfs_dabuf_t *dabuf)
2357{
2358 ASSERT(dabuf->data && dabuf->bbcount && dabuf->bp);
2359 xfs_trans_brelse(tp, dabuf->bp);
2360 xfs_da_buf_done(dabuf);
2361}
2362
2363/*
2364 * Invalidate dabuf from a transaction.
2365 */
2366void
2367xfs_da_binval(xfs_trans_t *tp, xfs_dabuf_t *dabuf)
2368{
2369 ASSERT(dabuf->data && dabuf->bbcount && dabuf->bp);
2370 xfs_da_buf_done(dabuf);
2371 xfs_trans_binval(tp, dabuf->bp);
2372}
2373
2374/*
2375 * Get the first daddr from a dabuf.
2376 */
2377xfs_daddr_t
2378xfs_da_blkno(xfs_dabuf_t *dabuf)
2379{
2380 ASSERT(dabuf->data);
2381 return XFS_BUF_ADDR(dabuf->bp);
2382}
diff --git a/fs/xfs/xfs_da_btree.h b/fs/xfs/xfs_da_btree.h
index 0b64c4a37afb..9f37aa03eb38 100644
--- a/fs/xfs/xfs_da_btree.h
+++ b/fs/xfs/xfs_da_btree.h
@@ -133,20 +133,6 @@ typedef struct xfs_da_args {
133 { XFS_DA_OP_CILOOKUP, "CILOOKUP" } 133 { XFS_DA_OP_CILOOKUP, "CILOOKUP" }
134 134
135/* 135/*
136 * Structure to describe buffer(s) for a block.
137 * This is needed in the directory version 2 format case, when
138 * multiple non-contiguous fsblocks might be needed to cover one
139 * logical directory block.
140 * If the buffer count is 1 then the data pointer points to the
141 * same place as the b_addr field for the buffer, else to kmem_alloced memory.
142 */
143typedef struct xfs_dabuf {
144 short bbcount; /* how large is data in bbs */
145 void *data; /* pointer for buffers' data */
146 struct xfs_buf *bp; /* actually nbuf of these */
147} xfs_dabuf_t;
148
149/*
150 * Storage for holding state during Btree searches and split/join ops. 136 * Storage for holding state during Btree searches and split/join ops.
151 * 137 *
152 * Only need space for 5 intermediate nodes. With a minimum of 62-way 138 * Only need space for 5 intermediate nodes. With a minimum of 62-way
@@ -154,7 +140,7 @@ typedef struct xfs_dabuf {
154 * which is slightly more than enough. 140 * which is slightly more than enough.
155 */ 141 */
156typedef struct xfs_da_state_blk { 142typedef struct xfs_da_state_blk {
157 xfs_dabuf_t *bp; /* buffer containing block */ 143 struct xfs_buf *bp; /* buffer containing block */
158 xfs_dablk_t blkno; /* filesystem blkno of buffer */ 144 xfs_dablk_t blkno; /* filesystem blkno of buffer */
159 xfs_daddr_t disk_blkno; /* on-disk blkno (in BBs) of buffer */ 145 xfs_daddr_t disk_blkno; /* on-disk blkno (in BBs) of buffer */
160 int index; /* relevant index into block */ 146 int index; /* relevant index into block */
@@ -207,7 +193,7 @@ struct xfs_nameops {
207 * Routines used for growing the Btree. 193 * Routines used for growing the Btree.
208 */ 194 */
209int xfs_da_node_create(xfs_da_args_t *args, xfs_dablk_t blkno, int level, 195int xfs_da_node_create(xfs_da_args_t *args, xfs_dablk_t blkno, int level,
210 xfs_dabuf_t **bpp, int whichfork); 196 struct xfs_buf **bpp, int whichfork);
211int xfs_da_split(xfs_da_state_t *state); 197int xfs_da_split(xfs_da_state_t *state);
212 198
213/* 199/*
@@ -237,14 +223,14 @@ int xfs_da_grow_inode_int(struct xfs_da_args *args, xfs_fileoff_t *bno,
237 int count); 223 int count);
238int xfs_da_get_buf(struct xfs_trans *trans, struct xfs_inode *dp, 224int xfs_da_get_buf(struct xfs_trans *trans, struct xfs_inode *dp,
239 xfs_dablk_t bno, xfs_daddr_t mappedbno, 225 xfs_dablk_t bno, xfs_daddr_t mappedbno,
240 xfs_dabuf_t **bp, int whichfork); 226 struct xfs_buf **bp, int whichfork);
241int xfs_da_read_buf(struct xfs_trans *trans, struct xfs_inode *dp, 227int xfs_da_read_buf(struct xfs_trans *trans, struct xfs_inode *dp,
242 xfs_dablk_t bno, xfs_daddr_t mappedbno, 228 xfs_dablk_t bno, xfs_daddr_t mappedbno,
243 xfs_dabuf_t **bpp, int whichfork); 229 struct xfs_buf **bpp, int whichfork);
244xfs_daddr_t xfs_da_reada_buf(struct xfs_trans *trans, struct xfs_inode *dp, 230xfs_daddr_t xfs_da_reada_buf(struct xfs_trans *trans, struct xfs_inode *dp,
245 xfs_dablk_t bno, int whichfork); 231 xfs_dablk_t bno, int whichfork);
246int xfs_da_shrink_inode(xfs_da_args_t *args, xfs_dablk_t dead_blkno, 232int xfs_da_shrink_inode(xfs_da_args_t *args, xfs_dablk_t dead_blkno,
247 xfs_dabuf_t *dead_buf); 233 struct xfs_buf *dead_buf);
248 234
249uint xfs_da_hashname(const __uint8_t *name_string, int name_length); 235uint xfs_da_hashname(const __uint8_t *name_string, int name_length);
250enum xfs_dacmp xfs_da_compname(struct xfs_da_args *args, 236enum xfs_dacmp xfs_da_compname(struct xfs_da_args *args,
@@ -254,15 +240,7 @@ enum xfs_dacmp xfs_da_compname(struct xfs_da_args *args,
254xfs_da_state_t *xfs_da_state_alloc(void); 240xfs_da_state_t *xfs_da_state_alloc(void);
255void xfs_da_state_free(xfs_da_state_t *state); 241void xfs_da_state_free(xfs_da_state_t *state);
256 242
257void xfs_da_buf_done(xfs_dabuf_t *dabuf);
258void xfs_da_log_buf(struct xfs_trans *tp, xfs_dabuf_t *dabuf, uint first,
259 uint last);
260void xfs_da_brelse(struct xfs_trans *tp, xfs_dabuf_t *dabuf);
261void xfs_da_binval(struct xfs_trans *tp, xfs_dabuf_t *dabuf);
262xfs_daddr_t xfs_da_blkno(xfs_dabuf_t *dabuf);
263
264extern struct kmem_zone *xfs_da_state_zone; 243extern struct kmem_zone *xfs_da_state_zone;
265extern struct kmem_zone *xfs_dabuf_zone;
266extern const struct xfs_nameops xfs_default_nameops; 244extern const struct xfs_nameops xfs_default_nameops;
267 245
268#endif /* __XFS_DA_BTREE_H__ */ 246#endif /* __XFS_DA_BTREE_H__ */
diff --git a/fs/xfs/xfs_dir2.c b/fs/xfs/xfs_dir2.c
index 67a250c36d41..b26a50f9921d 100644
--- a/fs/xfs/xfs_dir2.c
+++ b/fs/xfs/xfs_dir2.c
@@ -592,7 +592,7 @@ int
592xfs_dir2_shrink_inode( 592xfs_dir2_shrink_inode(
593 xfs_da_args_t *args, 593 xfs_da_args_t *args,
594 xfs_dir2_db_t db, 594 xfs_dir2_db_t db,
595 xfs_dabuf_t *bp) 595 struct xfs_buf *bp)
596{ 596{
597 xfs_fileoff_t bno; /* directory file offset */ 597 xfs_fileoff_t bno; /* directory file offset */
598 xfs_dablk_t da; /* directory file offset */ 598 xfs_dablk_t da; /* directory file offset */
@@ -634,7 +634,7 @@ xfs_dir2_shrink_inode(
634 /* 634 /*
635 * Invalidate the buffer from the transaction. 635 * Invalidate the buffer from the transaction.
636 */ 636 */
637 xfs_da_binval(tp, bp); 637 xfs_trans_binval(tp, bp);
638 /* 638 /*
639 * If it's not a data block, we're done. 639 * If it's not a data block, we're done.
640 */ 640 */
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}
diff --git a/fs/xfs/xfs_dir2_data.c b/fs/xfs/xfs_dir2_data.c
index 2046988e9eb2..44ffd4d6bc91 100644
--- a/fs/xfs/xfs_dir2_data.c
+++ b/fs/xfs/xfs_dir2_data.c
@@ -42,8 +42,8 @@ xfs_dir2_data_freefind(xfs_dir2_data_hdr_t *hdr, xfs_dir2_data_unused_t *dup);
42 */ 42 */
43void 43void
44xfs_dir2_data_check( 44xfs_dir2_data_check(
45 xfs_inode_t *dp, /* incore inode pointer */ 45 struct xfs_inode *dp, /* incore inode pointer */
46 xfs_dabuf_t *bp) /* data block's buffer */ 46 struct xfs_buf *bp) /* data block's buffer */
47{ 47{
48 xfs_dir2_dataptr_t addr; /* addr for leaf lookup */ 48 xfs_dir2_dataptr_t addr; /* addr for leaf lookup */
49 xfs_dir2_data_free_t *bf; /* bestfree table */ 49 xfs_dir2_data_free_t *bf; /* bestfree table */
@@ -65,7 +65,7 @@ xfs_dir2_data_check(
65 struct xfs_name name; 65 struct xfs_name name;
66 66
67 mp = dp->i_mount; 67 mp = dp->i_mount;
68 hdr = bp->data; 68 hdr = bp->b_addr;
69 bf = hdr->bestfree; 69 bf = hdr->bestfree;
70 p = (char *)(hdr + 1); 70 p = (char *)(hdr + 1);
71 71
@@ -389,9 +389,9 @@ int /* error */
389xfs_dir2_data_init( 389xfs_dir2_data_init(
390 xfs_da_args_t *args, /* directory operation args */ 390 xfs_da_args_t *args, /* directory operation args */
391 xfs_dir2_db_t blkno, /* logical dir block number */ 391 xfs_dir2_db_t blkno, /* logical dir block number */
392 xfs_dabuf_t **bpp) /* output block buffer */ 392 struct xfs_buf **bpp) /* output block buffer */
393{ 393{
394 xfs_dabuf_t *bp; /* block buffer */ 394 struct xfs_buf *bp; /* block buffer */
395 xfs_dir2_data_hdr_t *hdr; /* data block header */ 395 xfs_dir2_data_hdr_t *hdr; /* data block header */
396 xfs_inode_t *dp; /* incore directory inode */ 396 xfs_inode_t *dp; /* incore directory inode */
397 xfs_dir2_data_unused_t *dup; /* unused entry pointer */ 397 xfs_dir2_data_unused_t *dup; /* unused entry pointer */
@@ -417,7 +417,7 @@ xfs_dir2_data_init(
417 /* 417 /*
418 * Initialize the header. 418 * Initialize the header.
419 */ 419 */
420 hdr = bp->data; 420 hdr = bp->b_addr;
421 hdr->magic = cpu_to_be32(XFS_DIR2_DATA_MAGIC); 421 hdr->magic = cpu_to_be32(XFS_DIR2_DATA_MAGIC);
422 hdr->bestfree[0].offset = cpu_to_be16(sizeof(*hdr)); 422 hdr->bestfree[0].offset = cpu_to_be16(sizeof(*hdr));
423 for (i = 1; i < XFS_DIR2_DATA_FD_COUNT; i++) { 423 for (i = 1; i < XFS_DIR2_DATA_FD_COUNT; i++) {
@@ -449,16 +449,16 @@ xfs_dir2_data_init(
449 */ 449 */
450void 450void
451xfs_dir2_data_log_entry( 451xfs_dir2_data_log_entry(
452 xfs_trans_t *tp, /* transaction pointer */ 452 struct xfs_trans *tp,
453 xfs_dabuf_t *bp, /* block buffer */ 453 struct xfs_buf *bp,
454 xfs_dir2_data_entry_t *dep) /* data entry pointer */ 454 xfs_dir2_data_entry_t *dep) /* data entry pointer */
455{ 455{
456 xfs_dir2_data_hdr_t *hdr = bp->data; 456 xfs_dir2_data_hdr_t *hdr = bp->b_addr;
457 457
458 ASSERT(hdr->magic == cpu_to_be32(XFS_DIR2_DATA_MAGIC) || 458 ASSERT(hdr->magic == cpu_to_be32(XFS_DIR2_DATA_MAGIC) ||
459 hdr->magic == cpu_to_be32(XFS_DIR2_BLOCK_MAGIC)); 459 hdr->magic == cpu_to_be32(XFS_DIR2_BLOCK_MAGIC));
460 460
461 xfs_da_log_buf(tp, bp, (uint)((char *)dep - (char *)hdr), 461 xfs_trans_log_buf(tp, bp, (uint)((char *)dep - (char *)hdr),
462 (uint)((char *)(xfs_dir2_data_entry_tag_p(dep) + 1) - 462 (uint)((char *)(xfs_dir2_data_entry_tag_p(dep) + 1) -
463 (char *)hdr - 1)); 463 (char *)hdr - 1));
464} 464}
@@ -468,15 +468,15 @@ xfs_dir2_data_log_entry(
468 */ 468 */
469void 469void
470xfs_dir2_data_log_header( 470xfs_dir2_data_log_header(
471 xfs_trans_t *tp, /* transaction pointer */ 471 struct xfs_trans *tp,
472 xfs_dabuf_t *bp) /* block buffer */ 472 struct xfs_buf *bp)
473{ 473{
474 xfs_dir2_data_hdr_t *hdr = bp->data; 474 xfs_dir2_data_hdr_t *hdr = bp->b_addr;
475 475
476 ASSERT(hdr->magic == cpu_to_be32(XFS_DIR2_DATA_MAGIC) || 476 ASSERT(hdr->magic == cpu_to_be32(XFS_DIR2_DATA_MAGIC) ||
477 hdr->magic == cpu_to_be32(XFS_DIR2_BLOCK_MAGIC)); 477 hdr->magic == cpu_to_be32(XFS_DIR2_BLOCK_MAGIC));
478 478
479 xfs_da_log_buf(tp, bp, 0, sizeof(*hdr) - 1); 479 xfs_trans_log_buf(tp, bp, 0, sizeof(*hdr) - 1);
480} 480}
481 481
482/* 482/*
@@ -484,11 +484,11 @@ xfs_dir2_data_log_header(
484 */ 484 */
485void 485void
486xfs_dir2_data_log_unused( 486xfs_dir2_data_log_unused(
487 xfs_trans_t *tp, /* transaction pointer */ 487 struct xfs_trans *tp,
488 xfs_dabuf_t *bp, /* block buffer */ 488 struct xfs_buf *bp,
489 xfs_dir2_data_unused_t *dup) /* data unused pointer */ 489 xfs_dir2_data_unused_t *dup) /* data unused pointer */
490{ 490{
491 xfs_dir2_data_hdr_t *hdr = bp->data; 491 xfs_dir2_data_hdr_t *hdr = bp->b_addr;
492 492
493 ASSERT(hdr->magic == cpu_to_be32(XFS_DIR2_DATA_MAGIC) || 493 ASSERT(hdr->magic == cpu_to_be32(XFS_DIR2_DATA_MAGIC) ||
494 hdr->magic == cpu_to_be32(XFS_DIR2_BLOCK_MAGIC)); 494 hdr->magic == cpu_to_be32(XFS_DIR2_BLOCK_MAGIC));
@@ -496,13 +496,13 @@ xfs_dir2_data_log_unused(
496 /* 496 /*
497 * Log the first part of the unused entry. 497 * Log the first part of the unused entry.
498 */ 498 */
499 xfs_da_log_buf(tp, bp, (uint)((char *)dup - (char *)hdr), 499 xfs_trans_log_buf(tp, bp, (uint)((char *)dup - (char *)hdr),
500 (uint)((char *)&dup->length + sizeof(dup->length) - 500 (uint)((char *)&dup->length + sizeof(dup->length) -
501 1 - (char *)hdr)); 501 1 - (char *)hdr));
502 /* 502 /*
503 * Log the end (tag) of the unused entry. 503 * Log the end (tag) of the unused entry.
504 */ 504 */
505 xfs_da_log_buf(tp, bp, 505 xfs_trans_log_buf(tp, bp,
506 (uint)((char *)xfs_dir2_data_unused_tag_p(dup) - (char *)hdr), 506 (uint)((char *)xfs_dir2_data_unused_tag_p(dup) - (char *)hdr),
507 (uint)((char *)xfs_dir2_data_unused_tag_p(dup) - (char *)hdr + 507 (uint)((char *)xfs_dir2_data_unused_tag_p(dup) - (char *)hdr +
508 sizeof(xfs_dir2_data_off_t) - 1)); 508 sizeof(xfs_dir2_data_off_t) - 1));
@@ -514,8 +514,8 @@ xfs_dir2_data_log_unused(
514 */ 514 */
515void 515void
516xfs_dir2_data_make_free( 516xfs_dir2_data_make_free(
517 xfs_trans_t *tp, /* transaction pointer */ 517 struct xfs_trans *tp,
518 xfs_dabuf_t *bp, /* block buffer */ 518 struct xfs_buf *bp,
519 xfs_dir2_data_aoff_t offset, /* starting byte offset */ 519 xfs_dir2_data_aoff_t offset, /* starting byte offset */
520 xfs_dir2_data_aoff_t len, /* length in bytes */ 520 xfs_dir2_data_aoff_t len, /* length in bytes */
521 int *needlogp, /* out: log header */ 521 int *needlogp, /* out: log header */
@@ -531,7 +531,7 @@ xfs_dir2_data_make_free(
531 xfs_dir2_data_unused_t *prevdup; /* unused entry before us */ 531 xfs_dir2_data_unused_t *prevdup; /* unused entry before us */
532 532
533 mp = tp->t_mountp; 533 mp = tp->t_mountp;
534 hdr = bp->data; 534 hdr = bp->b_addr;
535 535
536 /* 536 /*
537 * Figure out where the end of the data area is. 537 * Figure out where the end of the data area is.
@@ -696,8 +696,8 @@ xfs_dir2_data_make_free(
696 */ 696 */
697void 697void
698xfs_dir2_data_use_free( 698xfs_dir2_data_use_free(
699 xfs_trans_t *tp, /* transaction pointer */ 699 struct xfs_trans *tp,
700 xfs_dabuf_t *bp, /* data block buffer */ 700 struct xfs_buf *bp,
701 xfs_dir2_data_unused_t *dup, /* unused entry */ 701 xfs_dir2_data_unused_t *dup, /* unused entry */
702 xfs_dir2_data_aoff_t offset, /* starting offset to use */ 702 xfs_dir2_data_aoff_t offset, /* starting offset to use */
703 xfs_dir2_data_aoff_t len, /* length to use */ 703 xfs_dir2_data_aoff_t len, /* length to use */
@@ -713,7 +713,7 @@ xfs_dir2_data_use_free(
713 xfs_dir2_data_unused_t *newdup2; /* another new unused entry */ 713 xfs_dir2_data_unused_t *newdup2; /* another new unused entry */
714 int oldlen; /* old unused entry's length */ 714 int oldlen; /* old unused entry's length */
715 715
716 hdr = bp->data; 716 hdr = bp->b_addr;
717 ASSERT(hdr->magic == cpu_to_be32(XFS_DIR2_DATA_MAGIC) || 717 ASSERT(hdr->magic == cpu_to_be32(XFS_DIR2_DATA_MAGIC) ||
718 hdr->magic == cpu_to_be32(XFS_DIR2_BLOCK_MAGIC)); 718 hdr->magic == cpu_to_be32(XFS_DIR2_BLOCK_MAGIC));
719 ASSERT(be16_to_cpu(dup->freetag) == XFS_DIR2_DATA_FREE_TAG); 719 ASSERT(be16_to_cpu(dup->freetag) == XFS_DIR2_DATA_FREE_TAG);
diff --git a/fs/xfs/xfs_dir2_leaf.c b/fs/xfs/xfs_dir2_leaf.c
index 397ffbcbab1d..69accf6cbc46 100644
--- a/fs/xfs/xfs_dir2_leaf.c
+++ b/fs/xfs/xfs_dir2_leaf.c
@@ -38,15 +38,15 @@
38 * Local function declarations. 38 * Local function declarations.
39 */ 39 */
40#ifdef DEBUG 40#ifdef DEBUG
41static void xfs_dir2_leaf_check(xfs_inode_t *dp, xfs_dabuf_t *bp); 41static void xfs_dir2_leaf_check(struct xfs_inode *dp, struct xfs_buf *bp);
42#else 42#else
43#define xfs_dir2_leaf_check(dp, bp) 43#define xfs_dir2_leaf_check(dp, bp)
44#endif 44#endif
45static int xfs_dir2_leaf_lookup_int(xfs_da_args_t *args, xfs_dabuf_t **lbpp, 45static int xfs_dir2_leaf_lookup_int(xfs_da_args_t *args, struct xfs_buf **lbpp,
46 int *indexp, xfs_dabuf_t **dbpp); 46 int *indexp, struct xfs_buf **dbpp);
47static void xfs_dir2_leaf_log_bests(struct xfs_trans *tp, struct xfs_dabuf *bp, 47static void xfs_dir2_leaf_log_bests(struct xfs_trans *tp, struct xfs_buf *bp,
48 int first, int last); 48 int first, int last);
49static void xfs_dir2_leaf_log_tail(struct xfs_trans *tp, struct xfs_dabuf *bp); 49static void xfs_dir2_leaf_log_tail(struct xfs_trans *tp, struct xfs_buf *bp);
50 50
51 51
52/* 52/*
@@ -55,7 +55,7 @@ static void xfs_dir2_leaf_log_tail(struct xfs_trans *tp, struct xfs_dabuf *bp);
55int /* error */ 55int /* error */
56xfs_dir2_block_to_leaf( 56xfs_dir2_block_to_leaf(
57 xfs_da_args_t *args, /* operation arguments */ 57 xfs_da_args_t *args, /* operation arguments */
58 xfs_dabuf_t *dbp) /* input block's buffer */ 58 struct xfs_buf *dbp) /* input block's buffer */
59{ 59{
60 __be16 *bestsp; /* leaf's bestsp entries */ 60 __be16 *bestsp; /* leaf's bestsp entries */
61 xfs_dablk_t blkno; /* leaf block's bno */ 61 xfs_dablk_t blkno; /* leaf block's bno */
@@ -64,7 +64,7 @@ xfs_dir2_block_to_leaf(
64 xfs_dir2_block_tail_t *btp; /* block's tail */ 64 xfs_dir2_block_tail_t *btp; /* block's tail */
65 xfs_inode_t *dp; /* incore directory inode */ 65 xfs_inode_t *dp; /* incore directory inode */
66 int error; /* error return code */ 66 int error; /* error return code */
67 xfs_dabuf_t *lbp; /* leaf block's buffer */ 67 struct xfs_buf *lbp; /* leaf block's buffer */
68 xfs_dir2_db_t ldb; /* leaf block's bno */ 68 xfs_dir2_db_t ldb; /* leaf block's bno */
69 xfs_dir2_leaf_t *leaf; /* leaf structure */ 69 xfs_dir2_leaf_t *leaf; /* leaf structure */
70 xfs_dir2_leaf_tail_t *ltp; /* leaf's tail */ 70 xfs_dir2_leaf_tail_t *ltp; /* leaf's tail */
@@ -95,8 +95,8 @@ xfs_dir2_block_to_leaf(
95 return error; 95 return error;
96 } 96 }
97 ASSERT(lbp != NULL); 97 ASSERT(lbp != NULL);
98 leaf = lbp->data; 98 leaf = lbp->b_addr;
99 hdr = dbp->data; 99 hdr = dbp->b_addr;
100 xfs_dir2_data_check(dp, dbp); 100 xfs_dir2_data_check(dp, dbp);
101 btp = xfs_dir2_block_tail_p(mp, hdr); 101 btp = xfs_dir2_block_tail_p(mp, hdr);
102 blp = xfs_dir2_block_leaf_p(btp); 102 blp = xfs_dir2_block_leaf_p(btp);
@@ -143,7 +143,6 @@ xfs_dir2_block_to_leaf(
143 xfs_dir2_leaf_check(dp, lbp); 143 xfs_dir2_leaf_check(dp, lbp);
144 xfs_dir2_data_check(dp, dbp); 144 xfs_dir2_data_check(dp, dbp);
145 xfs_dir2_leaf_log_bests(tp, lbp, 0, 0); 145 xfs_dir2_leaf_log_bests(tp, lbp, 0, 0);
146 xfs_da_buf_done(lbp);
147 return 0; 146 return 0;
148} 147}
149 148
@@ -282,7 +281,7 @@ xfs_dir2_leaf_addname(
282 __be16 *bestsp; /* freespace table in leaf */ 281 __be16 *bestsp; /* freespace table in leaf */
283 int compact; /* need to compact leaves */ 282 int compact; /* need to compact leaves */
284 xfs_dir2_data_hdr_t *hdr; /* data block header */ 283 xfs_dir2_data_hdr_t *hdr; /* data block header */
285 xfs_dabuf_t *dbp; /* data block buffer */ 284 struct xfs_buf *dbp; /* data block buffer */
286 xfs_dir2_data_entry_t *dep; /* data block entry */ 285 xfs_dir2_data_entry_t *dep; /* data block entry */
287 xfs_inode_t *dp; /* incore directory inode */ 286 xfs_inode_t *dp; /* incore directory inode */
288 xfs_dir2_data_unused_t *dup; /* data unused entry */ 287 xfs_dir2_data_unused_t *dup; /* data unused entry */
@@ -291,7 +290,7 @@ xfs_dir2_leaf_addname(
291 int highstale; /* index of next stale leaf */ 290 int highstale; /* index of next stale leaf */
292 int i; /* temporary, index */ 291 int i; /* temporary, index */
293 int index; /* leaf table position */ 292 int index; /* leaf table position */
294 xfs_dabuf_t *lbp; /* leaf's buffer */ 293 struct xfs_buf *lbp; /* leaf's buffer */
295 xfs_dir2_leaf_t *leaf; /* leaf structure */ 294 xfs_dir2_leaf_t *leaf; /* leaf structure */
296 int length; /* length of new entry */ 295 int length; /* length of new entry */
297 xfs_dir2_leaf_entry_t *lep; /* leaf entry table pointer */ 296 xfs_dir2_leaf_entry_t *lep; /* leaf entry table pointer */
@@ -328,7 +327,7 @@ xfs_dir2_leaf_addname(
328 * But if there are dup hash values the index is of the first of those. 327 * But if there are dup hash values the index is of the first of those.
329 */ 328 */
330 index = xfs_dir2_leaf_search_hash(args, lbp); 329 index = xfs_dir2_leaf_search_hash(args, lbp);
331 leaf = lbp->data; 330 leaf = lbp->b_addr;
332 ltp = xfs_dir2_leaf_tail_p(mp, leaf); 331 ltp = xfs_dir2_leaf_tail_p(mp, leaf);
333 bestsp = xfs_dir2_leaf_bests_p(ltp); 332 bestsp = xfs_dir2_leaf_bests_p(ltp);
334 length = xfs_dir2_data_entsize(args->namelen); 333 length = xfs_dir2_data_entsize(args->namelen);
@@ -402,14 +401,13 @@ xfs_dir2_leaf_addname(
402 */ 401 */
403 if ((args->op_flags & XFS_DA_OP_JUSTCHECK) || 402 if ((args->op_flags & XFS_DA_OP_JUSTCHECK) ||
404 args->total == 0) { 403 args->total == 0) {
405 xfs_da_brelse(tp, lbp); 404 xfs_trans_brelse(tp, lbp);
406 return XFS_ERROR(ENOSPC); 405 return XFS_ERROR(ENOSPC);
407 } 406 }
408 /* 407 /*
409 * Convert to node form. 408 * Convert to node form.
410 */ 409 */
411 error = xfs_dir2_leaf_to_node(args, lbp); 410 error = xfs_dir2_leaf_to_node(args, lbp);
412 xfs_da_buf_done(lbp);
413 if (error) 411 if (error)
414 return error; 412 return error;
415 /* 413 /*
@@ -427,7 +425,7 @@ xfs_dir2_leaf_addname(
427 * a new data block. 425 * a new data block.
428 */ 426 */
429 if (args->op_flags & XFS_DA_OP_JUSTCHECK) { 427 if (args->op_flags & XFS_DA_OP_JUSTCHECK) {
430 xfs_da_brelse(tp, lbp); 428 xfs_trans_brelse(tp, lbp);
431 return use_block == -1 ? XFS_ERROR(ENOSPC) : 0; 429 return use_block == -1 ? XFS_ERROR(ENOSPC) : 0;
432 } 430 }
433 /* 431 /*
@@ -435,7 +433,7 @@ xfs_dir2_leaf_addname(
435 * changed anything. 433 * changed anything.
436 */ 434 */
437 if (args->total == 0 && use_block == -1) { 435 if (args->total == 0 && use_block == -1) {
438 xfs_da_brelse(tp, lbp); 436 xfs_trans_brelse(tp, lbp);
439 return XFS_ERROR(ENOSPC); 437 return XFS_ERROR(ENOSPC);
440 } 438 }
441 /* 439 /*
@@ -466,14 +464,14 @@ xfs_dir2_leaf_addname(
466 */ 464 */
467 if ((error = xfs_dir2_grow_inode(args, XFS_DIR2_DATA_SPACE, 465 if ((error = xfs_dir2_grow_inode(args, XFS_DIR2_DATA_SPACE,
468 &use_block))) { 466 &use_block))) {
469 xfs_da_brelse(tp, lbp); 467 xfs_trans_brelse(tp, lbp);
470 return error; 468 return error;
471 } 469 }
472 /* 470 /*
473 * Initialize the block. 471 * Initialize the block.
474 */ 472 */
475 if ((error = xfs_dir2_data_init(args, use_block, &dbp))) { 473 if ((error = xfs_dir2_data_init(args, use_block, &dbp))) {
476 xfs_da_brelse(tp, lbp); 474 xfs_trans_brelse(tp, lbp);
477 return error; 475 return error;
478 } 476 }
479 /* 477 /*
@@ -493,7 +491,7 @@ xfs_dir2_leaf_addname(
493 */ 491 */
494 else 492 else
495 xfs_dir2_leaf_log_bests(tp, lbp, use_block, use_block); 493 xfs_dir2_leaf_log_bests(tp, lbp, use_block, use_block);
496 hdr = dbp->data; 494 hdr = dbp->b_addr;
497 bestsp[use_block] = hdr->bestfree[0].length; 495 bestsp[use_block] = hdr->bestfree[0].length;
498 grown = 1; 496 grown = 1;
499 } 497 }
@@ -505,10 +503,10 @@ xfs_dir2_leaf_addname(
505 if ((error = 503 if ((error =
506 xfs_da_read_buf(tp, dp, xfs_dir2_db_to_da(mp, use_block), 504 xfs_da_read_buf(tp, dp, xfs_dir2_db_to_da(mp, use_block),
507 -1, &dbp, XFS_DATA_FORK))) { 505 -1, &dbp, XFS_DATA_FORK))) {
508 xfs_da_brelse(tp, lbp); 506 xfs_trans_brelse(tp, lbp);
509 return error; 507 return error;
510 } 508 }
511 hdr = dbp->data; 509 hdr = dbp->b_addr;
512 grown = 0; 510 grown = 0;
513 } 511 }
514 xfs_dir2_data_check(dp, dbp); 512 xfs_dir2_data_check(dp, dbp);
@@ -570,9 +568,7 @@ xfs_dir2_leaf_addname(
570 xfs_dir2_leaf_log_header(tp, lbp); 568 xfs_dir2_leaf_log_header(tp, lbp);
571 xfs_dir2_leaf_log_ents(tp, lbp, lfloglow, lfloghigh); 569 xfs_dir2_leaf_log_ents(tp, lbp, lfloglow, lfloghigh);
572 xfs_dir2_leaf_check(dp, lbp); 570 xfs_dir2_leaf_check(dp, lbp);
573 xfs_da_buf_done(lbp);
574 xfs_dir2_data_check(dp, dbp); 571 xfs_dir2_data_check(dp, dbp);
575 xfs_da_buf_done(dbp);
576 return 0; 572 return 0;
577} 573}
578 574
@@ -583,8 +579,8 @@ xfs_dir2_leaf_addname(
583 */ 579 */
584STATIC void 580STATIC void
585xfs_dir2_leaf_check( 581xfs_dir2_leaf_check(
586 xfs_inode_t *dp, /* incore directory inode */ 582 struct xfs_inode *dp, /* incore directory inode */
587 xfs_dabuf_t *bp) /* leaf's buffer */ 583 struct xfs_buf *bp) /* leaf's buffer */
588{ 584{
589 int i; /* leaf index */ 585 int i; /* leaf index */
590 xfs_dir2_leaf_t *leaf; /* leaf structure */ 586 xfs_dir2_leaf_t *leaf; /* leaf structure */
@@ -592,7 +588,7 @@ xfs_dir2_leaf_check(
592 xfs_mount_t *mp; /* filesystem mount point */ 588 xfs_mount_t *mp; /* filesystem mount point */
593 int stale; /* count of stale leaves */ 589 int stale; /* count of stale leaves */
594 590
595 leaf = bp->data; 591 leaf = bp->b_addr;
596 mp = dp->i_mount; 592 mp = dp->i_mount;
597 ASSERT(leaf->hdr.info.magic == cpu_to_be16(XFS_DIR2_LEAF1_MAGIC)); 593 ASSERT(leaf->hdr.info.magic == cpu_to_be16(XFS_DIR2_LEAF1_MAGIC));
598 /* 594 /*
@@ -628,14 +624,14 @@ xfs_dir2_leaf_check(
628void 624void
629xfs_dir2_leaf_compact( 625xfs_dir2_leaf_compact(
630 xfs_da_args_t *args, /* operation arguments */ 626 xfs_da_args_t *args, /* operation arguments */
631 xfs_dabuf_t *bp) /* leaf buffer */ 627 struct xfs_buf *bp) /* leaf buffer */
632{ 628{
633 int from; /* source leaf index */ 629 int from; /* source leaf index */
634 xfs_dir2_leaf_t *leaf; /* leaf structure */ 630 xfs_dir2_leaf_t *leaf; /* leaf structure */
635 int loglow; /* first leaf entry to log */ 631 int loglow; /* first leaf entry to log */
636 int to; /* target leaf index */ 632 int to; /* target leaf index */
637 633
638 leaf = bp->data; 634 leaf = bp->b_addr;
639 if (!leaf->hdr.stale) { 635 if (!leaf->hdr.stale) {
640 return; 636 return;
641 } 637 }
@@ -677,7 +673,7 @@ xfs_dir2_leaf_compact(
677 */ 673 */
678void 674void
679xfs_dir2_leaf_compact_x1( 675xfs_dir2_leaf_compact_x1(
680 xfs_dabuf_t *bp, /* leaf buffer */ 676 struct xfs_buf *bp, /* leaf buffer */
681 int *indexp, /* insertion index */ 677 int *indexp, /* insertion index */
682 int *lowstalep, /* out: stale entry before us */ 678 int *lowstalep, /* out: stale entry before us */
683 int *highstalep, /* out: stale entry after us */ 679 int *highstalep, /* out: stale entry after us */
@@ -693,7 +689,7 @@ xfs_dir2_leaf_compact_x1(
693 int newindex=0; /* new insertion index */ 689 int newindex=0; /* new insertion index */
694 int to; /* destination copy index */ 690 int to; /* destination copy index */
695 691
696 leaf = bp->data; 692 leaf = bp->b_addr;
697 ASSERT(be16_to_cpu(leaf->hdr.stale) > 1); 693 ASSERT(be16_to_cpu(leaf->hdr.stale) > 1);
698 index = *indexp; 694 index = *indexp;
699 695
@@ -775,7 +771,7 @@ xfs_dir2_leaf_getdents(
775 xfs_off_t *offset, 771 xfs_off_t *offset,
776 filldir_t filldir) 772 filldir_t filldir)
777{ 773{
778 xfs_dabuf_t *bp; /* data block buffer */ 774 struct xfs_buf *bp; /* data block buffer */
779 int byteoff; /* offset in current block */ 775 int byteoff; /* offset in current block */
780 xfs_dir2_db_t curdb; /* db for current block */ 776 xfs_dir2_db_t curdb; /* db for current block */
781 xfs_dir2_off_t curoff; /* current overall offset */ 777 xfs_dir2_off_t curoff; /* current overall offset */
@@ -839,13 +835,13 @@ xfs_dir2_leaf_getdents(
839 * If we have no buffer, or we're off the end of the 835 * If we have no buffer, or we're off the end of the
840 * current buffer, need to get another one. 836 * current buffer, need to get another one.
841 */ 837 */
842 if (!bp || ptr >= (char *)bp->data + mp->m_dirblksize) { 838 if (!bp || ptr >= (char *)bp->b_addr + mp->m_dirblksize) {
843 /* 839 /*
844 * If we have a buffer, we need to release it and 840 * If we have a buffer, we need to release it and
845 * take it out of the mapping. 841 * take it out of the mapping.
846 */ 842 */
847 if (bp) { 843 if (bp) {
848 xfs_da_brelse(NULL, bp); 844 xfs_trans_brelse(NULL, bp);
849 bp = NULL; 845 bp = NULL;
850 map_blocks -= mp->m_dirblkfsbs; 846 map_blocks -= mp->m_dirblkfsbs;
851 /* 847 /*
@@ -1035,7 +1031,7 @@ xfs_dir2_leaf_getdents(
1035 else if (curoff > newoff) 1031 else if (curoff > newoff)
1036 ASSERT(xfs_dir2_byte_to_db(mp, curoff) == 1032 ASSERT(xfs_dir2_byte_to_db(mp, curoff) ==
1037 curdb); 1033 curdb);
1038 hdr = bp->data; 1034 hdr = bp->b_addr;
1039 xfs_dir2_data_check(dp, bp); 1035 xfs_dir2_data_check(dp, bp);
1040 /* 1036 /*
1041 * Find our position in the block. 1037 * Find our position in the block.
@@ -1119,7 +1115,7 @@ xfs_dir2_leaf_getdents(
1119 *offset = xfs_dir2_byte_to_dataptr(mp, curoff) & 0x7fffffff; 1115 *offset = xfs_dir2_byte_to_dataptr(mp, curoff) & 0x7fffffff;
1120 kmem_free(map); 1116 kmem_free(map);
1121 if (bp) 1117 if (bp)
1122 xfs_da_brelse(NULL, bp); 1118 xfs_trans_brelse(NULL, bp);
1123 return error; 1119 return error;
1124} 1120}
1125 1121
@@ -1130,10 +1126,10 @@ int
1130xfs_dir2_leaf_init( 1126xfs_dir2_leaf_init(
1131 xfs_da_args_t *args, /* operation arguments */ 1127 xfs_da_args_t *args, /* operation arguments */
1132 xfs_dir2_db_t bno, /* directory block number */ 1128 xfs_dir2_db_t bno, /* directory block number */
1133 xfs_dabuf_t **bpp, /* out: leaf buffer */ 1129 struct xfs_buf **bpp, /* out: leaf buffer */
1134 int magic) /* magic number for block */ 1130 int magic) /* magic number for block */
1135{ 1131{
1136 xfs_dabuf_t *bp; /* leaf buffer */ 1132 struct xfs_buf *bp; /* leaf buffer */
1137 xfs_inode_t *dp; /* incore directory inode */ 1133 xfs_inode_t *dp; /* incore directory inode */
1138 int error; /* error return code */ 1134 int error; /* error return code */
1139 xfs_dir2_leaf_t *leaf; /* leaf structure */ 1135 xfs_dir2_leaf_t *leaf; /* leaf structure */
@@ -1156,7 +1152,7 @@ xfs_dir2_leaf_init(
1156 return error; 1152 return error;
1157 } 1153 }
1158 ASSERT(bp != NULL); 1154 ASSERT(bp != NULL);
1159 leaf = bp->data; 1155 leaf = bp->b_addr;
1160 /* 1156 /*
1161 * Initialize the header. 1157 * Initialize the header.
1162 */ 1158 */
@@ -1186,7 +1182,7 @@ xfs_dir2_leaf_init(
1186static void 1182static void
1187xfs_dir2_leaf_log_bests( 1183xfs_dir2_leaf_log_bests(
1188 xfs_trans_t *tp, /* transaction pointer */ 1184 xfs_trans_t *tp, /* transaction pointer */
1189 xfs_dabuf_t *bp, /* leaf buffer */ 1185 struct xfs_buf *bp, /* leaf buffer */
1190 int first, /* first entry to log */ 1186 int first, /* first entry to log */
1191 int last) /* last entry to log */ 1187 int last) /* last entry to log */
1192{ 1188{
@@ -1195,12 +1191,12 @@ xfs_dir2_leaf_log_bests(
1195 xfs_dir2_leaf_t *leaf; /* leaf structure */ 1191 xfs_dir2_leaf_t *leaf; /* leaf structure */
1196 xfs_dir2_leaf_tail_t *ltp; /* leaf tail structure */ 1192 xfs_dir2_leaf_tail_t *ltp; /* leaf tail structure */
1197 1193
1198 leaf = bp->data; 1194 leaf = bp->b_addr;
1199 ASSERT(leaf->hdr.info.magic == cpu_to_be16(XFS_DIR2_LEAF1_MAGIC)); 1195 ASSERT(leaf->hdr.info.magic == cpu_to_be16(XFS_DIR2_LEAF1_MAGIC));
1200 ltp = xfs_dir2_leaf_tail_p(tp->t_mountp, leaf); 1196 ltp = xfs_dir2_leaf_tail_p(tp->t_mountp, leaf);
1201 firstb = xfs_dir2_leaf_bests_p(ltp) + first; 1197 firstb = xfs_dir2_leaf_bests_p(ltp) + first;
1202 lastb = xfs_dir2_leaf_bests_p(ltp) + last; 1198 lastb = xfs_dir2_leaf_bests_p(ltp) + last;
1203 xfs_da_log_buf(tp, bp, (uint)((char *)firstb - (char *)leaf), 1199 xfs_trans_log_buf(tp, bp, (uint)((char *)firstb - (char *)leaf),
1204 (uint)((char *)lastb - (char *)leaf + sizeof(*lastb) - 1)); 1200 (uint)((char *)lastb - (char *)leaf + sizeof(*lastb) - 1));
1205} 1201}
1206 1202
@@ -1210,7 +1206,7 @@ xfs_dir2_leaf_log_bests(
1210void 1206void
1211xfs_dir2_leaf_log_ents( 1207xfs_dir2_leaf_log_ents(
1212 xfs_trans_t *tp, /* transaction pointer */ 1208 xfs_trans_t *tp, /* transaction pointer */
1213 xfs_dabuf_t *bp, /* leaf buffer */ 1209 struct xfs_buf *bp, /* leaf buffer */
1214 int first, /* first entry to log */ 1210 int first, /* first entry to log */
1215 int last) /* last entry to log */ 1211 int last) /* last entry to log */
1216{ 1212{
@@ -1218,12 +1214,12 @@ xfs_dir2_leaf_log_ents(
1218 xfs_dir2_leaf_entry_t *lastlep; /* pointer to last entry */ 1214 xfs_dir2_leaf_entry_t *lastlep; /* pointer to last entry */
1219 xfs_dir2_leaf_t *leaf; /* leaf structure */ 1215 xfs_dir2_leaf_t *leaf; /* leaf structure */
1220 1216
1221 leaf = bp->data; 1217 leaf = bp->b_addr;
1222 ASSERT(leaf->hdr.info.magic == cpu_to_be16(XFS_DIR2_LEAF1_MAGIC) || 1218 ASSERT(leaf->hdr.info.magic == cpu_to_be16(XFS_DIR2_LEAF1_MAGIC) ||
1223 leaf->hdr.info.magic == cpu_to_be16(XFS_DIR2_LEAFN_MAGIC)); 1219 leaf->hdr.info.magic == cpu_to_be16(XFS_DIR2_LEAFN_MAGIC));
1224 firstlep = &leaf->ents[first]; 1220 firstlep = &leaf->ents[first];
1225 lastlep = &leaf->ents[last]; 1221 lastlep = &leaf->ents[last];
1226 xfs_da_log_buf(tp, bp, (uint)((char *)firstlep - (char *)leaf), 1222 xfs_trans_log_buf(tp, bp, (uint)((char *)firstlep - (char *)leaf),
1227 (uint)((char *)lastlep - (char *)leaf + sizeof(*lastlep) - 1)); 1223 (uint)((char *)lastlep - (char *)leaf + sizeof(*lastlep) - 1));
1228} 1224}
1229 1225
@@ -1232,15 +1228,15 @@ xfs_dir2_leaf_log_ents(
1232 */ 1228 */
1233void 1229void
1234xfs_dir2_leaf_log_header( 1230xfs_dir2_leaf_log_header(
1235 xfs_trans_t *tp, /* transaction pointer */ 1231 struct xfs_trans *tp,
1236 xfs_dabuf_t *bp) /* leaf buffer */ 1232 struct xfs_buf *bp)
1237{ 1233{
1238 xfs_dir2_leaf_t *leaf; /* leaf structure */ 1234 xfs_dir2_leaf_t *leaf; /* leaf structure */
1239 1235
1240 leaf = bp->data; 1236 leaf = bp->b_addr;
1241 ASSERT(leaf->hdr.info.magic == cpu_to_be16(XFS_DIR2_LEAF1_MAGIC) || 1237 ASSERT(leaf->hdr.info.magic == cpu_to_be16(XFS_DIR2_LEAF1_MAGIC) ||
1242 leaf->hdr.info.magic == cpu_to_be16(XFS_DIR2_LEAFN_MAGIC)); 1238 leaf->hdr.info.magic == cpu_to_be16(XFS_DIR2_LEAFN_MAGIC));
1243 xfs_da_log_buf(tp, bp, (uint)((char *)&leaf->hdr - (char *)leaf), 1239 xfs_trans_log_buf(tp, bp, (uint)((char *)&leaf->hdr - (char *)leaf),
1244 (uint)(sizeof(leaf->hdr) - 1)); 1240 (uint)(sizeof(leaf->hdr) - 1));
1245} 1241}
1246 1242
@@ -1249,18 +1245,18 @@ xfs_dir2_leaf_log_header(
1249 */ 1245 */
1250STATIC void 1246STATIC void
1251xfs_dir2_leaf_log_tail( 1247xfs_dir2_leaf_log_tail(
1252 xfs_trans_t *tp, /* transaction pointer */ 1248 struct xfs_trans *tp,
1253 xfs_dabuf_t *bp) /* leaf buffer */ 1249 struct xfs_buf *bp)
1254{ 1250{
1255 xfs_dir2_leaf_t *leaf; /* leaf structure */ 1251 xfs_dir2_leaf_t *leaf; /* leaf structure */
1256 xfs_dir2_leaf_tail_t *ltp; /* leaf tail structure */ 1252 xfs_dir2_leaf_tail_t *ltp; /* leaf tail structure */
1257 xfs_mount_t *mp; /* filesystem mount point */ 1253 xfs_mount_t *mp; /* filesystem mount point */
1258 1254
1259 mp = tp->t_mountp; 1255 mp = tp->t_mountp;
1260 leaf = bp->data; 1256 leaf = bp->b_addr;
1261 ASSERT(leaf->hdr.info.magic == cpu_to_be16(XFS_DIR2_LEAF1_MAGIC)); 1257 ASSERT(leaf->hdr.info.magic == cpu_to_be16(XFS_DIR2_LEAF1_MAGIC));
1262 ltp = xfs_dir2_leaf_tail_p(mp, leaf); 1258 ltp = xfs_dir2_leaf_tail_p(mp, leaf);
1263 xfs_da_log_buf(tp, bp, (uint)((char *)ltp - (char *)leaf), 1259 xfs_trans_log_buf(tp, bp, (uint)((char *)ltp - (char *)leaf),
1264 (uint)(mp->m_dirblksize - 1)); 1260 (uint)(mp->m_dirblksize - 1));
1265} 1261}
1266 1262
@@ -1273,12 +1269,12 @@ int
1273xfs_dir2_leaf_lookup( 1269xfs_dir2_leaf_lookup(
1274 xfs_da_args_t *args) /* operation arguments */ 1270 xfs_da_args_t *args) /* operation arguments */
1275{ 1271{
1276 xfs_dabuf_t *dbp; /* data block buffer */ 1272 struct xfs_buf *dbp; /* data block buffer */
1277 xfs_dir2_data_entry_t *dep; /* data block entry */ 1273 xfs_dir2_data_entry_t *dep; /* data block entry */
1278 xfs_inode_t *dp; /* incore directory inode */ 1274 xfs_inode_t *dp; /* incore directory inode */
1279 int error; /* error return code */ 1275 int error; /* error return code */
1280 int index; /* found entry index */ 1276 int index; /* found entry index */
1281 xfs_dabuf_t *lbp; /* leaf buffer */ 1277 struct xfs_buf *lbp; /* leaf buffer */
1282 xfs_dir2_leaf_t *leaf; /* leaf structure */ 1278 xfs_dir2_leaf_t *leaf; /* leaf structure */
1283 xfs_dir2_leaf_entry_t *lep; /* leaf entry */ 1279 xfs_dir2_leaf_entry_t *lep; /* leaf entry */
1284 xfs_trans_t *tp; /* transaction pointer */ 1280 xfs_trans_t *tp; /* transaction pointer */
@@ -1294,7 +1290,7 @@ xfs_dir2_leaf_lookup(
1294 tp = args->trans; 1290 tp = args->trans;
1295 dp = args->dp; 1291 dp = args->dp;
1296 xfs_dir2_leaf_check(dp, lbp); 1292 xfs_dir2_leaf_check(dp, lbp);
1297 leaf = lbp->data; 1293 leaf = lbp->b_addr;
1298 /* 1294 /*
1299 * Get to the leaf entry and contained data entry address. 1295 * Get to the leaf entry and contained data entry address.
1300 */ 1296 */
@@ -1303,15 +1299,15 @@ xfs_dir2_leaf_lookup(
1303 * Point to the data entry. 1299 * Point to the data entry.
1304 */ 1300 */
1305 dep = (xfs_dir2_data_entry_t *) 1301 dep = (xfs_dir2_data_entry_t *)
1306 ((char *)dbp->data + 1302 ((char *)dbp->b_addr +
1307 xfs_dir2_dataptr_to_off(dp->i_mount, be32_to_cpu(lep->address))); 1303 xfs_dir2_dataptr_to_off(dp->i_mount, be32_to_cpu(lep->address)));
1308 /* 1304 /*
1309 * Return the found inode number & CI name if appropriate 1305 * Return the found inode number & CI name if appropriate
1310 */ 1306 */
1311 args->inumber = be64_to_cpu(dep->inumber); 1307 args->inumber = be64_to_cpu(dep->inumber);
1312 error = xfs_dir_cilookup_result(args, dep->name, dep->namelen); 1308 error = xfs_dir_cilookup_result(args, dep->name, dep->namelen);
1313 xfs_da_brelse(tp, dbp); 1309 xfs_trans_brelse(tp, dbp);
1314 xfs_da_brelse(tp, lbp); 1310 xfs_trans_brelse(tp, lbp);
1315 return XFS_ERROR(error); 1311 return XFS_ERROR(error);
1316} 1312}
1317 1313
@@ -1324,17 +1320,17 @@ xfs_dir2_leaf_lookup(
1324static int /* error */ 1320static int /* error */
1325xfs_dir2_leaf_lookup_int( 1321xfs_dir2_leaf_lookup_int(
1326 xfs_da_args_t *args, /* operation arguments */ 1322 xfs_da_args_t *args, /* operation arguments */
1327 xfs_dabuf_t **lbpp, /* out: leaf buffer */ 1323 struct xfs_buf **lbpp, /* out: leaf buffer */
1328 int *indexp, /* out: index in leaf block */ 1324 int *indexp, /* out: index in leaf block */
1329 xfs_dabuf_t **dbpp) /* out: data buffer */ 1325 struct xfs_buf **dbpp) /* out: data buffer */
1330{ 1326{
1331 xfs_dir2_db_t curdb = -1; /* current data block number */ 1327 xfs_dir2_db_t curdb = -1; /* current data block number */
1332 xfs_dabuf_t *dbp = NULL; /* data buffer */ 1328 struct xfs_buf *dbp = NULL; /* data buffer */
1333 xfs_dir2_data_entry_t *dep; /* data entry */ 1329 xfs_dir2_data_entry_t *dep; /* data entry */
1334 xfs_inode_t *dp; /* incore directory inode */ 1330 xfs_inode_t *dp; /* incore directory inode */
1335 int error; /* error return code */ 1331 int error; /* error return code */
1336 int index; /* index in leaf block */ 1332 int index; /* index in leaf block */
1337 xfs_dabuf_t *lbp; /* leaf buffer */ 1333 struct xfs_buf *lbp; /* leaf buffer */
1338 xfs_dir2_leaf_entry_t *lep; /* leaf entry */ 1334 xfs_dir2_leaf_entry_t *lep; /* leaf entry */
1339 xfs_dir2_leaf_t *leaf; /* leaf structure */ 1335 xfs_dir2_leaf_t *leaf; /* leaf structure */
1340 xfs_mount_t *mp; /* filesystem mount point */ 1336 xfs_mount_t *mp; /* filesystem mount point */
@@ -1354,7 +1350,7 @@ xfs_dir2_leaf_lookup_int(
1354 if (error) 1350 if (error)
1355 return error; 1351 return error;
1356 *lbpp = lbp; 1352 *lbpp = lbp;
1357 leaf = lbp->data; 1353 leaf = lbp->b_addr;
1358 xfs_dir2_leaf_check(dp, lbp); 1354 xfs_dir2_leaf_check(dp, lbp);
1359 /* 1355 /*
1360 * Look for the first leaf entry with our hash value. 1356 * Look for the first leaf entry with our hash value.
@@ -1382,12 +1378,12 @@ xfs_dir2_leaf_lookup_int(
1382 */ 1378 */
1383 if (newdb != curdb) { 1379 if (newdb != curdb) {
1384 if (dbp) 1380 if (dbp)
1385 xfs_da_brelse(tp, dbp); 1381 xfs_trans_brelse(tp, dbp);
1386 error = xfs_da_read_buf(tp, dp, 1382 error = xfs_da_read_buf(tp, dp,
1387 xfs_dir2_db_to_da(mp, newdb), 1383 xfs_dir2_db_to_da(mp, newdb),
1388 -1, &dbp, XFS_DATA_FORK); 1384 -1, &dbp, XFS_DATA_FORK);
1389 if (error) { 1385 if (error) {
1390 xfs_da_brelse(tp, lbp); 1386 xfs_trans_brelse(tp, lbp);
1391 return error; 1387 return error;
1392 } 1388 }
1393 xfs_dir2_data_check(dp, dbp); 1389 xfs_dir2_data_check(dp, dbp);
@@ -1396,7 +1392,7 @@ xfs_dir2_leaf_lookup_int(
1396 /* 1392 /*
1397 * Point to the data entry. 1393 * Point to the data entry.
1398 */ 1394 */
1399 dep = (xfs_dir2_data_entry_t *)((char *)dbp->data + 1395 dep = (xfs_dir2_data_entry_t *)((char *)dbp->b_addr +
1400 xfs_dir2_dataptr_to_off(mp, be32_to_cpu(lep->address))); 1396 xfs_dir2_dataptr_to_off(mp, be32_to_cpu(lep->address)));
1401 /* 1397 /*
1402 * Compare name and if it's an exact match, return the index 1398 * Compare name and if it's an exact match, return the index
@@ -1424,12 +1420,12 @@ xfs_dir2_leaf_lookup_int(
1424 if (args->cmpresult == XFS_CMP_CASE) { 1420 if (args->cmpresult == XFS_CMP_CASE) {
1425 ASSERT(cidb != -1); 1421 ASSERT(cidb != -1);
1426 if (cidb != curdb) { 1422 if (cidb != curdb) {
1427 xfs_da_brelse(tp, dbp); 1423 xfs_trans_brelse(tp, dbp);
1428 error = xfs_da_read_buf(tp, dp, 1424 error = xfs_da_read_buf(tp, dp,
1429 xfs_dir2_db_to_da(mp, cidb), 1425 xfs_dir2_db_to_da(mp, cidb),
1430 -1, &dbp, XFS_DATA_FORK); 1426 -1, &dbp, XFS_DATA_FORK);
1431 if (error) { 1427 if (error) {
1432 xfs_da_brelse(tp, lbp); 1428 xfs_trans_brelse(tp, lbp);
1433 return error; 1429 return error;
1434 } 1430 }
1435 } 1431 }
@@ -1441,8 +1437,8 @@ xfs_dir2_leaf_lookup_int(
1441 */ 1437 */
1442 ASSERT(cidb == -1); 1438 ASSERT(cidb == -1);
1443 if (dbp) 1439 if (dbp)
1444 xfs_da_brelse(tp, dbp); 1440 xfs_trans_brelse(tp, dbp);
1445 xfs_da_brelse(tp, lbp); 1441 xfs_trans_brelse(tp, lbp);
1446 return XFS_ERROR(ENOENT); 1442 return XFS_ERROR(ENOENT);
1447} 1443}
1448 1444
@@ -1456,13 +1452,13 @@ xfs_dir2_leaf_removename(
1456 __be16 *bestsp; /* leaf block best freespace */ 1452 __be16 *bestsp; /* leaf block best freespace */
1457 xfs_dir2_data_hdr_t *hdr; /* data block header */ 1453 xfs_dir2_data_hdr_t *hdr; /* data block header */
1458 xfs_dir2_db_t db; /* data block number */ 1454 xfs_dir2_db_t db; /* data block number */
1459 xfs_dabuf_t *dbp; /* data block buffer */ 1455 struct xfs_buf *dbp; /* data block buffer */
1460 xfs_dir2_data_entry_t *dep; /* data entry structure */ 1456 xfs_dir2_data_entry_t *dep; /* data entry structure */
1461 xfs_inode_t *dp; /* incore directory inode */ 1457 xfs_inode_t *dp; /* incore directory inode */
1462 int error; /* error return code */ 1458 int error; /* error return code */
1463 xfs_dir2_db_t i; /* temporary data block # */ 1459 xfs_dir2_db_t i; /* temporary data block # */
1464 int index; /* index into leaf entries */ 1460 int index; /* index into leaf entries */
1465 xfs_dabuf_t *lbp; /* leaf buffer */ 1461 struct xfs_buf *lbp; /* leaf buffer */
1466 xfs_dir2_leaf_t *leaf; /* leaf structure */ 1462 xfs_dir2_leaf_t *leaf; /* leaf structure */
1467 xfs_dir2_leaf_entry_t *lep; /* leaf entry */ 1463 xfs_dir2_leaf_entry_t *lep; /* leaf entry */
1468 xfs_dir2_leaf_tail_t *ltp; /* leaf tail structure */ 1464 xfs_dir2_leaf_tail_t *ltp; /* leaf tail structure */
@@ -1483,8 +1479,8 @@ xfs_dir2_leaf_removename(
1483 dp = args->dp; 1479 dp = args->dp;
1484 tp = args->trans; 1480 tp = args->trans;
1485 mp = dp->i_mount; 1481 mp = dp->i_mount;
1486 leaf = lbp->data; 1482 leaf = lbp->b_addr;
1487 hdr = dbp->data; 1483 hdr = dbp->b_addr;
1488 xfs_dir2_data_check(dp, dbp); 1484 xfs_dir2_data_check(dp, dbp);
1489 /* 1485 /*
1490 * Point to the leaf entry, use that to point to the data entry. 1486 * Point to the leaf entry, use that to point to the data entry.
@@ -1541,12 +1537,9 @@ xfs_dir2_leaf_removename(
1541 * Just go on, returning success, leaving the 1537 * Just go on, returning success, leaving the
1542 * empty block in place. 1538 * empty block in place.
1543 */ 1539 */
1544 if (error == ENOSPC && args->total == 0) { 1540 if (error == ENOSPC && args->total == 0)
1545 xfs_da_buf_done(dbp);
1546 error = 0; 1541 error = 0;
1547 }
1548 xfs_dir2_leaf_check(dp, lbp); 1542 xfs_dir2_leaf_check(dp, lbp);
1549 xfs_da_buf_done(lbp);
1550 return error; 1543 return error;
1551 } 1544 }
1552 dbp = NULL; 1545 dbp = NULL;
@@ -1577,10 +1570,9 @@ xfs_dir2_leaf_removename(
1577 /* 1570 /*
1578 * If the data block was not the first one, drop it. 1571 * If the data block was not the first one, drop it.
1579 */ 1572 */
1580 else if (db != mp->m_dirdatablk && dbp != NULL) { 1573 else if (db != mp->m_dirdatablk)
1581 xfs_da_buf_done(dbp);
1582 dbp = NULL; 1574 dbp = NULL;
1583 } 1575
1584 xfs_dir2_leaf_check(dp, lbp); 1576 xfs_dir2_leaf_check(dp, lbp);
1585 /* 1577 /*
1586 * See if we can convert to block form. 1578 * See if we can convert to block form.
@@ -1595,12 +1587,12 @@ int /* error */
1595xfs_dir2_leaf_replace( 1587xfs_dir2_leaf_replace(
1596 xfs_da_args_t *args) /* operation arguments */ 1588 xfs_da_args_t *args) /* operation arguments */
1597{ 1589{
1598 xfs_dabuf_t *dbp; /* data block buffer */ 1590 struct xfs_buf *dbp; /* data block buffer */
1599 xfs_dir2_data_entry_t *dep; /* data block entry */ 1591 xfs_dir2_data_entry_t *dep; /* data block entry */
1600 xfs_inode_t *dp; /* incore directory inode */ 1592 xfs_inode_t *dp; /* incore directory inode */
1601 int error; /* error return code */ 1593 int error; /* error return code */
1602 int index; /* index of leaf entry */ 1594 int index; /* index of leaf entry */
1603 xfs_dabuf_t *lbp; /* leaf buffer */ 1595 struct xfs_buf *lbp; /* leaf buffer */
1604 xfs_dir2_leaf_t *leaf; /* leaf structure */ 1596 xfs_dir2_leaf_t *leaf; /* leaf structure */
1605 xfs_dir2_leaf_entry_t *lep; /* leaf entry */ 1597 xfs_dir2_leaf_entry_t *lep; /* leaf entry */
1606 xfs_trans_t *tp; /* transaction pointer */ 1598 xfs_trans_t *tp; /* transaction pointer */
@@ -1614,7 +1606,7 @@ xfs_dir2_leaf_replace(
1614 return error; 1606 return error;
1615 } 1607 }
1616 dp = args->dp; 1608 dp = args->dp;
1617 leaf = lbp->data; 1609 leaf = lbp->b_addr;
1618 /* 1610 /*
1619 * Point to the leaf entry, get data address from it. 1611 * Point to the leaf entry, get data address from it.
1620 */ 1612 */
@@ -1623,7 +1615,7 @@ xfs_dir2_leaf_replace(
1623 * Point to the data entry. 1615 * Point to the data entry.
1624 */ 1616 */
1625 dep = (xfs_dir2_data_entry_t *) 1617 dep = (xfs_dir2_data_entry_t *)
1626 ((char *)dbp->data + 1618 ((char *)dbp->b_addr +
1627 xfs_dir2_dataptr_to_off(dp->i_mount, be32_to_cpu(lep->address))); 1619 xfs_dir2_dataptr_to_off(dp->i_mount, be32_to_cpu(lep->address)));
1628 ASSERT(args->inumber != be64_to_cpu(dep->inumber)); 1620 ASSERT(args->inumber != be64_to_cpu(dep->inumber));
1629 /* 1621 /*
@@ -1632,9 +1624,8 @@ xfs_dir2_leaf_replace(
1632 dep->inumber = cpu_to_be64(args->inumber); 1624 dep->inumber = cpu_to_be64(args->inumber);
1633 tp = args->trans; 1625 tp = args->trans;
1634 xfs_dir2_data_log_entry(tp, dbp, dep); 1626 xfs_dir2_data_log_entry(tp, dbp, dep);
1635 xfs_da_buf_done(dbp);
1636 xfs_dir2_leaf_check(dp, lbp); 1627 xfs_dir2_leaf_check(dp, lbp);
1637 xfs_da_brelse(tp, lbp); 1628 xfs_trans_brelse(tp, lbp);
1638 return 0; 1629 return 0;
1639} 1630}
1640 1631
@@ -1646,7 +1637,7 @@ xfs_dir2_leaf_replace(
1646int /* index value */ 1637int /* index value */
1647xfs_dir2_leaf_search_hash( 1638xfs_dir2_leaf_search_hash(
1648 xfs_da_args_t *args, /* operation arguments */ 1639 xfs_da_args_t *args, /* operation arguments */
1649 xfs_dabuf_t *lbp) /* leaf buffer */ 1640 struct xfs_buf *lbp) /* leaf buffer */
1650{ 1641{
1651 xfs_dahash_t hash=0; /* hash from this entry */ 1642 xfs_dahash_t hash=0; /* hash from this entry */
1652 xfs_dahash_t hashwant; /* hash value looking for */ 1643 xfs_dahash_t hashwant; /* hash value looking for */
@@ -1656,7 +1647,7 @@ xfs_dir2_leaf_search_hash(
1656 xfs_dir2_leaf_entry_t *lep; /* leaf entry */ 1647 xfs_dir2_leaf_entry_t *lep; /* leaf entry */
1657 int mid=0; /* current leaf index */ 1648 int mid=0; /* current leaf index */
1658 1649
1659 leaf = lbp->data; 1650 leaf = lbp->b_addr;
1660#ifndef __KERNEL__ 1651#ifndef __KERNEL__
1661 if (!leaf->hdr.count) 1652 if (!leaf->hdr.count)
1662 return 0; 1653 return 0;
@@ -1699,11 +1690,11 @@ xfs_dir2_leaf_search_hash(
1699int /* error */ 1690int /* error */
1700xfs_dir2_leaf_trim_data( 1691xfs_dir2_leaf_trim_data(
1701 xfs_da_args_t *args, /* operation arguments */ 1692 xfs_da_args_t *args, /* operation arguments */
1702 xfs_dabuf_t *lbp, /* leaf buffer */ 1693 struct xfs_buf *lbp, /* leaf buffer */
1703 xfs_dir2_db_t db) /* data block number */ 1694 xfs_dir2_db_t db) /* data block number */
1704{ 1695{
1705 __be16 *bestsp; /* leaf bests table */ 1696 __be16 *bestsp; /* leaf bests table */
1706 xfs_dabuf_t *dbp; /* data block buffer */ 1697 struct xfs_buf *dbp; /* data block buffer */
1707 xfs_inode_t *dp; /* incore directory inode */ 1698 xfs_inode_t *dp; /* incore directory inode */
1708 int error; /* error return value */ 1699 int error; /* error return value */
1709 xfs_dir2_leaf_t *leaf; /* leaf structure */ 1700 xfs_dir2_leaf_t *leaf; /* leaf structure */
@@ -1722,12 +1713,12 @@ xfs_dir2_leaf_trim_data(
1722 return error; 1713 return error;
1723 } 1714 }
1724 1715
1725 leaf = lbp->data; 1716 leaf = lbp->b_addr;
1726 ltp = xfs_dir2_leaf_tail_p(mp, leaf); 1717 ltp = xfs_dir2_leaf_tail_p(mp, leaf);
1727 1718
1728#ifdef DEBUG 1719#ifdef DEBUG
1729{ 1720{
1730 struct xfs_dir2_data_hdr *hdr = dbp->data; 1721 struct xfs_dir2_data_hdr *hdr = dbp->b_addr;
1731 1722
1732 ASSERT(hdr->magic == cpu_to_be32(XFS_DIR2_DATA_MAGIC)); 1723 ASSERT(hdr->magic == cpu_to_be32(XFS_DIR2_DATA_MAGIC));
1733 ASSERT(be16_to_cpu(hdr->bestfree[0].length) == 1724 ASSERT(be16_to_cpu(hdr->bestfree[0].length) ==
@@ -1741,7 +1732,7 @@ xfs_dir2_leaf_trim_data(
1741 */ 1732 */
1742 if ((error = xfs_dir2_shrink_inode(args, db, dbp))) { 1733 if ((error = xfs_dir2_shrink_inode(args, db, dbp))) {
1743 ASSERT(error != ENOSPC); 1734 ASSERT(error != ENOSPC);
1744 xfs_da_brelse(tp, dbp); 1735 xfs_trans_brelse(tp, dbp);
1745 return error; 1736 return error;
1746 } 1737 }
1747 /* 1738 /*
@@ -1781,10 +1772,10 @@ xfs_dir2_node_to_leaf(
1781 xfs_da_args_t *args; /* operation arguments */ 1772 xfs_da_args_t *args; /* operation arguments */
1782 xfs_inode_t *dp; /* incore directory inode */ 1773 xfs_inode_t *dp; /* incore directory inode */
1783 int error; /* error return code */ 1774 int error; /* error return code */
1784 xfs_dabuf_t *fbp; /* buffer for freespace block */ 1775 struct xfs_buf *fbp; /* buffer for freespace block */
1785 xfs_fileoff_t fo; /* freespace file offset */ 1776 xfs_fileoff_t fo; /* freespace file offset */
1786 xfs_dir2_free_t *free; /* freespace structure */ 1777 xfs_dir2_free_t *free; /* freespace structure */
1787 xfs_dabuf_t *lbp; /* buffer for leaf block */ 1778 struct xfs_buf *lbp; /* buffer for leaf block */
1788 xfs_dir2_leaf_tail_t *ltp; /* tail of leaf structure */ 1779 xfs_dir2_leaf_tail_t *ltp; /* tail of leaf structure */
1789 xfs_dir2_leaf_t *leaf; /* leaf structure */ 1780 xfs_dir2_leaf_t *leaf; /* leaf structure */
1790 xfs_mount_t *mp; /* filesystem mount point */ 1781 xfs_mount_t *mp; /* filesystem mount point */
@@ -1838,7 +1829,7 @@ xfs_dir2_node_to_leaf(
1838 if (XFS_FSB_TO_B(mp, fo) > XFS_DIR2_LEAF_OFFSET + mp->m_dirblksize) 1829 if (XFS_FSB_TO_B(mp, fo) > XFS_DIR2_LEAF_OFFSET + mp->m_dirblksize)
1839 return 0; 1830 return 0;
1840 lbp = state->path.blk[0].bp; 1831 lbp = state->path.blk[0].bp;
1841 leaf = lbp->data; 1832 leaf = lbp->b_addr;
1842 ASSERT(leaf->hdr.info.magic == cpu_to_be16(XFS_DIR2_LEAFN_MAGIC)); 1833 ASSERT(leaf->hdr.info.magic == cpu_to_be16(XFS_DIR2_LEAFN_MAGIC));
1843 /* 1834 /*
1844 * Read the freespace block. 1835 * Read the freespace block.
@@ -1847,7 +1838,7 @@ xfs_dir2_node_to_leaf(
1847 XFS_DATA_FORK))) { 1838 XFS_DATA_FORK))) {
1848 return error; 1839 return error;
1849 } 1840 }
1850 free = fbp->data; 1841 free = fbp->b_addr;
1851 ASSERT(free->hdr.magic == cpu_to_be32(XFS_DIR2_FREE_MAGIC)); 1842 ASSERT(free->hdr.magic == cpu_to_be32(XFS_DIR2_FREE_MAGIC));
1852 ASSERT(!free->hdr.firstdb); 1843 ASSERT(!free->hdr.firstdb);
1853 1844
@@ -1857,7 +1848,7 @@ xfs_dir2_node_to_leaf(
1857 */ 1848 */
1858 if (xfs_dir2_leaf_size(&leaf->hdr, be32_to_cpu(free->hdr.nvalid)) > 1849 if (xfs_dir2_leaf_size(&leaf->hdr, be32_to_cpu(free->hdr.nvalid)) >
1859 mp->m_dirblksize) { 1850 mp->m_dirblksize) {
1860 xfs_da_brelse(tp, fbp); 1851 xfs_trans_brelse(tp, fbp);
1861 return 0; 1852 return 0;
1862 } 1853 }
1863 1854
diff --git a/fs/xfs/xfs_dir2_node.c b/fs/xfs/xfs_dir2_node.c
index b0f26780449d..6c7052406605 100644
--- a/fs/xfs/xfs_dir2_node.c
+++ b/fs/xfs/xfs_dir2_node.c
@@ -36,20 +36,20 @@
36/* 36/*
37 * Function declarations. 37 * Function declarations.
38 */ 38 */
39static void xfs_dir2_free_log_header(xfs_trans_t *tp, xfs_dabuf_t *bp); 39static int xfs_dir2_leafn_add(struct xfs_buf *bp, xfs_da_args_t *args,
40static int xfs_dir2_leafn_add(xfs_dabuf_t *bp, xfs_da_args_t *args, int index); 40 int index);
41#ifdef DEBUG 41#ifdef DEBUG
42static void xfs_dir2_leafn_check(xfs_inode_t *dp, xfs_dabuf_t *bp); 42static void xfs_dir2_leafn_check(struct xfs_inode *dp, struct xfs_buf *bp);
43#else 43#else
44#define xfs_dir2_leafn_check(dp, bp) 44#define xfs_dir2_leafn_check(dp, bp)
45#endif 45#endif
46static void xfs_dir2_leafn_moveents(xfs_da_args_t *args, xfs_dabuf_t *bp_s, 46static void xfs_dir2_leafn_moveents(xfs_da_args_t *args, struct xfs_buf *bp_s,
47 int start_s, xfs_dabuf_t *bp_d, int start_d, 47 int start_s, struct xfs_buf *bp_d,
48 int count); 48 int start_d, int count);
49static void xfs_dir2_leafn_rebalance(xfs_da_state_t *state, 49static void xfs_dir2_leafn_rebalance(xfs_da_state_t *state,
50 xfs_da_state_blk_t *blk1, 50 xfs_da_state_blk_t *blk1,
51 xfs_da_state_blk_t *blk2); 51 xfs_da_state_blk_t *blk2);
52static int xfs_dir2_leafn_remove(xfs_da_args_t *args, xfs_dabuf_t *bp, 52static int xfs_dir2_leafn_remove(xfs_da_args_t *args, struct xfs_buf *bp,
53 int index, xfs_da_state_blk_t *dblk, 53 int index, xfs_da_state_blk_t *dblk,
54 int *rval); 54 int *rval);
55static int xfs_dir2_node_addname_int(xfs_da_args_t *args, 55static int xfs_dir2_node_addname_int(xfs_da_args_t *args,
@@ -60,16 +60,16 @@ static int xfs_dir2_node_addname_int(xfs_da_args_t *args,
60 */ 60 */
61STATIC void 61STATIC void
62xfs_dir2_free_log_bests( 62xfs_dir2_free_log_bests(
63 xfs_trans_t *tp, /* transaction pointer */ 63 struct xfs_trans *tp,
64 xfs_dabuf_t *bp, /* freespace buffer */ 64 struct xfs_buf *bp,
65 int first, /* first entry to log */ 65 int first, /* first entry to log */
66 int last) /* last entry to log */ 66 int last) /* last entry to log */
67{ 67{
68 xfs_dir2_free_t *free; /* freespace structure */ 68 xfs_dir2_free_t *free; /* freespace structure */
69 69
70 free = bp->data; 70 free = bp->b_addr;
71 ASSERT(free->hdr.magic == cpu_to_be32(XFS_DIR2_FREE_MAGIC)); 71 ASSERT(free->hdr.magic == cpu_to_be32(XFS_DIR2_FREE_MAGIC));
72 xfs_da_log_buf(tp, bp, 72 xfs_trans_log_buf(tp, bp,
73 (uint)((char *)&free->bests[first] - (char *)free), 73 (uint)((char *)&free->bests[first] - (char *)free),
74 (uint)((char *)&free->bests[last] - (char *)free + 74 (uint)((char *)&free->bests[last] - (char *)free +
75 sizeof(free->bests[0]) - 1)); 75 sizeof(free->bests[0]) - 1));
@@ -80,14 +80,14 @@ xfs_dir2_free_log_bests(
80 */ 80 */
81static void 81static void
82xfs_dir2_free_log_header( 82xfs_dir2_free_log_header(
83 xfs_trans_t *tp, /* transaction pointer */ 83 struct xfs_trans *tp,
84 xfs_dabuf_t *bp) /* freespace buffer */ 84 struct xfs_buf *bp)
85{ 85{
86 xfs_dir2_free_t *free; /* freespace structure */ 86 xfs_dir2_free_t *free; /* freespace structure */
87 87
88 free = bp->data; 88 free = bp->b_addr;
89 ASSERT(free->hdr.magic == cpu_to_be32(XFS_DIR2_FREE_MAGIC)); 89 ASSERT(free->hdr.magic == cpu_to_be32(XFS_DIR2_FREE_MAGIC));
90 xfs_da_log_buf(tp, bp, (uint)((char *)&free->hdr - (char *)free), 90 xfs_trans_log_buf(tp, bp, (uint)((char *)&free->hdr - (char *)free),
91 (uint)(sizeof(xfs_dir2_free_hdr_t) - 1)); 91 (uint)(sizeof(xfs_dir2_free_hdr_t) - 1));
92} 92}
93 93
@@ -99,11 +99,11 @@ xfs_dir2_free_log_header(
99int /* error */ 99int /* error */
100xfs_dir2_leaf_to_node( 100xfs_dir2_leaf_to_node(
101 xfs_da_args_t *args, /* operation arguments */ 101 xfs_da_args_t *args, /* operation arguments */
102 xfs_dabuf_t *lbp) /* leaf buffer */ 102 struct xfs_buf *lbp) /* leaf buffer */
103{ 103{
104 xfs_inode_t *dp; /* incore directory inode */ 104 xfs_inode_t *dp; /* incore directory inode */
105 int error; /* error return value */ 105 int error; /* error return value */
106 xfs_dabuf_t *fbp; /* freespace buffer */ 106 struct xfs_buf *fbp; /* freespace buffer */
107 xfs_dir2_db_t fdb; /* freespace block number */ 107 xfs_dir2_db_t fdb; /* freespace block number */
108 xfs_dir2_free_t *free; /* freespace structure */ 108 xfs_dir2_free_t *free; /* freespace structure */
109 __be16 *from; /* pointer to freespace entry */ 109 __be16 *from; /* pointer to freespace entry */
@@ -136,8 +136,8 @@ xfs_dir2_leaf_to_node(
136 return error; 136 return error;
137 } 137 }
138 ASSERT(fbp != NULL); 138 ASSERT(fbp != NULL);
139 free = fbp->data; 139 free = fbp->b_addr;
140 leaf = lbp->data; 140 leaf = lbp->b_addr;
141 ltp = xfs_dir2_leaf_tail_p(mp, leaf); 141 ltp = xfs_dir2_leaf_tail_p(mp, leaf);
142 /* 142 /*
143 * Initialize the freespace block header. 143 * Initialize the freespace block header.
@@ -164,7 +164,6 @@ xfs_dir2_leaf_to_node(
164 xfs_dir2_leaf_log_header(tp, lbp); 164 xfs_dir2_leaf_log_header(tp, lbp);
165 xfs_dir2_free_log_header(tp, fbp); 165 xfs_dir2_free_log_header(tp, fbp);
166 xfs_dir2_free_log_bests(tp, fbp, 0, be32_to_cpu(free->hdr.nvalid) - 1); 166 xfs_dir2_free_log_bests(tp, fbp, 0, be32_to_cpu(free->hdr.nvalid) - 1);
167 xfs_da_buf_done(fbp);
168 xfs_dir2_leafn_check(dp, lbp); 167 xfs_dir2_leafn_check(dp, lbp);
169 return 0; 168 return 0;
170} 169}
@@ -175,7 +174,7 @@ xfs_dir2_leaf_to_node(
175 */ 174 */
176static int /* error */ 175static int /* error */
177xfs_dir2_leafn_add( 176xfs_dir2_leafn_add(
178 xfs_dabuf_t *bp, /* leaf buffer */ 177 struct xfs_buf *bp, /* leaf buffer */
179 xfs_da_args_t *args, /* operation arguments */ 178 xfs_da_args_t *args, /* operation arguments */
180 int index) /* insertion pt for new entry */ 179 int index) /* insertion pt for new entry */
181{ 180{
@@ -195,7 +194,7 @@ xfs_dir2_leafn_add(
195 dp = args->dp; 194 dp = args->dp;
196 mp = dp->i_mount; 195 mp = dp->i_mount;
197 tp = args->trans; 196 tp = args->trans;
198 leaf = bp->data; 197 leaf = bp->b_addr;
199 198
200 /* 199 /*
201 * Quick check just to make sure we are not going to index 200 * Quick check just to make sure we are not going to index
@@ -261,15 +260,15 @@ xfs_dir2_leafn_add(
261 */ 260 */
262void 261void
263xfs_dir2_leafn_check( 262xfs_dir2_leafn_check(
264 xfs_inode_t *dp, /* incore directory inode */ 263 struct xfs_inode *dp,
265 xfs_dabuf_t *bp) /* leaf buffer */ 264 struct xfs_buf *bp)
266{ 265{
267 int i; /* leaf index */ 266 int i; /* leaf index */
268 xfs_dir2_leaf_t *leaf; /* leaf structure */ 267 xfs_dir2_leaf_t *leaf; /* leaf structure */
269 xfs_mount_t *mp; /* filesystem mount point */ 268 xfs_mount_t *mp; /* filesystem mount point */
270 int stale; /* count of stale leaves */ 269 int stale; /* count of stale leaves */
271 270
272 leaf = bp->data; 271 leaf = bp->b_addr;
273 mp = dp->i_mount; 272 mp = dp->i_mount;
274 ASSERT(leaf->hdr.info.magic == cpu_to_be16(XFS_DIR2_LEAFN_MAGIC)); 273 ASSERT(leaf->hdr.info.magic == cpu_to_be16(XFS_DIR2_LEAFN_MAGIC));
275 ASSERT(be16_to_cpu(leaf->hdr.count) <= xfs_dir2_max_leaf_ents(mp)); 274 ASSERT(be16_to_cpu(leaf->hdr.count) <= xfs_dir2_max_leaf_ents(mp));
@@ -291,12 +290,12 @@ xfs_dir2_leafn_check(
291 */ 290 */
292xfs_dahash_t /* hash value */ 291xfs_dahash_t /* hash value */
293xfs_dir2_leafn_lasthash( 292xfs_dir2_leafn_lasthash(
294 xfs_dabuf_t *bp, /* leaf buffer */ 293 struct xfs_buf *bp, /* leaf buffer */
295 int *count) /* count of entries in leaf */ 294 int *count) /* count of entries in leaf */
296{ 295{
297 xfs_dir2_leaf_t *leaf; /* leaf structure */ 296 xfs_dir2_leaf_t *leaf; /* leaf structure */
298 297
299 leaf = bp->data; 298 leaf = bp->b_addr;
300 ASSERT(leaf->hdr.info.magic == cpu_to_be16(XFS_DIR2_LEAFN_MAGIC)); 299 ASSERT(leaf->hdr.info.magic == cpu_to_be16(XFS_DIR2_LEAFN_MAGIC));
301 if (count) 300 if (count)
302 *count = be16_to_cpu(leaf->hdr.count); 301 *count = be16_to_cpu(leaf->hdr.count);
@@ -311,12 +310,12 @@ xfs_dir2_leafn_lasthash(
311 */ 310 */
312STATIC int 311STATIC int
313xfs_dir2_leafn_lookup_for_addname( 312xfs_dir2_leafn_lookup_for_addname(
314 xfs_dabuf_t *bp, /* leaf buffer */ 313 struct xfs_buf *bp, /* leaf buffer */
315 xfs_da_args_t *args, /* operation arguments */ 314 xfs_da_args_t *args, /* operation arguments */
316 int *indexp, /* out: leaf entry index */ 315 int *indexp, /* out: leaf entry index */
317 xfs_da_state_t *state) /* state to fill in */ 316 xfs_da_state_t *state) /* state to fill in */
318{ 317{
319 xfs_dabuf_t *curbp = NULL; /* current data/free buffer */ 318 struct xfs_buf *curbp = NULL; /* current data/free buffer */
320 xfs_dir2_db_t curdb = -1; /* current data block number */ 319 xfs_dir2_db_t curdb = -1; /* current data block number */
321 xfs_dir2_db_t curfdb = -1; /* current free block number */ 320 xfs_dir2_db_t curfdb = -1; /* current free block number */
322 xfs_inode_t *dp; /* incore directory inode */ 321 xfs_inode_t *dp; /* incore directory inode */
@@ -335,7 +334,7 @@ xfs_dir2_leafn_lookup_for_addname(
335 dp = args->dp; 334 dp = args->dp;
336 tp = args->trans; 335 tp = args->trans;
337 mp = dp->i_mount; 336 mp = dp->i_mount;
338 leaf = bp->data; 337 leaf = bp->b_addr;
339 ASSERT(leaf->hdr.info.magic == cpu_to_be16(XFS_DIR2_LEAFN_MAGIC)); 338 ASSERT(leaf->hdr.info.magic == cpu_to_be16(XFS_DIR2_LEAFN_MAGIC));
340#ifdef __KERNEL__ 339#ifdef __KERNEL__
341 ASSERT(be16_to_cpu(leaf->hdr.count) > 0); 340 ASSERT(be16_to_cpu(leaf->hdr.count) > 0);
@@ -352,7 +351,7 @@ xfs_dir2_leafn_lookup_for_addname(
352 /* If so, it's a free block buffer, get the block number. */ 351 /* If so, it's a free block buffer, get the block number. */
353 curbp = state->extrablk.bp; 352 curbp = state->extrablk.bp;
354 curfdb = state->extrablk.blkno; 353 curfdb = state->extrablk.blkno;
355 free = curbp->data; 354 free = curbp->b_addr;
356 ASSERT(free->hdr.magic == cpu_to_be32(XFS_DIR2_FREE_MAGIC)); 355 ASSERT(free->hdr.magic == cpu_to_be32(XFS_DIR2_FREE_MAGIC));
357 } 356 }
358 length = xfs_dir2_data_entsize(args->namelen); 357 length = xfs_dir2_data_entsize(args->namelen);
@@ -394,7 +393,7 @@ xfs_dir2_leafn_lookup_for_addname(
394 * If we had one before, drop it. 393 * If we had one before, drop it.
395 */ 394 */
396 if (curbp) 395 if (curbp)
397 xfs_da_brelse(tp, curbp); 396 xfs_trans_brelse(tp, curbp);
398 /* 397 /*
399 * Read the free block. 398 * Read the free block.
400 */ 399 */
@@ -403,7 +402,7 @@ xfs_dir2_leafn_lookup_for_addname(
403 -1, &curbp, XFS_DATA_FORK); 402 -1, &curbp, XFS_DATA_FORK);
404 if (error) 403 if (error)
405 return error; 404 return error;
406 free = curbp->data; 405 free = curbp->b_addr;
407 ASSERT(be32_to_cpu(free->hdr.magic) == 406 ASSERT(be32_to_cpu(free->hdr.magic) ==
408 XFS_DIR2_FREE_MAGIC); 407 XFS_DIR2_FREE_MAGIC);
409 ASSERT((be32_to_cpu(free->hdr.firstdb) % 408 ASSERT((be32_to_cpu(free->hdr.firstdb) %
@@ -424,7 +423,7 @@ xfs_dir2_leafn_lookup_for_addname(
424 XFS_ERROR_REPORT("xfs_dir2_leafn_lookup_int", 423 XFS_ERROR_REPORT("xfs_dir2_leafn_lookup_int",
425 XFS_ERRLEVEL_LOW, mp); 424 XFS_ERRLEVEL_LOW, mp);
426 if (curfdb != newfdb) 425 if (curfdb != newfdb)
427 xfs_da_brelse(tp, curbp); 426 xfs_trans_brelse(tp, curbp);
428 return XFS_ERROR(EFSCORRUPTED); 427 return XFS_ERROR(EFSCORRUPTED);
429 } 428 }
430 curfdb = newfdb; 429 curfdb = newfdb;
@@ -459,12 +458,12 @@ out:
459 */ 458 */
460STATIC int 459STATIC int
461xfs_dir2_leafn_lookup_for_entry( 460xfs_dir2_leafn_lookup_for_entry(
462 xfs_dabuf_t *bp, /* leaf buffer */ 461 struct xfs_buf *bp, /* leaf buffer */
463 xfs_da_args_t *args, /* operation arguments */ 462 xfs_da_args_t *args, /* operation arguments */
464 int *indexp, /* out: leaf entry index */ 463 int *indexp, /* out: leaf entry index */
465 xfs_da_state_t *state) /* state to fill in */ 464 xfs_da_state_t *state) /* state to fill in */
466{ 465{
467 xfs_dabuf_t *curbp = NULL; /* current data/free buffer */ 466 struct xfs_buf *curbp = NULL; /* current data/free buffer */
468 xfs_dir2_db_t curdb = -1; /* current data block number */ 467 xfs_dir2_db_t curdb = -1; /* current data block number */
469 xfs_dir2_data_entry_t *dep; /* data block entry */ 468 xfs_dir2_data_entry_t *dep; /* data block entry */
470 xfs_inode_t *dp; /* incore directory inode */ 469 xfs_inode_t *dp; /* incore directory inode */
@@ -480,7 +479,7 @@ xfs_dir2_leafn_lookup_for_entry(
480 dp = args->dp; 479 dp = args->dp;
481 tp = args->trans; 480 tp = args->trans;
482 mp = dp->i_mount; 481 mp = dp->i_mount;
483 leaf = bp->data; 482 leaf = bp->b_addr;
484 ASSERT(leaf->hdr.info.magic == cpu_to_be16(XFS_DIR2_LEAFN_MAGIC)); 483 ASSERT(leaf->hdr.info.magic == cpu_to_be16(XFS_DIR2_LEAFN_MAGIC));
485#ifdef __KERNEL__ 484#ifdef __KERNEL__
486 ASSERT(be16_to_cpu(leaf->hdr.count) > 0); 485 ASSERT(be16_to_cpu(leaf->hdr.count) > 0);
@@ -525,7 +524,7 @@ xfs_dir2_leafn_lookup_for_entry(
525 */ 524 */
526 if (curbp && (args->cmpresult == XFS_CMP_DIFFERENT || 525 if (curbp && (args->cmpresult == XFS_CMP_DIFFERENT ||
527 curdb != state->extrablk.blkno)) 526 curdb != state->extrablk.blkno))
528 xfs_da_brelse(tp, curbp); 527 xfs_trans_brelse(tp, curbp);
529 /* 528 /*
530 * If needing the block that is saved with a CI match, 529 * If needing the block that is saved with a CI match,
531 * use it otherwise read in the new data block. 530 * use it otherwise read in the new data block.
@@ -547,7 +546,7 @@ xfs_dir2_leafn_lookup_for_entry(
547 /* 546 /*
548 * Point to the data entry. 547 * Point to the data entry.
549 */ 548 */
550 dep = (xfs_dir2_data_entry_t *)((char *)curbp->data + 549 dep = (xfs_dir2_data_entry_t *)((char *)curbp->b_addr +
551 xfs_dir2_dataptr_to_off(mp, be32_to_cpu(lep->address))); 550 xfs_dir2_dataptr_to_off(mp, be32_to_cpu(lep->address)));
552 /* 551 /*
553 * Compare the entry and if it's an exact match, return 552 * Compare the entry and if it's an exact match, return
@@ -559,7 +558,7 @@ xfs_dir2_leafn_lookup_for_entry(
559 /* If there is a CI match block, drop it */ 558 /* If there is a CI match block, drop it */
560 if (args->cmpresult != XFS_CMP_DIFFERENT && 559 if (args->cmpresult != XFS_CMP_DIFFERENT &&
561 curdb != state->extrablk.blkno) 560 curdb != state->extrablk.blkno)
562 xfs_da_brelse(tp, state->extrablk.bp); 561 xfs_trans_brelse(tp, state->extrablk.bp);
563 args->cmpresult = cmp; 562 args->cmpresult = cmp;
564 args->inumber = be64_to_cpu(dep->inumber); 563 args->inumber = be64_to_cpu(dep->inumber);
565 *indexp = index; 564 *indexp = index;
@@ -567,7 +566,7 @@ xfs_dir2_leafn_lookup_for_entry(
567 state->extrablk.bp = curbp; 566 state->extrablk.bp = curbp;
568 state->extrablk.blkno = curdb; 567 state->extrablk.blkno = curdb;
569 state->extrablk.index = (int)((char *)dep - 568 state->extrablk.index = (int)((char *)dep -
570 (char *)curbp->data); 569 (char *)curbp->b_addr);
571 state->extrablk.magic = XFS_DIR2_DATA_MAGIC; 570 state->extrablk.magic = XFS_DIR2_DATA_MAGIC;
572 if (cmp == XFS_CMP_EXACT) 571 if (cmp == XFS_CMP_EXACT)
573 return XFS_ERROR(EEXIST); 572 return XFS_ERROR(EEXIST);
@@ -586,7 +585,7 @@ xfs_dir2_leafn_lookup_for_entry(
586 } else { 585 } else {
587 /* If the curbp is not the CI match block, drop it */ 586 /* If the curbp is not the CI match block, drop it */
588 if (state->extrablk.bp != curbp) 587 if (state->extrablk.bp != curbp)
589 xfs_da_brelse(tp, curbp); 588 xfs_trans_brelse(tp, curbp);
590 } 589 }
591 } else { 590 } else {
592 state->extravalid = 0; 591 state->extravalid = 0;
@@ -602,7 +601,7 @@ xfs_dir2_leafn_lookup_for_entry(
602 */ 601 */
603int 602int
604xfs_dir2_leafn_lookup_int( 603xfs_dir2_leafn_lookup_int(
605 xfs_dabuf_t *bp, /* leaf buffer */ 604 struct xfs_buf *bp, /* leaf buffer */
606 xfs_da_args_t *args, /* operation arguments */ 605 xfs_da_args_t *args, /* operation arguments */
607 int *indexp, /* out: leaf entry index */ 606 int *indexp, /* out: leaf entry index */
608 xfs_da_state_t *state) /* state to fill in */ 607 xfs_da_state_t *state) /* state to fill in */
@@ -620,9 +619,9 @@ xfs_dir2_leafn_lookup_int(
620static void 619static void
621xfs_dir2_leafn_moveents( 620xfs_dir2_leafn_moveents(
622 xfs_da_args_t *args, /* operation arguments */ 621 xfs_da_args_t *args, /* operation arguments */
623 xfs_dabuf_t *bp_s, /* source leaf buffer */ 622 struct xfs_buf *bp_s, /* source leaf buffer */
624 int start_s, /* source leaf index */ 623 int start_s, /* source leaf index */
625 xfs_dabuf_t *bp_d, /* destination leaf buffer */ 624 struct xfs_buf *bp_d, /* destination leaf buffer */
626 int start_d, /* destination leaf index */ 625 int start_d, /* destination leaf index */
627 int count) /* count of leaves to copy */ 626 int count) /* count of leaves to copy */
628{ 627{
@@ -640,8 +639,8 @@ xfs_dir2_leafn_moveents(
640 return; 639 return;
641 } 640 }
642 tp = args->trans; 641 tp = args->trans;
643 leaf_s = bp_s->data; 642 leaf_s = bp_s->b_addr;
644 leaf_d = bp_d->data; 643 leaf_d = bp_d->b_addr;
645 /* 644 /*
646 * If the destination index is not the end of the current 645 * If the destination index is not the end of the current
647 * destination leaf entries, open up a hole in the destination 646 * destination leaf entries, open up a hole in the destination
@@ -702,14 +701,14 @@ xfs_dir2_leafn_moveents(
702 */ 701 */
703int /* sort order */ 702int /* sort order */
704xfs_dir2_leafn_order( 703xfs_dir2_leafn_order(
705 xfs_dabuf_t *leaf1_bp, /* leaf1 buffer */ 704 struct xfs_buf *leaf1_bp, /* leaf1 buffer */
706 xfs_dabuf_t *leaf2_bp) /* leaf2 buffer */ 705 struct xfs_buf *leaf2_bp) /* leaf2 buffer */
707{ 706{
708 xfs_dir2_leaf_t *leaf1; /* leaf1 structure */ 707 xfs_dir2_leaf_t *leaf1; /* leaf1 structure */
709 xfs_dir2_leaf_t *leaf2; /* leaf2 structure */ 708 xfs_dir2_leaf_t *leaf2; /* leaf2 structure */
710 709
711 leaf1 = leaf1_bp->data; 710 leaf1 = leaf1_bp->b_addr;
712 leaf2 = leaf2_bp->data; 711 leaf2 = leaf2_bp->b_addr;
713 ASSERT(leaf1->hdr.info.magic == cpu_to_be16(XFS_DIR2_LEAFN_MAGIC)); 712 ASSERT(leaf1->hdr.info.magic == cpu_to_be16(XFS_DIR2_LEAFN_MAGIC));
714 ASSERT(leaf2->hdr.info.magic == cpu_to_be16(XFS_DIR2_LEAFN_MAGIC)); 713 ASSERT(leaf2->hdr.info.magic == cpu_to_be16(XFS_DIR2_LEAFN_MAGIC));
715 if (be16_to_cpu(leaf1->hdr.count) > 0 && 714 if (be16_to_cpu(leaf1->hdr.count) > 0 &&
@@ -757,8 +756,8 @@ xfs_dir2_leafn_rebalance(
757 blk1 = blk2; 756 blk1 = blk2;
758 blk2 = tmp; 757 blk2 = tmp;
759 } 758 }
760 leaf1 = blk1->bp->data; 759 leaf1 = blk1->bp->b_addr;
761 leaf2 = blk2->bp->data; 760 leaf2 = blk2->bp->b_addr;
762 oldsum = be16_to_cpu(leaf1->hdr.count) + be16_to_cpu(leaf2->hdr.count); 761 oldsum = be16_to_cpu(leaf1->hdr.count) + be16_to_cpu(leaf2->hdr.count);
763#ifdef DEBUG 762#ifdef DEBUG
764 oldstale = be16_to_cpu(leaf1->hdr.stale) + be16_to_cpu(leaf2->hdr.stale); 763 oldstale = be16_to_cpu(leaf1->hdr.stale) + be16_to_cpu(leaf2->hdr.stale);
@@ -834,14 +833,14 @@ xfs_dir2_leafn_rebalance(
834static int /* error */ 833static int /* error */
835xfs_dir2_leafn_remove( 834xfs_dir2_leafn_remove(
836 xfs_da_args_t *args, /* operation arguments */ 835 xfs_da_args_t *args, /* operation arguments */
837 xfs_dabuf_t *bp, /* leaf buffer */ 836 struct xfs_buf *bp, /* leaf buffer */
838 int index, /* leaf entry index */ 837 int index, /* leaf entry index */
839 xfs_da_state_blk_t *dblk, /* data block */ 838 xfs_da_state_blk_t *dblk, /* data block */
840 int *rval) /* resulting block needs join */ 839 int *rval) /* resulting block needs join */
841{ 840{
842 xfs_dir2_data_hdr_t *hdr; /* data block header */ 841 xfs_dir2_data_hdr_t *hdr; /* data block header */
843 xfs_dir2_db_t db; /* data block number */ 842 xfs_dir2_db_t db; /* data block number */
844 xfs_dabuf_t *dbp; /* data block buffer */ 843 struct xfs_buf *dbp; /* data block buffer */
845 xfs_dir2_data_entry_t *dep; /* data block entry */ 844 xfs_dir2_data_entry_t *dep; /* data block entry */
846 xfs_inode_t *dp; /* incore directory inode */ 845 xfs_inode_t *dp; /* incore directory inode */
847 xfs_dir2_leaf_t *leaf; /* leaf structure */ 846 xfs_dir2_leaf_t *leaf; /* leaf structure */
@@ -858,7 +857,7 @@ xfs_dir2_leafn_remove(
858 dp = args->dp; 857 dp = args->dp;
859 tp = args->trans; 858 tp = args->trans;
860 mp = dp->i_mount; 859 mp = dp->i_mount;
861 leaf = bp->data; 860 leaf = bp->b_addr;
862 ASSERT(leaf->hdr.info.magic == cpu_to_be16(XFS_DIR2_LEAFN_MAGIC)); 861 ASSERT(leaf->hdr.info.magic == cpu_to_be16(XFS_DIR2_LEAFN_MAGIC));
863 /* 862 /*
864 * Point to the entry we're removing. 863 * Point to the entry we're removing.
@@ -884,7 +883,7 @@ xfs_dir2_leafn_remove(
884 * in the data block in case it changes. 883 * in the data block in case it changes.
885 */ 884 */
886 dbp = dblk->bp; 885 dbp = dblk->bp;
887 hdr = dbp->data; 886 hdr = dbp->b_addr;
888 dep = (xfs_dir2_data_entry_t *)((char *)hdr + off); 887 dep = (xfs_dir2_data_entry_t *)((char *)hdr + off);
889 longest = be16_to_cpu(hdr->bestfree[0].length); 888 longest = be16_to_cpu(hdr->bestfree[0].length);
890 needlog = needscan = 0; 889 needlog = needscan = 0;
@@ -905,7 +904,7 @@ xfs_dir2_leafn_remove(
905 */ 904 */
906 if (longest < be16_to_cpu(hdr->bestfree[0].length)) { 905 if (longest < be16_to_cpu(hdr->bestfree[0].length)) {
907 int error; /* error return value */ 906 int error; /* error return value */
908 xfs_dabuf_t *fbp; /* freeblock buffer */ 907 struct xfs_buf *fbp; /* freeblock buffer */
909 xfs_dir2_db_t fdb; /* freeblock block number */ 908 xfs_dir2_db_t fdb; /* freeblock block number */
910 int findex; /* index in freeblock entries */ 909 int findex; /* index in freeblock entries */
911 xfs_dir2_free_t *free; /* freeblock structure */ 910 xfs_dir2_free_t *free; /* freeblock structure */
@@ -920,7 +919,7 @@ xfs_dir2_leafn_remove(
920 -1, &fbp, XFS_DATA_FORK))) { 919 -1, &fbp, XFS_DATA_FORK))) {
921 return error; 920 return error;
922 } 921 }
923 free = fbp->data; 922 free = fbp->b_addr;
924 ASSERT(free->hdr.magic == cpu_to_be32(XFS_DIR2_FREE_MAGIC)); 923 ASSERT(free->hdr.magic == cpu_to_be32(XFS_DIR2_FREE_MAGIC));
925 ASSERT(be32_to_cpu(free->hdr.firstdb) == 924 ASSERT(be32_to_cpu(free->hdr.firstdb) ==
926 xfs_dir2_free_max_bests(mp) * 925 xfs_dir2_free_max_bests(mp) *
@@ -948,9 +947,7 @@ xfs_dir2_leafn_remove(
948 * In this case just drop the buffer and some one else 947 * In this case just drop the buffer and some one else
949 * will eventually get rid of the empty block. 948 * will eventually get rid of the empty block.
950 */ 949 */
951 else if (error == ENOSPC && args->total == 0) 950 else if (!(error == ENOSPC && args->total == 0))
952 xfs_da_buf_done(dbp);
953 else
954 return error; 951 return error;
955 } 952 }
956 /* 953 /*
@@ -1018,11 +1015,6 @@ xfs_dir2_leafn_remove(
1018 */ 1015 */
1019 if (logfree) 1016 if (logfree)
1020 xfs_dir2_free_log_bests(tp, fbp, findex, findex); 1017 xfs_dir2_free_log_bests(tp, fbp, findex, findex);
1021 /*
1022 * Drop the buffer if we still have it.
1023 */
1024 if (fbp)
1025 xfs_da_buf_done(fbp);
1026 } 1018 }
1027 xfs_dir2_leafn_check(dp, bp); 1019 xfs_dir2_leafn_check(dp, bp);
1028 /* 1020 /*
@@ -1114,7 +1106,7 @@ xfs_dir2_leafn_toosmall(
1114{ 1106{
1115 xfs_da_state_blk_t *blk; /* leaf block */ 1107 xfs_da_state_blk_t *blk; /* leaf block */
1116 xfs_dablk_t blkno; /* leaf block number */ 1108 xfs_dablk_t blkno; /* leaf block number */
1117 xfs_dabuf_t *bp; /* leaf buffer */ 1109 struct xfs_buf *bp; /* leaf buffer */
1118 int bytes; /* bytes in use */ 1110 int bytes; /* bytes in use */
1119 int count; /* leaf live entry count */ 1111 int count; /* leaf live entry count */
1120 int error; /* error return value */ 1112 int error; /* error return value */
@@ -1130,7 +1122,7 @@ xfs_dir2_leafn_toosmall(
1130 * to coalesce with a sibling. 1122 * to coalesce with a sibling.
1131 */ 1123 */
1132 blk = &state->path.blk[state->path.active - 1]; 1124 blk = &state->path.blk[state->path.active - 1];
1133 info = blk->bp->data; 1125 info = blk->bp->b_addr;
1134 ASSERT(info->magic == cpu_to_be16(XFS_DIR2_LEAFN_MAGIC)); 1126 ASSERT(info->magic == cpu_to_be16(XFS_DIR2_LEAFN_MAGIC));
1135 leaf = (xfs_dir2_leaf_t *)info; 1127 leaf = (xfs_dir2_leaf_t *)info;
1136 count = be16_to_cpu(leaf->hdr.count) - be16_to_cpu(leaf->hdr.stale); 1128 count = be16_to_cpu(leaf->hdr.count) - be16_to_cpu(leaf->hdr.stale);
@@ -1189,7 +1181,7 @@ xfs_dir2_leafn_toosmall(
1189 leaf = (xfs_dir2_leaf_t *)info; 1181 leaf = (xfs_dir2_leaf_t *)info;
1190 count = be16_to_cpu(leaf->hdr.count) - be16_to_cpu(leaf->hdr.stale); 1182 count = be16_to_cpu(leaf->hdr.count) - be16_to_cpu(leaf->hdr.stale);
1191 bytes = state->blocksize - (state->blocksize >> 2); 1183 bytes = state->blocksize - (state->blocksize >> 2);
1192 leaf = bp->data; 1184 leaf = bp->b_addr;
1193 ASSERT(leaf->hdr.info.magic == cpu_to_be16(XFS_DIR2_LEAFN_MAGIC)); 1185 ASSERT(leaf->hdr.info.magic == cpu_to_be16(XFS_DIR2_LEAFN_MAGIC));
1194 count += be16_to_cpu(leaf->hdr.count) - be16_to_cpu(leaf->hdr.stale); 1186 count += be16_to_cpu(leaf->hdr.count) - be16_to_cpu(leaf->hdr.stale);
1195 bytes -= count * (uint)sizeof(leaf->ents[0]); 1187 bytes -= count * (uint)sizeof(leaf->ents[0]);
@@ -1198,7 +1190,7 @@ xfs_dir2_leafn_toosmall(
1198 */ 1190 */
1199 if (bytes >= 0) 1191 if (bytes >= 0)
1200 break; 1192 break;
1201 xfs_da_brelse(state->args->trans, bp); 1193 xfs_trans_brelse(state->args->trans, bp);
1202 } 1194 }
1203 /* 1195 /*
1204 * Didn't like either block, give up. 1196 * Didn't like either block, give up.
@@ -1207,11 +1199,7 @@ xfs_dir2_leafn_toosmall(
1207 *action = 0; 1199 *action = 0;
1208 return 0; 1200 return 0;
1209 } 1201 }
1210 /* 1202
1211 * Done with the sibling leaf block here, drop the dabuf
1212 * so path_shift can get it.
1213 */
1214 xfs_da_buf_done(bp);
1215 /* 1203 /*
1216 * Make altpath point to the block we want to keep (the lower 1204 * Make altpath point to the block we want to keep (the lower
1217 * numbered block) and path point to the block we want to drop. 1205 * numbered block) and path point to the block we want to drop.
@@ -1247,8 +1235,8 @@ xfs_dir2_leafn_unbalance(
1247 args = state->args; 1235 args = state->args;
1248 ASSERT(drop_blk->magic == XFS_DIR2_LEAFN_MAGIC); 1236 ASSERT(drop_blk->magic == XFS_DIR2_LEAFN_MAGIC);
1249 ASSERT(save_blk->magic == XFS_DIR2_LEAFN_MAGIC); 1237 ASSERT(save_blk->magic == XFS_DIR2_LEAFN_MAGIC);
1250 drop_leaf = drop_blk->bp->data; 1238 drop_leaf = drop_blk->bp->b_addr;
1251 save_leaf = save_blk->bp->data; 1239 save_leaf = save_blk->bp->b_addr;
1252 ASSERT(drop_leaf->hdr.info.magic == cpu_to_be16(XFS_DIR2_LEAFN_MAGIC)); 1240 ASSERT(drop_leaf->hdr.info.magic == cpu_to_be16(XFS_DIR2_LEAFN_MAGIC));
1253 ASSERT(save_leaf->hdr.info.magic == cpu_to_be16(XFS_DIR2_LEAFN_MAGIC)); 1241 ASSERT(save_leaf->hdr.info.magic == cpu_to_be16(XFS_DIR2_LEAFN_MAGIC));
1254 /* 1242 /*
@@ -1356,13 +1344,13 @@ xfs_dir2_node_addname_int(
1356{ 1344{
1357 xfs_dir2_data_hdr_t *hdr; /* data block header */ 1345 xfs_dir2_data_hdr_t *hdr; /* data block header */
1358 xfs_dir2_db_t dbno; /* data block number */ 1346 xfs_dir2_db_t dbno; /* data block number */
1359 xfs_dabuf_t *dbp; /* data block buffer */ 1347 struct xfs_buf *dbp; /* data block buffer */
1360 xfs_dir2_data_entry_t *dep; /* data entry pointer */ 1348 xfs_dir2_data_entry_t *dep; /* data entry pointer */
1361 xfs_inode_t *dp; /* incore directory inode */ 1349 xfs_inode_t *dp; /* incore directory inode */
1362 xfs_dir2_data_unused_t *dup; /* data unused entry pointer */ 1350 xfs_dir2_data_unused_t *dup; /* data unused entry pointer */
1363 int error; /* error return value */ 1351 int error; /* error return value */
1364 xfs_dir2_db_t fbno; /* freespace block number */ 1352 xfs_dir2_db_t fbno; /* freespace block number */
1365 xfs_dabuf_t *fbp; /* freespace buffer */ 1353 struct xfs_buf *fbp; /* freespace buffer */
1366 int findex; /* freespace entry index */ 1354 int findex; /* freespace entry index */
1367 xfs_dir2_free_t *free=NULL; /* freespace block structure */ 1355 xfs_dir2_free_t *free=NULL; /* freespace block structure */
1368 xfs_dir2_db_t ifbno; /* initial freespace block no */ 1356 xfs_dir2_db_t ifbno; /* initial freespace block no */
@@ -1390,7 +1378,7 @@ xfs_dir2_node_addname_int(
1390 * Remember initial freespace block number. 1378 * Remember initial freespace block number.
1391 */ 1379 */
1392 ifbno = fblk->blkno; 1380 ifbno = fblk->blkno;
1393 free = fbp->data; 1381 free = fbp->b_addr;
1394 ASSERT(free->hdr.magic == cpu_to_be32(XFS_DIR2_FREE_MAGIC)); 1382 ASSERT(free->hdr.magic == cpu_to_be32(XFS_DIR2_FREE_MAGIC));
1395 findex = fblk->index; 1383 findex = fblk->index;
1396 /* 1384 /*
@@ -1474,7 +1462,7 @@ xfs_dir2_node_addname_int(
1474 if (unlikely(fbp == NULL)) { 1462 if (unlikely(fbp == NULL)) {
1475 continue; 1463 continue;
1476 } 1464 }
1477 free = fbp->data; 1465 free = fbp->b_addr;
1478 ASSERT(free->hdr.magic == cpu_to_be32(XFS_DIR2_FREE_MAGIC)); 1466 ASSERT(free->hdr.magic == cpu_to_be32(XFS_DIR2_FREE_MAGIC));
1479 findex = 0; 1467 findex = 0;
1480 } 1468 }
@@ -1492,7 +1480,7 @@ xfs_dir2_node_addname_int(
1492 /* 1480 /*
1493 * Drop the block. 1481 * Drop the block.
1494 */ 1482 */
1495 xfs_da_brelse(tp, fbp); 1483 xfs_trans_brelse(tp, fbp);
1496 fbp = NULL; 1484 fbp = NULL;
1497 if (fblk && fblk->bp) 1485 if (fblk && fblk->bp)
1498 fblk->bp = NULL; 1486 fblk->bp = NULL;
@@ -1507,36 +1495,23 @@ xfs_dir2_node_addname_int(
1507 /* 1495 /*
1508 * Not allowed to allocate, return failure. 1496 * Not allowed to allocate, return failure.
1509 */ 1497 */
1510 if ((args->op_flags & XFS_DA_OP_JUSTCHECK) || 1498 if ((args->op_flags & XFS_DA_OP_JUSTCHECK) || args->total == 0)
1511 args->total == 0) {
1512 /*
1513 * Drop the freespace buffer unless it came from our
1514 * caller.
1515 */
1516 if ((fblk == NULL || fblk->bp == NULL) && fbp != NULL)
1517 xfs_da_buf_done(fbp);
1518 return XFS_ERROR(ENOSPC); 1499 return XFS_ERROR(ENOSPC);
1519 } 1500
1520 /* 1501 /*
1521 * Allocate and initialize the new data block. 1502 * Allocate and initialize the new data block.
1522 */ 1503 */
1523 if (unlikely((error = xfs_dir2_grow_inode(args, 1504 if (unlikely((error = xfs_dir2_grow_inode(args,
1524 XFS_DIR2_DATA_SPACE, 1505 XFS_DIR2_DATA_SPACE,
1525 &dbno)) || 1506 &dbno)) ||
1526 (error = xfs_dir2_data_init(args, dbno, &dbp)))) { 1507 (error = xfs_dir2_data_init(args, dbno, &dbp))))
1527 /*
1528 * Drop the freespace buffer unless it came from our
1529 * caller.
1530 */
1531 if ((fblk == NULL || fblk->bp == NULL) && fbp != NULL)
1532 xfs_da_buf_done(fbp);
1533 return error; 1508 return error;
1534 } 1509
1535 /* 1510 /*
1536 * If (somehow) we have a freespace block, get rid of it. 1511 * If (somehow) we have a freespace block, get rid of it.
1537 */ 1512 */
1538 if (fbp) 1513 if (fbp)
1539 xfs_da_brelse(tp, fbp); 1514 xfs_trans_brelse(tp, fbp);
1540 if (fblk && fblk->bp) 1515 if (fblk && fblk->bp)
1541 fblk->bp = NULL; 1516 fblk->bp = NULL;
1542 1517
@@ -1547,10 +1522,9 @@ xfs_dir2_node_addname_int(
1547 fbno = xfs_dir2_db_to_fdb(mp, dbno); 1522 fbno = xfs_dir2_db_to_fdb(mp, dbno);
1548 if (unlikely(error = xfs_da_read_buf(tp, dp, 1523 if (unlikely(error = xfs_da_read_buf(tp, dp,
1549 xfs_dir2_db_to_da(mp, fbno), -2, &fbp, 1524 xfs_dir2_db_to_da(mp, fbno), -2, &fbp,
1550 XFS_DATA_FORK))) { 1525 XFS_DATA_FORK)))
1551 xfs_da_buf_done(dbp);
1552 return error; 1526 return error;
1553 } 1527
1554 /* 1528 /*
1555 * If there wasn't a freespace block, the read will 1529 * If there wasn't a freespace block, the read will
1556 * return a NULL fbp. Allocate and initialize a new one. 1530 * return a NULL fbp. Allocate and initialize a new one.
@@ -1598,7 +1572,7 @@ xfs_dir2_node_addname_int(
1598 * Initialize the new block to be empty, and remember 1572 * Initialize the new block to be empty, and remember
1599 * its first slot as our empty slot. 1573 * its first slot as our empty slot.
1600 */ 1574 */
1601 free = fbp->data; 1575 free = fbp->b_addr;
1602 free->hdr.magic = cpu_to_be32(XFS_DIR2_FREE_MAGIC); 1576 free->hdr.magic = cpu_to_be32(XFS_DIR2_FREE_MAGIC);
1603 free->hdr.firstdb = cpu_to_be32( 1577 free->hdr.firstdb = cpu_to_be32(
1604 (fbno - XFS_DIR2_FREE_FIRSTDB(mp)) * 1578 (fbno - XFS_DIR2_FREE_FIRSTDB(mp)) *
@@ -1606,7 +1580,7 @@ xfs_dir2_node_addname_int(
1606 free->hdr.nvalid = 0; 1580 free->hdr.nvalid = 0;
1607 free->hdr.nused = 0; 1581 free->hdr.nused = 0;
1608 } else { 1582 } else {
1609 free = fbp->data; 1583 free = fbp->b_addr;
1610 ASSERT(free->hdr.magic == cpu_to_be32(XFS_DIR2_FREE_MAGIC)); 1584 ASSERT(free->hdr.magic == cpu_to_be32(XFS_DIR2_FREE_MAGIC));
1611 } 1585 }
1612 1586
@@ -1639,7 +1613,7 @@ xfs_dir2_node_addname_int(
1639 * We haven't allocated the data entry yet so this will 1613 * We haven't allocated the data entry yet so this will
1640 * change again. 1614 * change again.
1641 */ 1615 */
1642 hdr = dbp->data; 1616 hdr = dbp->b_addr;
1643 free->bests[findex] = hdr->bestfree[0].length; 1617 free->bests[findex] = hdr->bestfree[0].length;
1644 logfree = 1; 1618 logfree = 1;
1645 } 1619 }
@@ -1650,22 +1624,17 @@ xfs_dir2_node_addname_int(
1650 /* 1624 /*
1651 * If just checking, we succeeded. 1625 * If just checking, we succeeded.
1652 */ 1626 */
1653 if (args->op_flags & XFS_DA_OP_JUSTCHECK) { 1627 if (args->op_flags & XFS_DA_OP_JUSTCHECK)
1654 if ((fblk == NULL || fblk->bp == NULL) && fbp != NULL)
1655 xfs_da_buf_done(fbp);
1656 return 0; 1628 return 0;
1657 } 1629
1658 /* 1630 /*
1659 * Read the data block in. 1631 * Read the data block in.
1660 */ 1632 */
1661 if (unlikely( 1633 error = xfs_da_read_buf(tp, dp, xfs_dir2_db_to_da(mp, dbno),
1662 error = xfs_da_read_buf(tp, dp, xfs_dir2_db_to_da(mp, dbno), 1634 -1, &dbp, XFS_DATA_FORK);
1663 -1, &dbp, XFS_DATA_FORK))) { 1635 if (error)
1664 if ((fblk == NULL || fblk->bp == NULL) && fbp != NULL)
1665 xfs_da_buf_done(fbp);
1666 return error; 1636 return error;
1667 } 1637 hdr = dbp->b_addr;
1668 hdr = dbp->data;
1669 logfree = 0; 1638 logfree = 0;
1670 } 1639 }
1671 ASSERT(be16_to_cpu(hdr->bestfree[0].length) >= length); 1640 ASSERT(be16_to_cpu(hdr->bestfree[0].length) >= length);
@@ -1714,16 +1683,10 @@ xfs_dir2_node_addname_int(
1714 if (logfree) 1683 if (logfree)
1715 xfs_dir2_free_log_bests(tp, fbp, findex, findex); 1684 xfs_dir2_free_log_bests(tp, fbp, findex, findex);
1716 /* 1685 /*
1717 * If the caller didn't hand us the freespace block, drop it.
1718 */
1719 if ((fblk == NULL || fblk->bp == NULL) && fbp != NULL)
1720 xfs_da_buf_done(fbp);
1721 /*
1722 * Return the data block and offset in args, then drop the data block. 1686 * Return the data block and offset in args, then drop the data block.
1723 */ 1687 */
1724 args->blkno = (xfs_dablk_t)dbno; 1688 args->blkno = (xfs_dablk_t)dbno;
1725 args->index = be16_to_cpu(*tagp); 1689 args->index = be16_to_cpu(*tagp);
1726 xfs_da_buf_done(dbp);
1727 return 0; 1690 return 0;
1728} 1691}
1729 1692
@@ -1761,22 +1724,23 @@ xfs_dir2_node_lookup(
1761 /* If a CI match, dup the actual name and return EEXIST */ 1724 /* If a CI match, dup the actual name and return EEXIST */
1762 xfs_dir2_data_entry_t *dep; 1725 xfs_dir2_data_entry_t *dep;
1763 1726
1764 dep = (xfs_dir2_data_entry_t *)((char *)state->extrablk.bp-> 1727 dep = (xfs_dir2_data_entry_t *)
1765 data + state->extrablk.index); 1728 ((char *)state->extrablk.bp->b_addr +
1729 state->extrablk.index);
1766 rval = xfs_dir_cilookup_result(args, dep->name, dep->namelen); 1730 rval = xfs_dir_cilookup_result(args, dep->name, dep->namelen);
1767 } 1731 }
1768 /* 1732 /*
1769 * Release the btree blocks and leaf block. 1733 * Release the btree blocks and leaf block.
1770 */ 1734 */
1771 for (i = 0; i < state->path.active; i++) { 1735 for (i = 0; i < state->path.active; i++) {
1772 xfs_da_brelse(args->trans, state->path.blk[i].bp); 1736 xfs_trans_brelse(args->trans, state->path.blk[i].bp);
1773 state->path.blk[i].bp = NULL; 1737 state->path.blk[i].bp = NULL;
1774 } 1738 }
1775 /* 1739 /*
1776 * Release the data block if we have it. 1740 * Release the data block if we have it.
1777 */ 1741 */
1778 if (state->extravalid && state->extrablk.bp) { 1742 if (state->extravalid && state->extrablk.bp) {
1779 xfs_da_brelse(args->trans, state->extrablk.bp); 1743 xfs_trans_brelse(args->trans, state->extrablk.bp);
1780 state->extrablk.bp = NULL; 1744 state->extrablk.bp = NULL;
1781 } 1745 }
1782 xfs_da_state_free(state); 1746 xfs_da_state_free(state);
@@ -1893,13 +1857,13 @@ xfs_dir2_node_replace(
1893 */ 1857 */
1894 blk = &state->path.blk[state->path.active - 1]; 1858 blk = &state->path.blk[state->path.active - 1];
1895 ASSERT(blk->magic == XFS_DIR2_LEAFN_MAGIC); 1859 ASSERT(blk->magic == XFS_DIR2_LEAFN_MAGIC);
1896 leaf = blk->bp->data; 1860 leaf = blk->bp->b_addr;
1897 lep = &leaf->ents[blk->index]; 1861 lep = &leaf->ents[blk->index];
1898 ASSERT(state->extravalid); 1862 ASSERT(state->extravalid);
1899 /* 1863 /*
1900 * Point to the data entry. 1864 * Point to the data entry.
1901 */ 1865 */
1902 hdr = state->extrablk.bp->data; 1866 hdr = state->extrablk.bp->b_addr;
1903 ASSERT(hdr->magic == cpu_to_be32(XFS_DIR2_DATA_MAGIC)); 1867 ASSERT(hdr->magic == cpu_to_be32(XFS_DIR2_DATA_MAGIC));
1904 dep = (xfs_dir2_data_entry_t *) 1868 dep = (xfs_dir2_data_entry_t *)
1905 ((char *)hdr + 1869 ((char *)hdr +
@@ -1916,14 +1880,14 @@ xfs_dir2_node_replace(
1916 * Didn't find it, and we're holding a data block. Drop it. 1880 * Didn't find it, and we're holding a data block. Drop it.
1917 */ 1881 */
1918 else if (state->extravalid) { 1882 else if (state->extravalid) {
1919 xfs_da_brelse(args->trans, state->extrablk.bp); 1883 xfs_trans_brelse(args->trans, state->extrablk.bp);
1920 state->extrablk.bp = NULL; 1884 state->extrablk.bp = NULL;
1921 } 1885 }
1922 /* 1886 /*
1923 * Release all the buffers in the cursor. 1887 * Release all the buffers in the cursor.
1924 */ 1888 */
1925 for (i = 0; i < state->path.active; i++) { 1889 for (i = 0; i < state->path.active; i++) {
1926 xfs_da_brelse(args->trans, state->path.blk[i].bp); 1890 xfs_trans_brelse(args->trans, state->path.blk[i].bp);
1927 state->path.blk[i].bp = NULL; 1891 state->path.blk[i].bp = NULL;
1928 } 1892 }
1929 xfs_da_state_free(state); 1893 xfs_da_state_free(state);
@@ -1940,7 +1904,7 @@ xfs_dir2_node_trim_free(
1940 xfs_fileoff_t fo, /* free block number */ 1904 xfs_fileoff_t fo, /* free block number */
1941 int *rvalp) /* out: did something */ 1905 int *rvalp) /* out: did something */
1942{ 1906{
1943 xfs_dabuf_t *bp; /* freespace buffer */ 1907 struct xfs_buf *bp; /* freespace buffer */
1944 xfs_inode_t *dp; /* incore directory inode */ 1908 xfs_inode_t *dp; /* incore directory inode */
1945 int error; /* error return code */ 1909 int error; /* error return code */
1946 xfs_dir2_free_t *free; /* freespace structure */ 1910 xfs_dir2_free_t *free; /* freespace structure */
@@ -1965,13 +1929,13 @@ xfs_dir2_node_trim_free(
1965 if (bp == NULL) { 1929 if (bp == NULL) {
1966 return 0; 1930 return 0;
1967 } 1931 }
1968 free = bp->data; 1932 free = bp->b_addr;
1969 ASSERT(free->hdr.magic == cpu_to_be32(XFS_DIR2_FREE_MAGIC)); 1933 ASSERT(free->hdr.magic == cpu_to_be32(XFS_DIR2_FREE_MAGIC));
1970 /* 1934 /*
1971 * If there are used entries, there's nothing to do. 1935 * If there are used entries, there's nothing to do.
1972 */ 1936 */
1973 if (be32_to_cpu(free->hdr.nused) > 0) { 1937 if (be32_to_cpu(free->hdr.nused) > 0) {
1974 xfs_da_brelse(tp, bp); 1938 xfs_trans_brelse(tp, bp);
1975 *rvalp = 0; 1939 *rvalp = 0;
1976 return 0; 1940 return 0;
1977 } 1941 }
@@ -1987,7 +1951,7 @@ xfs_dir2_node_trim_free(
1987 * pieces. This is the last block of an extent. 1951 * pieces. This is the last block of an extent.
1988 */ 1952 */
1989 ASSERT(error != ENOSPC); 1953 ASSERT(error != ENOSPC);
1990 xfs_da_brelse(tp, bp); 1954 xfs_trans_brelse(tp, bp);
1991 return error; 1955 return error;
1992 } 1956 }
1993 /* 1957 /*
diff --git a/fs/xfs/xfs_dir2_priv.h b/fs/xfs/xfs_dir2_priv.h
index 067f403ecf8a..3523d3e15aa8 100644
--- a/fs/xfs/xfs_dir2_priv.h
+++ b/fs/xfs/xfs_dir2_priv.h
@@ -25,7 +25,7 @@ extern int xfs_dir2_isleaf(struct xfs_trans *tp, struct xfs_inode *dp, int *r);
25extern int xfs_dir2_grow_inode(struct xfs_da_args *args, int space, 25extern int xfs_dir2_grow_inode(struct xfs_da_args *args, int space,
26 xfs_dir2_db_t *dbp); 26 xfs_dir2_db_t *dbp);
27extern int xfs_dir2_shrink_inode(struct xfs_da_args *args, xfs_dir2_db_t db, 27extern int xfs_dir2_shrink_inode(struct xfs_da_args *args, xfs_dir2_db_t db,
28 struct xfs_dabuf *bp); 28 struct xfs_buf *bp);
29extern int xfs_dir_cilookup_result(struct xfs_da_args *args, 29extern int xfs_dir_cilookup_result(struct xfs_da_args *args,
30 const unsigned char *name, int len); 30 const unsigned char *name, int len);
31 31
@@ -37,11 +37,11 @@ extern int xfs_dir2_block_lookup(struct xfs_da_args *args);
37extern int xfs_dir2_block_removename(struct xfs_da_args *args); 37extern int xfs_dir2_block_removename(struct xfs_da_args *args);
38extern int xfs_dir2_block_replace(struct xfs_da_args *args); 38extern int xfs_dir2_block_replace(struct xfs_da_args *args);
39extern int xfs_dir2_leaf_to_block(struct xfs_da_args *args, 39extern int xfs_dir2_leaf_to_block(struct xfs_da_args *args,
40 struct xfs_dabuf *lbp, struct xfs_dabuf *dbp); 40 struct xfs_buf *lbp, struct xfs_buf *dbp);
41 41
42/* xfs_dir2_data.c */ 42/* xfs_dir2_data.c */
43#ifdef DEBUG 43#ifdef DEBUG
44extern void xfs_dir2_data_check(struct xfs_inode *dp, struct xfs_dabuf *bp); 44extern void xfs_dir2_data_check(struct xfs_inode *dp, struct xfs_buf *bp);
45#else 45#else
46#define xfs_dir2_data_check(dp,bp) 46#define xfs_dir2_data_check(dp,bp)
47#endif 47#endif
@@ -51,43 +51,43 @@ xfs_dir2_data_freeinsert(struct xfs_dir2_data_hdr *hdr,
51extern void xfs_dir2_data_freescan(struct xfs_mount *mp, 51extern void xfs_dir2_data_freescan(struct xfs_mount *mp,
52 struct xfs_dir2_data_hdr *hdr, int *loghead); 52 struct xfs_dir2_data_hdr *hdr, int *loghead);
53extern int xfs_dir2_data_init(struct xfs_da_args *args, xfs_dir2_db_t blkno, 53extern int xfs_dir2_data_init(struct xfs_da_args *args, xfs_dir2_db_t blkno,
54 struct xfs_dabuf **bpp); 54 struct xfs_buf **bpp);
55extern void xfs_dir2_data_log_entry(struct xfs_trans *tp, struct xfs_dabuf *bp, 55extern void xfs_dir2_data_log_entry(struct xfs_trans *tp, struct xfs_buf *bp,
56 struct xfs_dir2_data_entry *dep); 56 struct xfs_dir2_data_entry *dep);
57extern void xfs_dir2_data_log_header(struct xfs_trans *tp, 57extern void xfs_dir2_data_log_header(struct xfs_trans *tp,
58 struct xfs_dabuf *bp); 58 struct xfs_buf *bp);
59extern void xfs_dir2_data_log_unused(struct xfs_trans *tp, struct xfs_dabuf *bp, 59extern void xfs_dir2_data_log_unused(struct xfs_trans *tp, struct xfs_buf *bp,
60 struct xfs_dir2_data_unused *dup); 60 struct xfs_dir2_data_unused *dup);
61extern void xfs_dir2_data_make_free(struct xfs_trans *tp, struct xfs_dabuf *bp, 61extern void xfs_dir2_data_make_free(struct xfs_trans *tp, struct xfs_buf *bp,
62 xfs_dir2_data_aoff_t offset, xfs_dir2_data_aoff_t len, 62 xfs_dir2_data_aoff_t offset, xfs_dir2_data_aoff_t len,
63 int *needlogp, int *needscanp); 63 int *needlogp, int *needscanp);
64extern void xfs_dir2_data_use_free(struct xfs_trans *tp, struct xfs_dabuf *bp, 64extern void xfs_dir2_data_use_free(struct xfs_trans *tp, struct xfs_buf *bp,
65 struct xfs_dir2_data_unused *dup, xfs_dir2_data_aoff_t offset, 65 struct xfs_dir2_data_unused *dup, xfs_dir2_data_aoff_t offset,
66 xfs_dir2_data_aoff_t len, int *needlogp, int *needscanp); 66 xfs_dir2_data_aoff_t len, int *needlogp, int *needscanp);
67 67
68/* xfs_dir2_leaf.c */ 68/* xfs_dir2_leaf.c */
69extern int xfs_dir2_block_to_leaf(struct xfs_da_args *args, 69extern int xfs_dir2_block_to_leaf(struct xfs_da_args *args,
70 struct xfs_dabuf *dbp); 70 struct xfs_buf *dbp);
71extern int xfs_dir2_leaf_addname(struct xfs_da_args *args); 71extern int xfs_dir2_leaf_addname(struct xfs_da_args *args);
72extern void xfs_dir2_leaf_compact(struct xfs_da_args *args, 72extern void xfs_dir2_leaf_compact(struct xfs_da_args *args,
73 struct xfs_dabuf *bp); 73 struct xfs_buf *bp);
74extern void xfs_dir2_leaf_compact_x1(struct xfs_dabuf *bp, int *indexp, 74extern void xfs_dir2_leaf_compact_x1(struct xfs_buf *bp, int *indexp,
75 int *lowstalep, int *highstalep, int *lowlogp, int *highlogp); 75 int *lowstalep, int *highstalep, int *lowlogp, int *highlogp);
76extern int xfs_dir2_leaf_getdents(struct xfs_inode *dp, void *dirent, 76extern int xfs_dir2_leaf_getdents(struct xfs_inode *dp, void *dirent,
77 size_t bufsize, xfs_off_t *offset, filldir_t filldir); 77 size_t bufsize, xfs_off_t *offset, filldir_t filldir);
78extern int xfs_dir2_leaf_init(struct xfs_da_args *args, xfs_dir2_db_t bno, 78extern int xfs_dir2_leaf_init(struct xfs_da_args *args, xfs_dir2_db_t bno,
79 struct xfs_dabuf **bpp, int magic); 79 struct xfs_buf **bpp, int magic);
80extern void xfs_dir2_leaf_log_ents(struct xfs_trans *tp, struct xfs_dabuf *bp, 80extern void xfs_dir2_leaf_log_ents(struct xfs_trans *tp, struct xfs_buf *bp,
81 int first, int last); 81 int first, int last);
82extern void xfs_dir2_leaf_log_header(struct xfs_trans *tp, 82extern void xfs_dir2_leaf_log_header(struct xfs_trans *tp,
83 struct xfs_dabuf *bp); 83 struct xfs_buf *bp);
84extern int xfs_dir2_leaf_lookup(struct xfs_da_args *args); 84extern int xfs_dir2_leaf_lookup(struct xfs_da_args *args);
85extern int xfs_dir2_leaf_removename(struct xfs_da_args *args); 85extern int xfs_dir2_leaf_removename(struct xfs_da_args *args);
86extern int xfs_dir2_leaf_replace(struct xfs_da_args *args); 86extern int xfs_dir2_leaf_replace(struct xfs_da_args *args);
87extern int xfs_dir2_leaf_search_hash(struct xfs_da_args *args, 87extern int xfs_dir2_leaf_search_hash(struct xfs_da_args *args,
88 struct xfs_dabuf *lbp); 88 struct xfs_buf *lbp);
89extern int xfs_dir2_leaf_trim_data(struct xfs_da_args *args, 89extern int xfs_dir2_leaf_trim_data(struct xfs_da_args *args,
90 struct xfs_dabuf *lbp, xfs_dir2_db_t db); 90 struct xfs_buf *lbp, xfs_dir2_db_t db);
91extern struct xfs_dir2_leaf_entry * 91extern struct xfs_dir2_leaf_entry *
92xfs_dir2_leaf_find_entry(struct xfs_dir2_leaf *leaf, int index, int compact, 92xfs_dir2_leaf_find_entry(struct xfs_dir2_leaf *leaf, int index, int compact,
93 int lowstale, int highstale, 93 int lowstale, int highstale,
@@ -96,13 +96,13 @@ extern int xfs_dir2_node_to_leaf(struct xfs_da_state *state);
96 96
97/* xfs_dir2_node.c */ 97/* xfs_dir2_node.c */
98extern int xfs_dir2_leaf_to_node(struct xfs_da_args *args, 98extern int xfs_dir2_leaf_to_node(struct xfs_da_args *args,
99 struct xfs_dabuf *lbp); 99 struct xfs_buf *lbp);
100extern xfs_dahash_t xfs_dir2_leafn_lasthash(struct xfs_dabuf *bp, int *count); 100extern xfs_dahash_t xfs_dir2_leafn_lasthash(struct xfs_buf *bp, int *count);
101extern int xfs_dir2_leafn_lookup_int(struct xfs_dabuf *bp, 101extern int xfs_dir2_leafn_lookup_int(struct xfs_buf *bp,
102 struct xfs_da_args *args, int *indexp, 102 struct xfs_da_args *args, int *indexp,
103 struct xfs_da_state *state); 103 struct xfs_da_state *state);
104extern int xfs_dir2_leafn_order(struct xfs_dabuf *leaf1_bp, 104extern int xfs_dir2_leafn_order(struct xfs_buf *leaf1_bp,
105 struct xfs_dabuf *leaf2_bp); 105 struct xfs_buf *leaf2_bp);
106extern int xfs_dir2_leafn_split(struct xfs_da_state *state, 106extern int xfs_dir2_leafn_split(struct xfs_da_state *state,
107 struct xfs_da_state_blk *oldblk, struct xfs_da_state_blk *newblk); 107 struct xfs_da_state_blk *oldblk, struct xfs_da_state_blk *newblk);
108extern int xfs_dir2_leafn_toosmall(struct xfs_da_state *state, int *action); 108extern int xfs_dir2_leafn_toosmall(struct xfs_da_state *state, int *action);
@@ -122,7 +122,7 @@ extern xfs_ino_t xfs_dir2_sfe_get_ino(struct xfs_dir2_sf_hdr *sfp,
122 struct xfs_dir2_sf_entry *sfep); 122 struct xfs_dir2_sf_entry *sfep);
123extern int xfs_dir2_block_sfsize(struct xfs_inode *dp, 123extern int xfs_dir2_block_sfsize(struct xfs_inode *dp,
124 struct xfs_dir2_data_hdr *block, struct xfs_dir2_sf_hdr *sfhp); 124 struct xfs_dir2_data_hdr *block, struct xfs_dir2_sf_hdr *sfhp);
125extern int xfs_dir2_block_to_sf(struct xfs_da_args *args, struct xfs_dabuf *bp, 125extern int xfs_dir2_block_to_sf(struct xfs_da_args *args, struct xfs_buf *bp,
126 int size, xfs_dir2_sf_hdr_t *sfhp); 126 int size, xfs_dir2_sf_hdr_t *sfhp);
127extern int xfs_dir2_sf_addname(struct xfs_da_args *args); 127extern int xfs_dir2_sf_addname(struct xfs_da_args *args);
128extern int xfs_dir2_sf_create(struct xfs_da_args *args, xfs_ino_t pino); 128extern int xfs_dir2_sf_create(struct xfs_da_args *args, xfs_ino_t pino);
diff --git a/fs/xfs/xfs_dir2_sf.c b/fs/xfs/xfs_dir2_sf.c
index 19bf0c5e38f4..1b9fc3ec7e4b 100644
--- a/fs/xfs/xfs_dir2_sf.c
+++ b/fs/xfs/xfs_dir2_sf.c
@@ -222,7 +222,7 @@ xfs_dir2_block_sfsize(
222int /* error */ 222int /* error */
223xfs_dir2_block_to_sf( 223xfs_dir2_block_to_sf(
224 xfs_da_args_t *args, /* operation arguments */ 224 xfs_da_args_t *args, /* operation arguments */
225 xfs_dabuf_t *bp, /* block buffer */ 225 struct xfs_buf *bp,
226 int size, /* shortform directory size */ 226 int size, /* shortform directory size */
227 xfs_dir2_sf_hdr_t *sfhp) /* shortform directory hdr */ 227 xfs_dir2_sf_hdr_t *sfhp) /* shortform directory hdr */
228{ 228{
@@ -249,7 +249,7 @@ xfs_dir2_block_to_sf(
249 * and add local data. 249 * and add local data.
250 */ 250 */
251 hdr = kmem_alloc(mp->m_dirblksize, KM_SLEEP); 251 hdr = kmem_alloc(mp->m_dirblksize, KM_SLEEP);
252 memcpy(hdr, bp->data, mp->m_dirblksize); 252 memcpy(hdr, bp->b_addr, mp->m_dirblksize);
253 logflags = XFS_ILOG_CORE; 253 logflags = XFS_ILOG_CORE;
254 if ((error = xfs_dir2_shrink_inode(args, mp->m_dirdatablk, bp))) { 254 if ((error = xfs_dir2_shrink_inode(args, mp->m_dirdatablk, bp))) {
255 ASSERT(error != ENOSPC); 255 ASSERT(error != ENOSPC);
diff --git a/fs/xfs/xfs_super.c b/fs/xfs/xfs_super.c
index 425f6e9d4c0c..07f70e17c745 100644
--- a/fs/xfs/xfs_super.c
+++ b/fs/xfs/xfs_super.c
@@ -1491,13 +1491,9 @@ xfs_init_zones(void)
1491 if (!xfs_da_state_zone) 1491 if (!xfs_da_state_zone)
1492 goto out_destroy_btree_cur_zone; 1492 goto out_destroy_btree_cur_zone;
1493 1493
1494 xfs_dabuf_zone = kmem_zone_init(sizeof(xfs_dabuf_t), "xfs_dabuf");
1495 if (!xfs_dabuf_zone)
1496 goto out_destroy_da_state_zone;
1497
1498 xfs_ifork_zone = kmem_zone_init(sizeof(xfs_ifork_t), "xfs_ifork"); 1494 xfs_ifork_zone = kmem_zone_init(sizeof(xfs_ifork_t), "xfs_ifork");
1499 if (!xfs_ifork_zone) 1495 if (!xfs_ifork_zone)
1500 goto out_destroy_dabuf_zone; 1496 goto out_destroy_da_state_zone;
1501 1497
1502 xfs_trans_zone = kmem_zone_init(sizeof(xfs_trans_t), "xfs_trans"); 1498 xfs_trans_zone = kmem_zone_init(sizeof(xfs_trans_t), "xfs_trans");
1503 if (!xfs_trans_zone) 1499 if (!xfs_trans_zone)
@@ -1560,8 +1556,6 @@ xfs_init_zones(void)
1560 kmem_zone_destroy(xfs_trans_zone); 1556 kmem_zone_destroy(xfs_trans_zone);
1561 out_destroy_ifork_zone: 1557 out_destroy_ifork_zone:
1562 kmem_zone_destroy(xfs_ifork_zone); 1558 kmem_zone_destroy(xfs_ifork_zone);
1563 out_destroy_dabuf_zone:
1564 kmem_zone_destroy(xfs_dabuf_zone);
1565 out_destroy_da_state_zone: 1559 out_destroy_da_state_zone:
1566 kmem_zone_destroy(xfs_da_state_zone); 1560 kmem_zone_destroy(xfs_da_state_zone);
1567 out_destroy_btree_cur_zone: 1561 out_destroy_btree_cur_zone:
@@ -1589,7 +1583,6 @@ xfs_destroy_zones(void)
1589 kmem_zone_destroy(xfs_log_item_desc_zone); 1583 kmem_zone_destroy(xfs_log_item_desc_zone);
1590 kmem_zone_destroy(xfs_trans_zone); 1584 kmem_zone_destroy(xfs_trans_zone);
1591 kmem_zone_destroy(xfs_ifork_zone); 1585 kmem_zone_destroy(xfs_ifork_zone);
1592 kmem_zone_destroy(xfs_dabuf_zone);
1593 kmem_zone_destroy(xfs_da_state_zone); 1586 kmem_zone_destroy(xfs_da_state_zone);
1594 kmem_zone_destroy(xfs_btree_cur_zone); 1587 kmem_zone_destroy(xfs_btree_cur_zone);
1595 kmem_zone_destroy(xfs_bmap_free_item_zone); 1588 kmem_zone_destroy(xfs_bmap_free_item_zone);