Function report

Linux Kernel

v5.5.9

Brick Technologies Co., Ltd

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

Name:btree_insert_level

Proto:static int btree_insert_level(struct btree_head *head, struct btree_geo *geo, unsigned long *key, void *val, int level, gfp_t gfp)

Type:int

Parameter:

TypeParameterName
struct btree_head *head
struct btree_geo *geo
unsigned long *key
void *val
intlevel
gfp_tgfp
455  BUG_ON(!val)
456  If height < level Then
457  err = btree_grow(head, geo, gfp)
458  If err Then Return err
462  retry :
463  node = locate the correct leaf node in the btree
464  pos = getpos(geo, node, key)
465  fill = getfill(geo, node, pos)
467  BUG_ON(pos < fill && keycmp(geo, node, pos, key) == 0)
469  If fill == no_pairs Then
473  new = btree_node_alloc(head, gfp)
474  If Not new Then Return -ENOMEM
476  err = btree_insert_level(head, geo, bkey(geo, node, fill / 2 - 1), new, level + 1, gfp)
479  If err Then
481  Return err
483  When i < fill / 2 cycle
484  setkey(geo, new, i, bkey(geo, node, i))
485  setval(geo, new, i, bval(geo, node, i))
486  setkey(geo, node, i, bkey(geo, node, i + fill / 2))
487  setval(geo, node, i, bval(geo, node, i + fill / 2))
488  clearpair(geo, node, i + fill / 2)
490  If fill & 1 Then
491  setkey(geo, node, i, bkey(geo, node, fill - 1))
492  setval(geo, node, i, bval(geo, node, fill - 1))
493  clearpair(geo, node, fill - 1)
495  Go to retry
497  BUG_ON(fill >= no_pairs)
500  When i > pos cycle
501  setkey(geo, node, i, bkey(geo, node, i - 1))
502  setval(geo, node, i, bval(geo, node, i - 1))
504  setkey(geo, node, pos, key)
505  setval(geo, node, pos, val)
507  Return 0
Caller
NameDescribe
btree_insert_level
btree_insert