Skip to content

Commit 330018f

Browse files
Peng Zhangakpm00
authored andcommitted
maple_tree: simplify mas_leaf_set_meta()
Now it seems that the incoming 'end' is already pointing to the last item, so we can simplify this function, considering only whether the last slot is being used. This has passed the maple tree test suite. Link: https://lkml.kernel.org/r/[email protected] Signed-off-by: Peng Zhang <[email protected]> Reviewed-by: Liam R. Howlett <[email protected]> Cc: Dan Carpenter <[email protected]> Signed-off-by: Andrew Morton <[email protected]>
1 parent 026b935 commit 330018f

File tree

1 file changed

+4
-18
lines changed

1 file changed

+4
-18
lines changed

lib/maple_tree.c

Lines changed: 4 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1964,27 +1964,13 @@ static inline void mas_mab_cp(struct ma_state *mas, unsigned char mas_start,
19641964

19651965
/*
19661966
* mas_leaf_set_meta() - Set the metadata of a leaf if possible.
1967-
* @mas: The maple state
19681967
* @node: The maple node
1969-
* @pivots: pointer to the maple node pivots
19701968
* @mt: The maple type
1971-
* @end: The assumed end
1972-
*
1973-
* Note, end may be incremented within this function but not modified at the
1974-
* source. This is fine since the metadata is the last thing to be stored in a
1975-
* node during a write.
1969+
* @end: The node end
19761970
*/
1977-
static inline void mas_leaf_set_meta(struct ma_state *mas,
1978-
struct maple_node *node, unsigned long *pivots,
1971+
static inline void mas_leaf_set_meta(struct maple_node *node,
19791972
enum maple_type mt, unsigned char end)
19801973
{
1981-
/* There is no room for metadata already */
1982-
if (mt_pivots[mt] <= end)
1983-
return;
1984-
1985-
if (pivots[end] && pivots[end] < mas->max)
1986-
end++;
1987-
19881974
if (end < mt_slots[mt] - 1)
19891975
ma_set_meta(node, mt, 0, end);
19901976
}
@@ -2041,7 +2027,7 @@ static inline void mab_mas_cp(struct maple_big_node *b_node,
20412027

20422028
ma_set_meta(node, mt, offset, end);
20432029
} else {
2044-
mas_leaf_set_meta(mas, node, pivots, mt, end);
2030+
mas_leaf_set_meta(node, mt, end);
20452031
}
20462032
}
20472033

@@ -3962,7 +3948,7 @@ static inline bool mas_wr_node_store(struct ma_wr_state *wr_mas,
39623948
dst_pivots[new_end] = mas->max;
39633949

39643950
done:
3965-
mas_leaf_set_meta(mas, newnode, dst_pivots, maple_leaf_64, new_end);
3951+
mas_leaf_set_meta(newnode, maple_leaf_64, new_end);
39663952
if (in_rcu) {
39673953
struct maple_enode *old_enode = mas->node;
39683954

0 commit comments

Comments
 (0)