~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/include/linux/mbcache.h

Version: ~ [ linux-6.11.5 ] ~ [ linux-6.10.14 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.58 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.114 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.169 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.228 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.284 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.322 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.336 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.337 ] ~ [ linux-4.4.302 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.9 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 /* SPDX-License-Identifier: GPL-2.0 */
  2 #ifndef _LINUX_MBCACHE_H
  3 #define _LINUX_MBCACHE_H
  4 
  5 #include <linux/hash.h>
  6 #include <linux/list_bl.h>
  7 #include <linux/list.h>
  8 #include <linux/atomic.h>
  9 #include <linux/fs.h>
 10 
 11 struct mb_cache;
 12 
 13 /* Cache entry flags */
 14 enum {
 15         MBE_REFERENCED_B = 0,
 16         MBE_REUSABLE_B
 17 };
 18 
 19 struct mb_cache_entry {
 20         /* List of entries in cache - protected by cache->c_list_lock */
 21         struct list_head        e_list;
 22         /*
 23          * Hash table list - protected by hash chain bitlock. The entry is
 24          * guaranteed to be hashed while e_refcnt > 0.
 25          */
 26         struct hlist_bl_node    e_hash_list;
 27         /*
 28          * Entry refcount. Once it reaches zero, entry is unhashed and freed.
 29          * While refcount > 0, the entry is guaranteed to stay in the hash and
 30          * e.g. mb_cache_entry_try_delete() will fail.
 31          */
 32         atomic_t                e_refcnt;
 33         /* Key in hash - stable during lifetime of the entry */
 34         u32                     e_key;
 35         unsigned long           e_flags;
 36         /* User provided value - stable during lifetime of the entry */
 37         u64                     e_value;
 38 };
 39 
 40 struct mb_cache *mb_cache_create(int bucket_bits);
 41 void mb_cache_destroy(struct mb_cache *cache);
 42 
 43 int mb_cache_entry_create(struct mb_cache *cache, gfp_t mask, u32 key,
 44                           u64 value, bool reusable);
 45 void __mb_cache_entry_free(struct mb_cache *cache,
 46                            struct mb_cache_entry *entry);
 47 void mb_cache_entry_wait_unused(struct mb_cache_entry *entry);
 48 static inline void mb_cache_entry_put(struct mb_cache *cache,
 49                                       struct mb_cache_entry *entry)
 50 {
 51         unsigned int cnt = atomic_dec_return(&entry->e_refcnt);
 52 
 53         if (cnt > 0) {
 54                 if (cnt <= 2)
 55                         wake_up_var(&entry->e_refcnt);
 56                 return;
 57         }
 58         __mb_cache_entry_free(cache, entry);
 59 }
 60 
 61 struct mb_cache_entry *mb_cache_entry_delete_or_get(struct mb_cache *cache,
 62                                                     u32 key, u64 value);
 63 struct mb_cache_entry *mb_cache_entry_get(struct mb_cache *cache, u32 key,
 64                                           u64 value);
 65 struct mb_cache_entry *mb_cache_entry_find_first(struct mb_cache *cache,
 66                                                  u32 key);
 67 struct mb_cache_entry *mb_cache_entry_find_next(struct mb_cache *cache,
 68                                                 struct mb_cache_entry *entry);
 69 void mb_cache_entry_touch(struct mb_cache *cache,
 70                           struct mb_cache_entry *entry);
 71 
 72 #endif  /* _LINUX_MBCACHE_H */
 73 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

sflogo.php