Commit 5ad2686e9266f24a0bb76b01d5c3ae29b4e149fe

Authored by Ryusuke Konishi
1 parent 9b7b265c9a

nilfs2: get maximum number of child nodes from bmap object

The patch "reduce repetitive calculation of max number of child nodes"
gathered up the calculation of maximum number of child nodes into
nilfs_btree_nchildren_per_block() function.  This makes the function
get resultant value from a private variable in bmap object instead of
calculating it for each call.

Signed-off-by: Ryusuke Konishi <konishi.ryusuke@lab.ntt.co.jp>

Showing 2 changed files with 7 additions and 1 deletions Side-by-side Diff

... ... @@ -105,6 +105,7 @@
105 105 * @b_last_allocated_ptr: last allocated ptr for data block
106 106 * @b_ptr_type: pointer type
107 107 * @b_state: state
  108 + * @b_nchildren_per_block: maximum number of child nodes for non-root nodes
108 109 */
109 110 struct nilfs_bmap {
110 111 union {
... ... @@ -118,6 +119,7 @@
118 119 __u64 b_last_allocated_ptr;
119 120 int b_ptr_type;
120 121 int b_state;
  122 + __u16 b_nchildren_per_block;
121 123 };
122 124  
123 125 /* pointer type */
... ... @@ -154,7 +154,7 @@
154 154  
155 155 static int nilfs_btree_nchildren_per_block(const struct nilfs_bmap *btree)
156 156 {
157   - return NILFS_BTREE_NODE_NCHILDREN_MAX(nilfs_btree_node_size(btree));
  157 + return btree->b_nchildren_per_block;
158 158 }
159 159  
160 160 static inline __le64 *
161 161  
... ... @@ -2218,11 +2218,15 @@
2218 2218 int nilfs_btree_init(struct nilfs_bmap *bmap)
2219 2219 {
2220 2220 bmap->b_ops = &nilfs_btree_ops;
  2221 + bmap->b_nchildren_per_block =
  2222 + NILFS_BTREE_NODE_NCHILDREN_MAX(nilfs_btree_node_size(bmap));
2221 2223 return 0;
2222 2224 }
2223 2225  
2224 2226 void nilfs_btree_init_gc(struct nilfs_bmap *bmap)
2225 2227 {
2226 2228 bmap->b_ops = &nilfs_btree_ops_gc;
  2229 + bmap->b_nchildren_per_block =
  2230 + NILFS_BTREE_NODE_NCHILDREN_MAX(nilfs_btree_node_size(bmap));
2227 2231 }