diff options
author | Kent Overstreet <kent.overstreet@gmail.com> | 2020-11-29 23:55:51 -0500 |
---|---|---|
committer | Kent Overstreet <kent.overstreet@gmail.com> | 2020-11-30 00:06:46 -0500 |
commit | 1e574cb1aa07ab3a796c7d6c5501b96f3056ef4d (patch) | |
tree | ebcb516a753e19eb83f2dd4ed9b4f851f8afd911 /include/linux/slab.h | |
parent | 41bec63b265a38dd9fa168b6042ea5bf07135048 (diff) |
Update bcachefs sources to 021e62a098 bcachefs: Fix error in filesystem initialization
Diffstat (limited to 'include/linux/slab.h')
-rw-r--r-- | include/linux/slab.h | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/include/linux/slab.h b/include/linux/slab.h index ff342b6..b8a1235 100644 --- a/include/linux/slab.h +++ b/include/linux/slab.h @@ -132,4 +132,35 @@ static inline void *kmemdup(const void *src, size_t len, gfp_t gfp) return p; } +struct kmem_cache { + size_t obj_size; +}; + +static inline void *kmem_cache_alloc(struct kmem_cache *c, gfp_t gfp) +{ + return kmalloc(c->obj_size, gfp); +} + +static inline void kmem_cache_free(struct kmem_cache *c, void *p) +{ + kfree(p); +} + +static inline void kmem_cache_destroy(struct kmem_cache *p) +{ + kfree(p); +} + +static inline struct kmem_cache *kmem_cache_create(size_t obj_size) +{ + struct kmem_cache *p = kmalloc(sizeof(*p), GFP_KERNEL); + if (!p) + return NULL; + + p->obj_size = obj_size; + return p; +} + +#define KMEM_CACHE(_struct, _flags) kmem_cache_create(sizeof(struct _struct)) + #endif /* __TOOLS_LINUX_SLAB_H */ |