lkml.org 
[lkml]   [2023]   [May]   [18]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    From
    Subject[PATCH v4 10/35] maple_tree: Use MAS_BUG_ON() when setting a leaf node as a parent
    Date
    Use MAS_BUG_ON() to dump the maple state and tree in the unlikely event
    of an issue.

    Signed-off-by: Liam R. Howlett <Liam.Howlett@oracle.com>
    ---
    lib/maple_tree.c | 26 +++++++++++++-------------
    1 file changed, 13 insertions(+), 13 deletions(-)

    diff --git a/lib/maple_tree.c b/lib/maple_tree.c
    index 8fd83f21caf0..a594f1d88d06 100644
    --- a/lib/maple_tree.c
    +++ b/lib/maple_tree.c
    @@ -453,7 +453,7 @@ enum maple_type mas_parent_type(struct ma_state *mas, struct maple_enode *enode)
    }

    /*
    - * mte_set_parent() - Set the parent node and encode the slot
    + * mas_set_parent() - Set the parent node and encode the slot
    * @enode: The encoded maple node.
    * @parent: The encoded maple node that is the parent of @enode.
    * @slot: The slot that @enode resides in @parent.
    @@ -462,16 +462,16 @@ enum maple_type mas_parent_type(struct ma_state *mas, struct maple_enode *enode)
    * parent type.
    */
    static inline
    -void mte_set_parent(struct maple_enode *enode, const struct maple_enode *parent,
    - unsigned char slot)
    +void mas_set_parent(struct ma_state *mas, struct maple_enode *enode,
    + const struct maple_enode *parent, unsigned char slot)
    {
    unsigned long val = (unsigned long)parent;
    unsigned long shift;
    unsigned long type;
    enum maple_type p_type = mte_node_type(parent);

    - BUG_ON(p_type == maple_dense);
    - BUG_ON(p_type == maple_leaf_64);
    + MAS_BUG_ON(mas, p_type == maple_dense);
    + MAS_BUG_ON(mas, p_type == maple_leaf_64);

    switch (p_type) {
    case maple_range_64:
    @@ -1740,7 +1740,7 @@ static inline void mas_adopt_children(struct ma_state *mas,
    offset = ma_data_end(node, type, pivots, mas->max);
    do {
    child = mas_slot_locked(mas, slots, offset);
    - mte_set_parent(child, parent, offset);
    + mas_set_parent(mas, child, parent, offset);
    } while (offset--);
    }

    @@ -2705,9 +2705,9 @@ static inline void mas_set_split_parent(struct ma_state *mas,
    return;

    if ((*slot) <= split)
    - mte_set_parent(mas->node, left, *slot);
    + mas_set_parent(mas, mas->node, left, *slot);
    else if (right)
    - mte_set_parent(mas->node, right, (*slot) - split - 1);
    + mas_set_parent(mas, mas->node, right, (*slot) - split - 1);

    (*slot)++;
    }
    @@ -3104,12 +3104,12 @@ static int mas_spanning_rebalance(struct ma_state *mas,
    mte_node_type(mast->orig_l->node));
    mast->orig_l->depth++;
    mab_mas_cp(mast->bn, 0, mt_slots[mast->bn->type] - 1, &l_mas, true);
    - mte_set_parent(left, l_mas.node, slot);
    + mas_set_parent(mas, left, l_mas.node, slot);
    if (middle)
    - mte_set_parent(middle, l_mas.node, ++slot);
    + mas_set_parent(mas, middle, l_mas.node, ++slot);

    if (right)
    - mte_set_parent(right, l_mas.node, ++slot);
    + mas_set_parent(mas, right, l_mas.node, ++slot);

    if (mas_is_root_limits(mast->l)) {
    new_root:
    @@ -3336,8 +3336,8 @@ static inline bool mas_split_final_node(struct maple_subtree_state *mast,
    * The Big_node data should just fit in a single node.
    */
    ancestor = mas_new_ma_node(mas, mast->bn);
    - mte_set_parent(mast->l->node, ancestor, mast->l->offset);
    - mte_set_parent(mast->r->node, ancestor, mast->r->offset);
    + mas_set_parent(mas, mast->l->node, ancestor, mast->l->offset);
    + mas_set_parent(mas, mast->r->node, ancestor, mast->r->offset);
    mte_to_node(ancestor)->parent = mas_mn(mas)->parent;

    mast->l->node = ancestor;
    --
    2.39.2
    \
     
     \ /
      Last update: 2023-05-18 16:59    [W:7.101 / U:0.008 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site