diff options
author | Dave Chinner <david@fromorbit.com> | 2014-06-09 17:32:41 -0400 |
---|---|---|
committer | Dave Chinner <david@fromorbit.com> | 2014-06-09 17:32:41 -0400 |
commit | 8612c7e594808e4a67bc2d4661f5925df2be3f51 (patch) | |
tree | bf13dd921033fb4aaba8bd5ad309e933b6427ad8 /fs/xfs/xfs_da_btree.c | |
parent | b70f14e1ffbb47369b1cc2cdf558c3468ae9e484 (diff) | |
parent | 35f46c5f04cc7c45ce59d3ba4c28ba138184414b (diff) |
Merge branch 'xfs-da-geom' into for-next
Diffstat (limited to 'fs/xfs/xfs_da_btree.c')
-rw-r--r-- | fs/xfs/xfs_da_btree.c | 65 |
1 files changed, 29 insertions, 36 deletions
diff --git a/fs/xfs/xfs_da_btree.c b/fs/xfs/xfs_da_btree.c index 4db5102d403a..a514ab616650 100644 --- a/fs/xfs/xfs_da_btree.c +++ b/fs/xfs/xfs_da_btree.c | |||
@@ -167,8 +167,8 @@ xfs_da3_node_verify( | |||
167 | * we don't know if the node is for and attribute or directory tree, | 167 | * we don't know if the node is for and attribute or directory tree, |
168 | * so only fail if the count is outside both bounds | 168 | * so only fail if the count is outside both bounds |
169 | */ | 169 | */ |
170 | if (ichdr.count > mp->m_dir_node_ents && | 170 | if (ichdr.count > mp->m_dir_geo->node_ents && |
171 | ichdr.count > mp->m_attr_node_ents) | 171 | ichdr.count > mp->m_attr_geo->node_ents) |
172 | return false; | 172 | return false; |
173 | 173 | ||
174 | /* XXX: hash order check? */ | 174 | /* XXX: hash order check? */ |
@@ -598,7 +598,7 @@ xfs_da3_root_split( | |||
598 | * Set up the new root node. | 598 | * Set up the new root node. |
599 | */ | 599 | */ |
600 | error = xfs_da3_node_create(args, | 600 | error = xfs_da3_node_create(args, |
601 | (args->whichfork == XFS_DATA_FORK) ? mp->m_dirleafblk : 0, | 601 | (args->whichfork == XFS_DATA_FORK) ? args->geo->leafblk : 0, |
602 | level + 1, &bp, args->whichfork); | 602 | level + 1, &bp, args->whichfork); |
603 | if (error) | 603 | if (error) |
604 | return error; | 604 | return error; |
@@ -616,10 +616,10 @@ xfs_da3_root_split( | |||
616 | #ifdef DEBUG | 616 | #ifdef DEBUG |
617 | if (oldroot->hdr.info.magic == cpu_to_be16(XFS_DIR2_LEAFN_MAGIC) || | 617 | if (oldroot->hdr.info.magic == cpu_to_be16(XFS_DIR2_LEAFN_MAGIC) || |
618 | oldroot->hdr.info.magic == cpu_to_be16(XFS_DIR3_LEAFN_MAGIC)) { | 618 | oldroot->hdr.info.magic == cpu_to_be16(XFS_DIR3_LEAFN_MAGIC)) { |
619 | ASSERT(blk1->blkno >= mp->m_dirleafblk && | 619 | ASSERT(blk1->blkno >= args->geo->leafblk && |
620 | blk1->blkno < mp->m_dirfreeblk); | 620 | blk1->blkno < args->geo->freeblk); |
621 | ASSERT(blk2->blkno >= mp->m_dirleafblk && | 621 | ASSERT(blk2->blkno >= args->geo->leafblk && |
622 | blk2->blkno < mp->m_dirfreeblk); | 622 | blk2->blkno < args->geo->freeblk); |
623 | } | 623 | } |
624 | #endif | 624 | #endif |
625 | 625 | ||
@@ -663,7 +663,7 @@ xfs_da3_node_split( | |||
663 | /* | 663 | /* |
664 | * Do we have to split the node? | 664 | * Do we have to split the node? |
665 | */ | 665 | */ |
666 | if (nodehdr.count + newcount > state->node_ents) { | 666 | if (nodehdr.count + newcount > state->args->geo->node_ents) { |
667 | /* | 667 | /* |
668 | * Allocate a new node, add to the doubly linked chain of | 668 | * Allocate a new node, add to the doubly linked chain of |
669 | * nodes, then move some of our excess entries into it. | 669 | * nodes, then move some of our excess entries into it. |
@@ -894,8 +894,8 @@ xfs_da3_node_add( | |||
894 | ASSERT(oldblk->index >= 0 && oldblk->index <= nodehdr.count); | 894 | ASSERT(oldblk->index >= 0 && oldblk->index <= nodehdr.count); |
895 | ASSERT(newblk->blkno != 0); | 895 | ASSERT(newblk->blkno != 0); |
896 | if (state->args->whichfork == XFS_DATA_FORK) | 896 | if (state->args->whichfork == XFS_DATA_FORK) |
897 | ASSERT(newblk->blkno >= state->mp->m_dirleafblk && | 897 | ASSERT(newblk->blkno >= state->args->geo->leafblk && |
898 | newblk->blkno < state->mp->m_dirfreeblk); | 898 | newblk->blkno < state->args->geo->freeblk); |
899 | 899 | ||
900 | /* | 900 | /* |
901 | * We may need to make some room before we insert the new node. | 901 | * We may need to make some room before we insert the new node. |
@@ -1089,14 +1089,15 @@ xfs_da3_root_join( | |||
1089 | * that could occur. For dir3 blocks we also need to update the block | 1089 | * that could occur. For dir3 blocks we also need to update the block |
1090 | * number in the buffer header. | 1090 | * number in the buffer header. |
1091 | */ | 1091 | */ |
1092 | memcpy(root_blk->bp->b_addr, bp->b_addr, state->blocksize); | 1092 | memcpy(root_blk->bp->b_addr, bp->b_addr, args->geo->blksize); |
1093 | root_blk->bp->b_ops = bp->b_ops; | 1093 | root_blk->bp->b_ops = bp->b_ops; |
1094 | xfs_trans_buf_copy_type(root_blk->bp, bp); | 1094 | xfs_trans_buf_copy_type(root_blk->bp, bp); |
1095 | if (oldroothdr.magic == XFS_DA3_NODE_MAGIC) { | 1095 | if (oldroothdr.magic == XFS_DA3_NODE_MAGIC) { |
1096 | struct xfs_da3_blkinfo *da3 = root_blk->bp->b_addr; | 1096 | struct xfs_da3_blkinfo *da3 = root_blk->bp->b_addr; |
1097 | da3->blkno = cpu_to_be64(root_blk->bp->b_bn); | 1097 | da3->blkno = cpu_to_be64(root_blk->bp->b_bn); |
1098 | } | 1098 | } |
1099 | xfs_trans_log_buf(args->trans, root_blk->bp, 0, state->blocksize - 1); | 1099 | xfs_trans_log_buf(args->trans, root_blk->bp, 0, |
1100 | args->geo->blksize - 1); | ||
1100 | error = xfs_da_shrink_inode(args, child, bp); | 1101 | error = xfs_da_shrink_inode(args, child, bp); |
1101 | return(error); | 1102 | return(error); |
1102 | } | 1103 | } |
@@ -1139,7 +1140,7 @@ xfs_da3_node_toosmall( | |||
1139 | info = blk->bp->b_addr; | 1140 | info = blk->bp->b_addr; |
1140 | node = (xfs_da_intnode_t *)info; | 1141 | node = (xfs_da_intnode_t *)info; |
1141 | dp->d_ops->node_hdr_from_disk(&nodehdr, node); | 1142 | dp->d_ops->node_hdr_from_disk(&nodehdr, node); |
1142 | if (nodehdr.count > (state->node_ents >> 1)) { | 1143 | if (nodehdr.count > (state->args->geo->node_ents >> 1)) { |
1143 | *action = 0; /* blk over 50%, don't try to join */ | 1144 | *action = 0; /* blk over 50%, don't try to join */ |
1144 | return(0); /* blk over 50%, don't try to join */ | 1145 | return(0); /* blk over 50%, don't try to join */ |
1145 | } | 1146 | } |
@@ -1176,8 +1177,8 @@ xfs_da3_node_toosmall( | |||
1176 | * We prefer coalescing with the lower numbered sibling so as | 1177 | * We prefer coalescing with the lower numbered sibling so as |
1177 | * to shrink a directory over time. | 1178 | * to shrink a directory over time. |
1178 | */ | 1179 | */ |
1179 | count = state->node_ents; | 1180 | count = state->args->geo->node_ents; |
1180 | count -= state->node_ents >> 2; | 1181 | count -= state->args->geo->node_ents >> 2; |
1181 | count -= nodehdr.count; | 1182 | count -= nodehdr.count; |
1182 | 1183 | ||
1183 | /* start with smaller blk num */ | 1184 | /* start with smaller blk num */ |
@@ -1472,7 +1473,7 @@ xfs_da3_node_lookup_int( | |||
1472 | * Descend thru the B-tree searching each level for the right | 1473 | * Descend thru the B-tree searching each level for the right |
1473 | * node to use, until the right hashval is found. | 1474 | * node to use, until the right hashval is found. |
1474 | */ | 1475 | */ |
1475 | blkno = (args->whichfork == XFS_DATA_FORK)? state->mp->m_dirleafblk : 0; | 1476 | blkno = (args->whichfork == XFS_DATA_FORK)? args->geo->leafblk : 0; |
1476 | for (blk = &state->path.blk[0], state->path.active = 1; | 1477 | for (blk = &state->path.blk[0], state->path.active = 1; |
1477 | state->path.active <= XFS_DA_NODE_MAXDEPTH; | 1478 | state->path.active <= XFS_DA_NODE_MAXDEPTH; |
1478 | blk++, state->path.active++) { | 1479 | blk++, state->path.active++) { |
@@ -2090,20 +2091,12 @@ xfs_da_grow_inode( | |||
2090 | xfs_dablk_t *new_blkno) | 2091 | xfs_dablk_t *new_blkno) |
2091 | { | 2092 | { |
2092 | xfs_fileoff_t bno; | 2093 | xfs_fileoff_t bno; |
2093 | int count; | ||
2094 | int error; | 2094 | int error; |
2095 | 2095 | ||
2096 | trace_xfs_da_grow_inode(args); | 2096 | trace_xfs_da_grow_inode(args); |
2097 | 2097 | ||
2098 | if (args->whichfork == XFS_DATA_FORK) { | 2098 | bno = args->geo->leafblk; |
2099 | bno = args->dp->i_mount->m_dirleafblk; | 2099 | error = xfs_da_grow_inode_int(args, &bno, args->geo->fsbcount); |
2100 | count = args->dp->i_mount->m_dirblkfsbs; | ||
2101 | } else { | ||
2102 | bno = 0; | ||
2103 | count = 1; | ||
2104 | } | ||
2105 | |||
2106 | error = xfs_da_grow_inode_int(args, &bno, count); | ||
2107 | if (!error) | 2100 | if (!error) |
2108 | *new_blkno = (xfs_dablk_t)bno; | 2101 | *new_blkno = (xfs_dablk_t)bno; |
2109 | return error; | 2102 | return error; |
@@ -2158,7 +2151,7 @@ xfs_da3_swap_lastblock( | |||
2158 | w = args->whichfork; | 2151 | w = args->whichfork; |
2159 | ASSERT(w == XFS_DATA_FORK); | 2152 | ASSERT(w == XFS_DATA_FORK); |
2160 | mp = dp->i_mount; | 2153 | mp = dp->i_mount; |
2161 | lastoff = mp->m_dirfreeblk; | 2154 | lastoff = args->geo->freeblk; |
2162 | error = xfs_bmap_last_before(tp, dp, &lastoff, w); | 2155 | error = xfs_bmap_last_before(tp, dp, &lastoff, w); |
2163 | if (error) | 2156 | if (error) |
2164 | return error; | 2157 | return error; |
@@ -2170,15 +2163,15 @@ xfs_da3_swap_lastblock( | |||
2170 | /* | 2163 | /* |
2171 | * Read the last block in the btree space. | 2164 | * Read the last block in the btree space. |
2172 | */ | 2165 | */ |
2173 | last_blkno = (xfs_dablk_t)lastoff - mp->m_dirblkfsbs; | 2166 | last_blkno = (xfs_dablk_t)lastoff - args->geo->fsbcount; |
2174 | error = xfs_da3_node_read(tp, dp, last_blkno, -1, &last_buf, w); | 2167 | error = xfs_da3_node_read(tp, dp, last_blkno, -1, &last_buf, w); |
2175 | if (error) | 2168 | if (error) |
2176 | return error; | 2169 | return error; |
2177 | /* | 2170 | /* |
2178 | * Copy the last block into the dead buffer and log it. | 2171 | * Copy the last block into the dead buffer and log it. |
2179 | */ | 2172 | */ |
2180 | memcpy(dead_buf->b_addr, last_buf->b_addr, mp->m_dirblksize); | 2173 | memcpy(dead_buf->b_addr, last_buf->b_addr, args->geo->blksize); |
2181 | xfs_trans_log_buf(tp, dead_buf, 0, mp->m_dirblksize - 1); | 2174 | xfs_trans_log_buf(tp, dead_buf, 0, args->geo->blksize - 1); |
2182 | dead_info = dead_buf->b_addr; | 2175 | dead_info = dead_buf->b_addr; |
2183 | /* | 2176 | /* |
2184 | * Get values from the moved block. | 2177 | * Get values from the moved block. |
@@ -2247,7 +2240,7 @@ xfs_da3_swap_lastblock( | |||
2247 | sizeof(sib_info->back))); | 2240 | sizeof(sib_info->back))); |
2248 | sib_buf = NULL; | 2241 | sib_buf = NULL; |
2249 | } | 2242 | } |
2250 | par_blkno = mp->m_dirleafblk; | 2243 | par_blkno = args->geo->leafblk; |
2251 | level = -1; | 2244 | level = -1; |
2252 | /* | 2245 | /* |
2253 | * Walk down the tree looking for the parent of the moved block. | 2246 | * Walk down the tree looking for the parent of the moved block. |
@@ -2357,10 +2350,7 @@ xfs_da_shrink_inode( | |||
2357 | w = args->whichfork; | 2350 | w = args->whichfork; |
2358 | tp = args->trans; | 2351 | tp = args->trans; |
2359 | mp = dp->i_mount; | 2352 | mp = dp->i_mount; |
2360 | if (w == XFS_DATA_FORK) | 2353 | count = args->geo->fsbcount; |
2361 | count = mp->m_dirblkfsbs; | ||
2362 | else | ||
2363 | count = 1; | ||
2364 | for (;;) { | 2354 | for (;;) { |
2365 | /* | 2355 | /* |
2366 | * Remove extents. If we get ENOSPC for a dir we have to move | 2356 | * Remove extents. If we get ENOSPC for a dir we have to move |
@@ -2479,7 +2469,10 @@ xfs_dabuf_map( | |||
2479 | ASSERT(map && *map); | 2469 | ASSERT(map && *map); |
2480 | ASSERT(*nmaps == 1); | 2470 | ASSERT(*nmaps == 1); |
2481 | 2471 | ||
2482 | nfsb = (whichfork == XFS_DATA_FORK) ? mp->m_dirblkfsbs : 1; | 2472 | if (whichfork == XFS_DATA_FORK) |
2473 | nfsb = mp->m_dir_geo->fsbcount; | ||
2474 | else | ||
2475 | nfsb = mp->m_attr_geo->fsbcount; | ||
2483 | 2476 | ||
2484 | /* | 2477 | /* |
2485 | * Caller doesn't have a mapping. -2 means don't complain | 2478 | * Caller doesn't have a mapping. -2 means don't complain |