函数逻辑报告

Linux Kernel

v5.5.9

Brick Technologies Co., Ltd

Source Code:lib\assoc_array.c Create Date:2022-07-27 07:51:18
Last Modify:2020-03-12 14:18:49 Copyright©Brick
首页 函数Tree
注解内核,赢得工具下载SCCTEnglish

函数名称:Handle insertion into a terminal node.

函数原型:static bool assoc_array_insert_into_terminal_node(struct assoc_array_edit *edit, const struct assoc_array_ops *ops, const void *index_key, struct assoc_array_walk_result *result)

返回类型:bool

参数:

类型参数名称
struct assoc_array_edit *edit
const struct assoc_array_ops *ops
const void *index_key
struct assoc_array_walk_result *result
488  node等于 Node in which leaf might be found
489  level等于level
490  segment_cache[Number of slots per node ]等于slot
492  打印调试信息("-->%s()\n", __func__)
499  free_slot等于负1
504 i小于Number of slots per node 循环
505  ptr等于slots[i]
506  如果非ptr
507  free_slot等于i
508  继续下一循环
513  打印调试信息("replace in slot %d\n", i)
514  leaf_p等于slots[i]
515  dead_leaf等于slots[i]
516  打印调试信息("<--%s() = ok [replace]\n", __func__)
517  返回:true
524  如果free_slot大于等于0则
525  打印调试信息("insert in free slot %d\n", free_slot)
526  leaf_p等于slots[free_slot]
527  adjust_count_on等于node
528  打印调试信息("<--%s() = ok [insert]\n", __func__)
529  返回:true
539  new_n0等于分配内存并置零
540  如果非new_n0则返回:false
542  new_meta[0]等于assoc_array_node_to_ptr(new_n0)
543  new_n1等于分配内存并置零
544  如果非new_n1则返回:false
546  new_meta[1]等于assoc_array_node_to_ptr(new_n1)
549  打印调试信息("no spare slots\n")
550  have_meta = false
551 i小于Number of slots per node 循环
552  ptr等于slots[i]
553  如果assoc_array_ptr_is_meta(ptr)则
554  segment_cache[i]等于0xff
555  have_meta = true
556  继续下一循环
558  base_seg等于get_object_key_chunk(assoc_array_ptr_to_leaf(ptr), level)
560  base_seg右移等于level按位与ASSOC_ARRAY_KEY_CHUNK_MASK
561  segment_cache[i]等于base_seg按位与ASSOC_ARRAY_FAN_MASK
564  如果have_meta
565  打印调试信息("have meta\n")
566  转到:split_node
570  dissimilarity等于0
571  base_seg等于segment_cache[0]
572 i小于Number of slots per node 循环dissimilarity或等于segment_cache[i]按位异或base_seg
575  打印调试信息("only leaves; dissimilarity=%lx\n", dissimilarity)
577  如果dissimilarity按位与ASSOC_ARRAY_FAN_MASK的值恒等于0则
581  如果segment_cache[Number of slots per node ]按位异或base_seg的值恒等于0则转到:all_leaves_cluster_together
592  打印调试信息("present leaves cluster but not new leaf\n")
595  split_node :
596  打印调试信息("split node\n")
613  to等于assoc_array_node_to_ptr(new_n0)
614  back_pointer等于back_pointer
615  parent_slot等于parent_slot
616  back_pointer等于assoc_array_node_to_ptr(new_n0)
617  parent_slot等于负1
619  do_split_node :
620  打印调试信息("do_split_node\n")
622  nr_leaves_on_branch等于nr_leaves_on_branch
623  nr_leaves_on_branch等于0
631 i小于Number of slots per node 循环
632  slot等于segment_cache[i]
633  如果slot不等于0xff则以j小于Number of slots per node 加1循环
635  如果segment_cache[j]恒等于slot则转到:found_slot_for_multiple_occupancy
638  found_slot_for_multiple_occupancy :
639  打印调试信息("same slot: %x %x [%02x]\n", i, j, slot)
640  BUG_ON(i >= Number of slots per node )
641  BUG_ON(j >= Number of slots per node + 1)
642  BUG_ON(slot >= Number of slots per node )
644  parent_slot等于slot
647 i小于Number of slots per node 循环如果assoc_array_ptr_is_meta(slots[i])则
649  slots[i]等于slots[i]
650  否则slots[i] = NULL
652  BUG_ON(slots[slot] != NULL)
653  slots[slot]等于assoc_array_node_to_ptr(new_n1)
656  free_slot等于负1
657  next_slot等于0
658 i小于Number of slots per node 循环
659  如果assoc_array_ptr_is_meta(slots[i])则继续下一循环
661  如果segment_cache[i]恒等于slot
662  slots[next_slot++]等于slots[i]
663  nr_leaves_on_branch自加
664  否则
665  循环
666  free_slot自加
667  当(slots[free_slot] != NULL)循环
668  slots[free_slot]等于slots[i]
672  打印调试信息("filtered: f=%x n=%x\n", free_slot, next_slot)
674  如果segment_cache[Number of slots per node ]不等于slot
675  循环
676  free_slot自加
677  当(slots[free_slot] != NULL)循环
678  leaf_p等于slots[free_slot]
679  adjust_count_on等于new_n0
680  否则
681  leaf_p等于slots[next_slot++]
682  adjust_count_on等于new_n1
685  BUG_ON(next_slot <= 1)
687  set_backpointers_to等于assoc_array_node_to_ptr(new_n0)
688 i小于Number of slots per node 循环
689  如果segment_cache[i]恒等于0xff则
690  ptr等于slots[i]
692  如果assoc_array_ptr_is_node(ptr)则
695  否则
702  ptr等于back_pointer
703  如果非ptrptr等于The node at the root of the tree
705  否则如果assoc_array_ptr_is_node(ptr)则ptr等于slots[parent_slot]
707  否则ptr等于next_node
709  excised_meta[0]等于assoc_array_node_to_ptr(node)
710  打印调试信息("<--%s() = ok [split node]\n", __func__)
711  返回:true
713  all_leaves_cluster_together :
728  打印调试信息("all leaves cluster together\n")
729  diff等于INT_MAX
730 i小于Number of slots per node 循环
731  x等于diff_objects(assoc_array_ptr_to_leaf(slots[i]), index_key)
733  如果x小于diff
734  BUG_ON(x < 0)
735  diff等于x
738  BUG_ON(diff == INT_MAX)
739  BUG_ON(diff < level + ASSOC_ARRAY_LEVEL_STEP)
741  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 )
742  keylen右移等于ASSOC_ARRAY_KEY_CHUNK_SHIFT
744  new_s0等于分配内存并置零
746  如果非new_s0则返回:false
748  new_meta[2]等于assoc_array_shortcut_to_ptr(new_s0)
750  to等于assoc_array_shortcut_to_ptr(new_s0)
751  back_pointer等于back_pointer
752  parent_slot等于parent_slot
753  next_node等于assoc_array_node_to_ptr(new_n0)
754  back_pointer等于assoc_array_shortcut_to_ptr(new_s0)
755  parent_slot等于0
756  back_pointer等于assoc_array_node_to_ptr(new_n0)
757  parent_slot等于负1
759  skip_to_level等于level等于diff按位与ASSOC_ARRAY_LEVEL_STEP_MASK的反
760  打印调试信息("skip_to_level = %d [diff %d]\n", level, diff)
761  BUG_ON(level <= 0)
763 i小于keylen循环index_key[i]等于get_key_chunk(index_key, i * Key data retrieved in chunks of this size )
767  如果level按位与ASSOC_ARRAY_KEY_CHUNK_MASK
768  blank等于ULONG_MAX左移level按位与ASSOC_ARRAY_KEY_CHUNK_MASK的值位
769  打印调试信息("blank off [%zu] %d: %lx\n", keylen - 1, level, blank)
770  index_key[keylen - 1]与等于blank的反
776 i小于Number of slots per node 循环
777  ptr等于slots[i]
778  base_seg等于get_object_key_chunk(assoc_array_ptr_to_leaf(ptr), level)
780  base_seg右移等于level按位与ASSOC_ARRAY_KEY_CHUNK_MASK
781  segment_cache[i]等于base_seg按位与ASSOC_ARRAY_FAN_MASK
784  base_seg等于get_key_chunk(index_key, level)
785  base_seg右移等于level按位与ASSOC_ARRAY_KEY_CHUNK_MASK
786  segment_cache[Number of slots per node ]等于base_seg按位与ASSOC_ARRAY_FAN_MASK
787  转到:do_split_node
调用者
名称描述
assoc_array_insertassoc_array_insert - Script insertion of an object into an associative array*@array: The array to insert into