Function report

Linux Kernel

v5.5.9

Brick Technologies Co., Ltd

Source Code:fs\mbcache.c Create Date:2022-07-28 20:29:33
Last Modify:2020-03-12 14:18:49 Copyright©Brick
home page Tree
Annotation kernel can get tool activityDownload SCCTChinese

Name:mb_cache_entry_create - create entry in cache*@cache - cache where the entry should be created*@mask - gfp mask with which the entry should be allocated*@key - key of the entry*@value - value of the entry*@reusable - is the entry reusable by others?

Proto:int mb_cache_entry_create(struct mb_cache *cache, gfp_t mask, unsigned int key, u64 value, bool reusable)

Type:int

Parameter:

TypeParameterName
struct mb_cache *cache
gfp_tmask
unsigned intkey
u64value
boolreusable
82  If Number of entries in cache >= Maximum entries in cache to avoid degrading hash too much Then schedule_work - put work task in global workqueue*@work: job to be done* Returns %false if @work was already on the kernel-global workqueue and* %true otherwise
85  If Number of entries in cache >= 2 * Maximum entries in cache to avoid degrading hash too much Then mb_cache_shrink(cache, Number of entries to reclaim synchronously when there are too many entries* in cache)
88  entry = kmem_cache_alloc(mb_entry_cache, mask)
89  If Not entry Then Return -ENOMEM
92  Initialization list head
94  atomic_set( & e_refcnt, 1)
95  Key in hash - stable during lifetime of the entry = key
96  User provided value - stable during lifetime of the entry = value
97  e_reusable = reusable
98  e_referenced = 0
99  head = mb_cache_entry_head(cache, key)
100  hlist_bl_lock(head)
102  If Key in hash - stable during lifetime of the entry == key && User provided value - stable during lifetime of the entry == value Then
103  hlist_bl_unlock(head)
104  kmem_cache_free(mb_entry_cache, entry)
105  Return -EBUSY
108  hlist_bl_add_head( & Hash table list - protected by hash chain bitlock , head)
109  hlist_bl_unlock(head)
111  spin_lock( & Protects c_list, c_entry_count )
112  list_add_tail - add a new entry*@new: new entry to be added*@head: list head to add it before* Insert a new entry before the specified head.* This is useful for implementing queues.
114  atomic_inc( & e_refcnt)
115  Number of entries in cache ++
116  spin_unlock( & Protects c_list, c_entry_count )
118  Return 0