diff options
author | Dave Chinner <dchinner@redhat.com> | 2014-06-06 01:22:04 -0400 |
---|---|---|
committer | Dave Chinner <david@fromorbit.com> | 2014-06-06 01:22:04 -0400 |
commit | b2a21e7a6bfa6aa1b712fb6167d37a96f332d3d5 (patch) | |
tree | 0e9140196e999dc591ee64ccca44fcef0801fb21 /fs | |
parent | c2c4c477e0d02b0b352a71a25be56c9d35537265 (diff) |
xfs: remove redundant geometry information from xfs_da_state
It's carried in state->args->geo, so there's no need to duplicate it
and use more stack space than necessary.
Signed-off-by: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Brian Foster <bfoster@redhat.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>
Diffstat (limited to 'fs')
-rw-r--r-- | fs/xfs/xfs_attr.c | 8 | ||||
-rw-r--r-- | fs/xfs/xfs_attr_leaf.c | 19 | ||||
-rw-r--r-- | fs/xfs/xfs_da_btree.c | 13 | ||||
-rw-r--r-- | fs/xfs/xfs_da_btree.h | 2 | ||||
-rw-r--r-- | fs/xfs/xfs_dir2_node.c | 13 |
5 files changed, 20 insertions, 35 deletions
diff --git a/fs/xfs/xfs_attr.c b/fs/xfs/xfs_attr.c index 470a22d190fb..bfe36fc2cdc2 100644 --- a/fs/xfs/xfs_attr.c +++ b/fs/xfs/xfs_attr.c | |||
@@ -896,8 +896,6 @@ restart: | |||
896 | state = xfs_da_state_alloc(); | 896 | state = xfs_da_state_alloc(); |
897 | state->args = args; | 897 | state->args = args; |
898 | state->mp = mp; | 898 | state->mp = mp; |
899 | state->blocksize = args->geo->blksize; | ||
900 | state->node_ents = args->geo->node_ents; | ||
901 | 899 | ||
902 | /* | 900 | /* |
903 | * Search to see if name already exists, and get back a pointer | 901 | * Search to see if name already exists, and get back a pointer |
@@ -1075,8 +1073,6 @@ restart: | |||
1075 | state = xfs_da_state_alloc(); | 1073 | state = xfs_da_state_alloc(); |
1076 | state->args = args; | 1074 | state->args = args; |
1077 | state->mp = mp; | 1075 | state->mp = mp; |
1078 | state->blocksize = args->geo->blksize; | ||
1079 | state->node_ents = args->geo->node_ents; | ||
1080 | state->inleaf = 0; | 1076 | state->inleaf = 0; |
1081 | error = xfs_da3_node_lookup_int(state, &retval); | 1077 | error = xfs_da3_node_lookup_int(state, &retval); |
1082 | if (error) | 1078 | if (error) |
@@ -1167,8 +1163,6 @@ xfs_attr_node_removename(xfs_da_args_t *args) | |||
1167 | state = xfs_da_state_alloc(); | 1163 | state = xfs_da_state_alloc(); |
1168 | state->args = args; | 1164 | state->args = args; |
1169 | state->mp = dp->i_mount; | 1165 | state->mp = dp->i_mount; |
1170 | state->blocksize = args->geo->blksize; | ||
1171 | state->node_ents = args->geo->node_ents; | ||
1172 | 1166 | ||
1173 | /* | 1167 | /* |
1174 | * Search to see if name exists, and get back a pointer to it. | 1168 | * Search to see if name exists, and get back a pointer to it. |
@@ -1430,8 +1424,6 @@ xfs_attr_node_get(xfs_da_args_t *args) | |||
1430 | state = xfs_da_state_alloc(); | 1424 | state = xfs_da_state_alloc(); |
1431 | state->args = args; | 1425 | state->args = args; |
1432 | state->mp = args->dp->i_mount; | 1426 | state->mp = args->dp->i_mount; |
1433 | state->blocksize = args->geo->blksize; | ||
1434 | state->node_ents = args->geo->node_ents; | ||
1435 | 1427 | ||
1436 | /* | 1428 | /* |
1437 | * Search to see if name exists, and get back a pointer to it. | 1429 | * Search to see if name exists, and get back a pointer to it. |
diff --git a/fs/xfs/xfs_attr_leaf.c b/fs/xfs/xfs_attr_leaf.c index ae33b141342b..28712d29e43c 100644 --- a/fs/xfs/xfs_attr_leaf.c +++ b/fs/xfs/xfs_attr_leaf.c | |||
@@ -1494,8 +1494,8 @@ xfs_attr3_leaf_rebalance( | |||
1494 | 1494 | ||
1495 | xfs_attr3_leaf_hdr_to_disk(leaf1, &ichdr1); | 1495 | xfs_attr3_leaf_hdr_to_disk(leaf1, &ichdr1); |
1496 | xfs_attr3_leaf_hdr_to_disk(leaf2, &ichdr2); | 1496 | xfs_attr3_leaf_hdr_to_disk(leaf2, &ichdr2); |
1497 | xfs_trans_log_buf(args->trans, blk1->bp, 0, state->blocksize-1); | 1497 | xfs_trans_log_buf(args->trans, blk1->bp, 0, args->geo->blksize - 1); |
1498 | xfs_trans_log_buf(args->trans, blk2->bp, 0, state->blocksize-1); | 1498 | xfs_trans_log_buf(args->trans, blk2->bp, 0, args->geo->blksize - 1); |
1499 | 1499 | ||
1500 | /* | 1500 | /* |
1501 | * Copy out last hashval in each block for B-tree code. | 1501 | * Copy out last hashval in each block for B-tree code. |
@@ -1592,7 +1592,7 @@ xfs_attr3_leaf_figure_balance( | |||
1592 | half += ichdr1->usedbytes + ichdr2->usedbytes + | 1592 | half += ichdr1->usedbytes + ichdr2->usedbytes + |
1593 | xfs_attr_leaf_newentsize(state->args, NULL); | 1593 | xfs_attr_leaf_newentsize(state->args, NULL); |
1594 | half /= 2; | 1594 | half /= 2; |
1595 | lastdelta = state->blocksize; | 1595 | lastdelta = state->args->geo->blksize; |
1596 | entry = xfs_attr3_leaf_entryp(leaf1); | 1596 | entry = xfs_attr3_leaf_entryp(leaf1); |
1597 | for (count = index = 0; count < max; entry++, index++, count++) { | 1597 | for (count = index = 0; count < max; entry++, index++, count++) { |
1598 | 1598 | ||
@@ -1690,7 +1690,7 @@ xfs_attr3_leaf_toosmall( | |||
1690 | bytes = xfs_attr3_leaf_hdr_size(leaf) + | 1690 | bytes = xfs_attr3_leaf_hdr_size(leaf) + |
1691 | ichdr.count * sizeof(xfs_attr_leaf_entry_t) + | 1691 | ichdr.count * sizeof(xfs_attr_leaf_entry_t) + |
1692 | ichdr.usedbytes; | 1692 | ichdr.usedbytes; |
1693 | if (bytes > (state->blocksize >> 1)) { | 1693 | if (bytes > (state->args->geo->blksize >> 1)) { |
1694 | *action = 0; /* blk over 50%, don't try to join */ | 1694 | *action = 0; /* blk over 50%, don't try to join */ |
1695 | return(0); | 1695 | return(0); |
1696 | } | 1696 | } |
@@ -1744,7 +1744,8 @@ xfs_attr3_leaf_toosmall( | |||
1744 | 1744 | ||
1745 | xfs_attr3_leaf_hdr_from_disk(&ichdr2, bp->b_addr); | 1745 | xfs_attr3_leaf_hdr_from_disk(&ichdr2, bp->b_addr); |
1746 | 1746 | ||
1747 | bytes = state->blocksize - (state->blocksize >> 2) - | 1747 | bytes = state->args->geo->blksize - |
1748 | (state->args->geo->blksize >> 2) - | ||
1748 | ichdr.usedbytes - ichdr2.usedbytes - | 1749 | ichdr.usedbytes - ichdr2.usedbytes - |
1749 | ((ichdr.count + ichdr2.count) * | 1750 | ((ichdr.count + ichdr2.count) * |
1750 | sizeof(xfs_attr_leaf_entry_t)) - | 1751 | sizeof(xfs_attr_leaf_entry_t)) - |
@@ -1997,7 +1998,7 @@ xfs_attr3_leaf_unbalance( | |||
1997 | struct xfs_attr_leafblock *tmp_leaf; | 1998 | struct xfs_attr_leafblock *tmp_leaf; |
1998 | struct xfs_attr3_icleaf_hdr tmphdr; | 1999 | struct xfs_attr3_icleaf_hdr tmphdr; |
1999 | 2000 | ||
2000 | tmp_leaf = kmem_zalloc(state->blocksize, KM_SLEEP); | 2001 | tmp_leaf = kmem_zalloc(state->args->geo->blksize, KM_SLEEP); |
2001 | 2002 | ||
2002 | /* | 2003 | /* |
2003 | * Copy the header into the temp leaf so that all the stuff | 2004 | * Copy the header into the temp leaf so that all the stuff |
@@ -2010,7 +2011,7 @@ xfs_attr3_leaf_unbalance( | |||
2010 | tmphdr.magic = savehdr.magic; | 2011 | tmphdr.magic = savehdr.magic; |
2011 | tmphdr.forw = savehdr.forw; | 2012 | tmphdr.forw = savehdr.forw; |
2012 | tmphdr.back = savehdr.back; | 2013 | tmphdr.back = savehdr.back; |
2013 | tmphdr.firstused = state->blocksize; | 2014 | tmphdr.firstused = state->args->geo->blksize; |
2014 | 2015 | ||
2015 | /* write the header to the temp buffer to initialise it */ | 2016 | /* write the header to the temp buffer to initialise it */ |
2016 | xfs_attr3_leaf_hdr_to_disk(tmp_leaf, &tmphdr); | 2017 | xfs_attr3_leaf_hdr_to_disk(tmp_leaf, &tmphdr); |
@@ -2035,14 +2036,14 @@ xfs_attr3_leaf_unbalance( | |||
2035 | tmp_leaf, &tmphdr, tmphdr.count, | 2036 | tmp_leaf, &tmphdr, tmphdr.count, |
2036 | drophdr.count); | 2037 | drophdr.count); |
2037 | } | 2038 | } |
2038 | memcpy(save_leaf, tmp_leaf, state->blocksize); | 2039 | memcpy(save_leaf, tmp_leaf, state->args->geo->blksize); |
2039 | savehdr = tmphdr; /* struct copy */ | 2040 | savehdr = tmphdr; /* struct copy */ |
2040 | kmem_free(tmp_leaf); | 2041 | kmem_free(tmp_leaf); |
2041 | } | 2042 | } |
2042 | 2043 | ||
2043 | xfs_attr3_leaf_hdr_to_disk(save_leaf, &savehdr); | 2044 | xfs_attr3_leaf_hdr_to_disk(save_leaf, &savehdr); |
2044 | xfs_trans_log_buf(state->args->trans, save_blk->bp, 0, | 2045 | xfs_trans_log_buf(state->args->trans, save_blk->bp, 0, |
2045 | state->blocksize - 1); | 2046 | state->args->geo->blksize - 1); |
2046 | 2047 | ||
2047 | /* | 2048 | /* |
2048 | * Copy out last hashval in each block for B-tree code. | 2049 | * Copy out last hashval in each block for B-tree code. |
diff --git a/fs/xfs/xfs_da_btree.c b/fs/xfs/xfs_da_btree.c index e6c994c00672..166087fd1946 100644 --- a/fs/xfs/xfs_da_btree.c +++ b/fs/xfs/xfs_da_btree.c | |||
@@ -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. |
@@ -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 */ |
diff --git a/fs/xfs/xfs_da_btree.h b/fs/xfs/xfs_da_btree.h index 0ac63adca705..6e153e399a77 100644 --- a/fs/xfs/xfs_da_btree.h +++ b/fs/xfs/xfs_da_btree.h | |||
@@ -128,8 +128,6 @@ typedef struct xfs_da_state_path { | |||
128 | typedef struct xfs_da_state { | 128 | typedef struct xfs_da_state { |
129 | xfs_da_args_t *args; /* filename arguments */ | 129 | xfs_da_args_t *args; /* filename arguments */ |
130 | struct xfs_mount *mp; /* filesystem mount point */ | 130 | struct xfs_mount *mp; /* filesystem mount point */ |
131 | unsigned int blocksize; /* logical block size */ | ||
132 | unsigned int node_ents; /* how many entries in danode */ | ||
133 | xfs_da_state_path_t path; /* search/split paths */ | 131 | xfs_da_state_path_t path; /* search/split paths */ |
134 | xfs_da_state_path_t altpath; /* alternate path for join */ | 132 | xfs_da_state_path_t altpath; /* alternate path for join */ |
135 | unsigned char inleaf; /* insert into 1->lf, 0->splf */ | 133 | unsigned char inleaf; /* insert into 1->lf, 0->splf */ |
diff --git a/fs/xfs/xfs_dir2_node.c b/fs/xfs/xfs_dir2_node.c index 65df8cbedbb7..da43d304fca2 100644 --- a/fs/xfs/xfs_dir2_node.c +++ b/fs/xfs/xfs_dir2_node.c | |||
@@ -1414,7 +1414,7 @@ xfs_dir2_leafn_toosmall( | |||
1414 | 1414 | ||
1415 | count = leafhdr.count - leafhdr.stale; | 1415 | count = leafhdr.count - leafhdr.stale; |
1416 | bytes = dp->d_ops->leaf_hdr_size + count * sizeof(ents[0]); | 1416 | bytes = dp->d_ops->leaf_hdr_size + count * sizeof(ents[0]); |
1417 | if (bytes > (state->blocksize >> 1)) { | 1417 | if (bytes > (state->args->geo->blksize >> 1)) { |
1418 | /* | 1418 | /* |
1419 | * Blk over 50%, don't try to join. | 1419 | * Blk over 50%, don't try to join. |
1420 | */ | 1420 | */ |
@@ -1467,7 +1467,8 @@ xfs_dir2_leafn_toosmall( | |||
1467 | * Count bytes in the two blocks combined. | 1467 | * Count bytes in the two blocks combined. |
1468 | */ | 1468 | */ |
1469 | count = leafhdr.count - leafhdr.stale; | 1469 | count = leafhdr.count - leafhdr.stale; |
1470 | bytes = state->blocksize - (state->blocksize >> 2); | 1470 | bytes = state->args->geo->blksize - |
1471 | (state->args->geo->blksize >> 2); | ||
1471 | 1472 | ||
1472 | leaf = bp->b_addr; | 1473 | leaf = bp->b_addr; |
1473 | dp->d_ops->leaf_hdr_from_disk(&hdr2, leaf); | 1474 | dp->d_ops->leaf_hdr_from_disk(&hdr2, leaf); |
@@ -1591,8 +1592,6 @@ xfs_dir2_node_addname( | |||
1591 | state = xfs_da_state_alloc(); | 1592 | state = xfs_da_state_alloc(); |
1592 | state->args = args; | 1593 | state->args = args; |
1593 | state->mp = args->dp->i_mount; | 1594 | state->mp = args->dp->i_mount; |
1594 | state->blocksize = args->geo->blksize; | ||
1595 | state->node_ents = args->geo->node_ents; | ||
1596 | /* | 1595 | /* |
1597 | * Look up the name. We're not supposed to find it, but | 1596 | * Look up the name. We're not supposed to find it, but |
1598 | * this gives us the insertion point. | 1597 | * this gives us the insertion point. |
@@ -2037,8 +2036,6 @@ xfs_dir2_node_lookup( | |||
2037 | state = xfs_da_state_alloc(); | 2036 | state = xfs_da_state_alloc(); |
2038 | state->args = args; | 2037 | state->args = args; |
2039 | state->mp = args->dp->i_mount; | 2038 | state->mp = args->dp->i_mount; |
2040 | state->blocksize = args->geo->blksize; | ||
2041 | state->node_ents = args->geo->node_ents; | ||
2042 | /* | 2039 | /* |
2043 | * Fill in the path to the entry in the cursor. | 2040 | * Fill in the path to the entry in the cursor. |
2044 | */ | 2041 | */ |
@@ -2092,8 +2089,6 @@ xfs_dir2_node_removename( | |||
2092 | state = xfs_da_state_alloc(); | 2089 | state = xfs_da_state_alloc(); |
2093 | state->args = args; | 2090 | state->args = args; |
2094 | state->mp = args->dp->i_mount; | 2091 | state->mp = args->dp->i_mount; |
2095 | state->blocksize = args->geo->blksize; | ||
2096 | state->node_ents = args->geo->node_ents; | ||
2097 | 2092 | ||
2098 | /* Look up the entry we're deleting, set up the cursor. */ | 2093 | /* Look up the entry we're deleting, set up the cursor. */ |
2099 | error = xfs_da3_node_lookup_int(state, &rval); | 2094 | error = xfs_da3_node_lookup_int(state, &rval); |
@@ -2162,8 +2157,6 @@ xfs_dir2_node_replace( | |||
2162 | state = xfs_da_state_alloc(); | 2157 | state = xfs_da_state_alloc(); |
2163 | state->args = args; | 2158 | state->args = args; |
2164 | state->mp = args->dp->i_mount; | 2159 | state->mp = args->dp->i_mount; |
2165 | state->blocksize = args->geo->blksize; | ||
2166 | state->node_ents = args->geo->node_ents; | ||
2167 | inum = args->inumber; | 2160 | inum = args->inumber; |
2168 | /* | 2161 | /* |
2169 | * Lookup the entry to change in the btree. | 2162 | * Lookup the entry to change in the btree. |