Function report

Linux Kernel

v5.5.9

Brick Technologies Co., Ltd

Source Code:lib\assoc_array.c Create Date:2022-07-28 06:54:26
Last Modify:2020-03-12 14:18:49 Copyright©Brick
home page Tree
Annotation kernel can get tool activityDownload SCCTChinese

Name:Handle insertion into the middle of a shortcut.

Proto:static bool assoc_array_insert_mid_shortcut(struct assoc_array_edit *edit, const struct assoc_array_ops *ops, struct assoc_array_walk_result *result)

Type:bool

Parameter:

TypeParameterName
struct assoc_array_edit *edit
const struct assoc_array_ops *ops
struct assoc_array_walk_result *result
804  shortcut = shortcut
805  level = level
806  sc_level = sc_level
807  sc_segments = sc_segments
808  dissimilarity = dissimilarity
810  pr_devel("-->%s(ix=%d dis=%lx scix=%d)\n", __func__, level, dissimilarity, sc_level)
819  diff = __ffs - find first set bit in word*@word: The word to search* Undefined if no bit exists, so code should check against 0 first.
820  diff &= ~ASSOC_ARRAY_LEVEL_STEP_MASK
821  diff += sc_level & ~ASSOC_ARRAY_KEY_CHUNK_MASK
822  pr_devel("diff=%d\n", diff)
824  If Not back_pointer Then
825  ptr = The node at the root of the tree
826  Else if assoc_array_ptr_is_node(back_pointer) Then
827  node = assoc_array_ptr_to_node(back_pointer)
828  ptr = slots[parent_slot]
829  Else
830  BUG()
833  excised_meta[0] = assoc_array_shortcut_to_ptr(shortcut)
836  new_n0 = kzalloc - allocate memory. The memory is set to zero.*@size: how many bytes of memory are required.*@flags: the type of memory to allocate (see kmalloc).
837  If Not new_n0 Then Return false
839  new_meta[0] = assoc_array_node_to_ptr(new_n0)
840  adjust_count_on = new_n0
846  level += ASSOC_ARRAY_LEVEL_STEP
847  If diff > level Then
848  pr_devel("pre-shortcut %d...%d\n", level, diff)
849  keylen = und_up - round up to next specified power of 2*@x: the value to round*@y: multiple to round up to (must be a power of 2)* Rounds @x up to next multiple of @y (which must be a power of 2).* To perform arbitrary rounding up, use roundup() below.(diff, Key data retrieved in chunks of this size )
850  keylen >>= ASSOC_ARRAY_KEY_CHUNK_SHIFT
852  new_s0 = kzalloc - allocate memory. The memory is set to zero.*@size: how many bytes of memory are required.*@flags: the type of memory to allocate (see kmalloc).
854  If Not new_s0 Then Return false
856  new_meta[1] = assoc_array_shortcut_to_ptr(new_s0)
857  to = assoc_array_shortcut_to_ptr(new_s0)
858  back_pointer = back_pointer
859  parent_slot = parent_slot
860  next_node = assoc_array_node_to_ptr(new_n0)
861  skip_to_level = diff
863  back_pointer = assoc_array_shortcut_to_ptr(new_s0)
864  parent_slot = 0
866  No 3D Now!(index_key, index_key, keylen * sizeof(unsignedlong))
869  blank = ULONG_MAX << (diff & ASSOC_ARRAY_KEY_CHUNK_MASK)
870  pr_devel("blank off [%zu] %d: %lx\n", keylen - 1, diff, blank)
871  index_key[keylen - 1] &= ~blank
872  Else
873  pr_devel("no pre-shortcut\n")
874  to = assoc_array_node_to_ptr(new_n0)
875  back_pointer = back_pointer
876  parent_slot = parent_slot
879  side = assoc_array_ptr_to_node(next_node)
880  nr_leaves_on_branch = nr_leaves_on_branch
885  sc_slot = sc_segments >> (diff & ASSOC_ARRAY_KEY_CHUNK_MASK)
886  sc_slot &= ASSOC_ARRAY_FAN_MASK
888  pr_devel("new slot %lx >> %d -> %d\n", sc_segments, diff & ASSOC_ARRAY_KEY_CHUNK_MASK, sc_slot)
896  level = diff + ASSOC_ARRAY_LEVEL_STEP
897  If level < skip_to_level Then
898  pr_devel("post-shortcut %d...%d\n", level, skip_to_level)
899  keylen = und_up - round up to next specified power of 2*@x: the value to round*@y: multiple to round up to (must be a power of 2)* Rounds @x up to next multiple of @y (which must be a power of 2).* To perform arbitrary rounding up, use roundup() below.(skip_to_level, Key data retrieved in chunks of this size )
900  keylen >>= ASSOC_ARRAY_KEY_CHUNK_SHIFT
902  new_s1 = kzalloc - allocate memory. The memory is set to zero.*@size: how many bytes of memory are required.*@flags: the type of memory to allocate (see kmalloc).
904  If Not new_s1 Then Return false
906  new_meta[2] = assoc_array_shortcut_to_ptr(new_s1)
908  back_pointer = assoc_array_node_to_ptr(new_n0)
909  parent_slot = sc_slot
910  next_node = next_node
911  skip_to_level = skip_to_level
913  slots[sc_slot] = assoc_array_shortcut_to_ptr(new_s1)
915  No 3D Now!(index_key, index_key, keylen * sizeof(unsignedlong))
918  ptr = back_pointer
919  to = assoc_array_shortcut_to_ptr(new_s1)
920  Else
921  pr_devel("no post-shortcut\n")
928  slots[sc_slot] = next_node
929  p = parent_slot
930  to = sc_slot
931  ptr = back_pointer
932  to = assoc_array_node_to_ptr(new_n0)
936  If sc_slot == 0 Then leaf_p = slots[1]
938  Else leaf_p = slots[0]
941  pr_devel("<--%s() = ok [split shortcut]\n", __func__)
942  Return edit
Caller
NameDescribe
assoc_array_insertassoc_array_insert - Script insertion of an object into an associative array*@array: The array to insert into