NVMLib  very early alpha
A library to optimally use a Hybrid RAM setup.
pool.h
Go to the documentation of this file.
1 #ifndef __NVM_POOL__
2 #define __NVM_POOL__
3 
4 #include "globals.h"
5 #include "free_slot_list.h"
6 #include "hashmap.h"
7 #include <libpmemobj.h>
8 
9 #define POOL_ID_MALLOC_OBJ -1
10 
11 #define POOL_SIZE (2 << 12) // Pool size is 4kB
12 
14 
15 POBJ_LAYOUT_BEGIN(free_slot_layout);
16 POBJ_LAYOUT_ROOT(free_slot_layout, struct pool_free_slots_root);
17 POBJ_LAYOUT_TOID(free_slot_layout, struct pool_free_slot);
18 POBJ_LAYOUT_END(free_slot_layout);
19 
20 typedef struct pool_free_slot {
27 
28 typedef struct pool_free_slots_root {
31 
32 typedef struct pool_kv_st {
36 
37 typedef struct pool_free_slot_val_st {
39  PMEMobjpool* pool;
42 
43 
46 
47 HASH_MAP(pool_kv) *pool_map;
48 HASH_MAP(pool_free_slot_val) *pool_free_slot_map;
49 // Initialise the metadata datastructures
51 
52 // Returns the memory mapped file pointer of the current pool
54 
55 // Returns the current number of the pool
57 
58 // Returns the offset of the pointer to the allocated space in NVRAM
60 
61 // Frees the allocated spaces
62 void nvm_free(uint64_t pool_id, uint64_t offset, size_t size);
63 
64 void create_new_pool(size_t size);
65 
66 
67 #endif // !__NVM_POOL__
POBJ_LAYOUT_ROOT
POBJ_LAYOUT_ROOT(free_slot_layout, struct pool_free_slots_root)
get_first_free_offset
uint64_t get_first_free_offset(size_t size)
pool_kv_st
Definition: pool.h:32
get_pool_from_poolid
uintptr_t get_pool_from_poolid(uint64_t pool_id)
Definition: pool.c:79
pool_free_slot::start_b
uint64_t start_b
Definition: pool.h:21
pool_free_slot_val_st::head
pool_free_slot_head * head
Definition: pool.h:40
pool_free_slot::end_b
uint64_t end_b
Definition: pool.h:22
pool_free_slot_val
struct pool_free_slot_val_st pool_free_slot_val
pool_kv_st::pool_ptr
uintptr_t pool_ptr
Definition: pool.h:34
DECLARE_HASHMAP
DECLARE_HASHMAP(pool_free_slot_val)
pool_free_slots_root::head
struct pool_free_slot_head head
Definition: pool.h:29
create_new_pool
void create_new_pool(size_t size)
Definition: pool.c:94
POBJ_TAILQ_HEAD
POBJ_TAILQ_HEAD(pool_free_slot_head, struct pool_free_slot)
pool_free_slots_root
Definition: pool.h:28
hashmap.h
pool_free_slot_val_st
Definition: pool.h:37
nvm_free
void nvm_free(uint64_t pool_id, uint64_t offset, size_t size)
Definition: pool.c:137
pool_free_slots_root
struct pool_free_slots_root pool_free_slots_root
globals.h
pool_free_slot::POBJ_TAILQ_ENTRY
POBJ_TAILQ_ENTRY(struct pool_free_slot) fnd
uint64_t
__uint64_t uint64_t
Definition: globals.h:51
uint16_t
__uint16_t uint16_t
Definition: globals.h:53
pool_free_slot_val_st::pool
PMEMobjpool * pool
Definition: pool.h:39
POBJ_LAYOUT_TOID
POBJ_LAYOUT_TOID(free_slot_layout, struct pool_free_slot)
pool_free_slot_head
struct pool_free_slot_head pool_free_slot_head
Definition: pool.h:26
POBJ_LAYOUT_END
POBJ_LAYOUT_END(free_slot_layout)
pool_free_slot
Definition: pool.h:20
pool_free_slot
struct pool_free_slot pool_free_slot
initialize_pool
int initialize_pool()
pool_kv_st::key
uint16_t key
Definition: pool.h:33
uintptr_t
unsigned long int uintptr_t
Definition: globals.h:56
free_slot_list.h
POBJ_LAYOUT_BEGIN
POBJ_LAYOUT_BEGIN(free_slot_layout)
pool_kv
struct pool_kv_st pool_kv
HASH_MAP
HASH_MAP(pool_kv) *pool_map
Definition: pool.c:33
uint32_t
__uint32_t uint32_t
Definition: globals.h:52
num_pools
uint32_t num_pools
Definition: pool.h:13
get_current_poolid
uint64_t get_current_poolid()
Definition: pool.c:90
pool_free_slot_val_st::key
uint16_t key
Definition: pool.h:38