1 #define HOT_LRU 0 2 #define WARM_LRU 64 3 #define COLD_LRU 128 4 #define TEMP_LRU 192 5 6 #define CLEAR_LRU(id) (id & ~(3<<6)) 7 #define GET_LRU(id) (id & (3<<6)) 8 9 /* See items.c */ 10 uint64_t get_cas_id(void); 11 void set_cas_id(uint64_t new_cas); 12 13 /*@null@*/ 14 item *do_item_alloc(char *key, const size_t nkey, const unsigned int flags, const rel_time_t exptime, const int nbytes); 15 item_chunk *do_item_alloc_chunk(item_chunk *ch, const size_t bytes_remain); 16 item *do_item_alloc_pull(const size_t ntotal, const unsigned int id); 17 void item_free(item *it); 18 bool item_size_ok(const size_t nkey, const int flags, const int nbytes); 19 20 int do_item_link(item *it, const uint32_t hv); /** may fail if transgresses limits */ 21 void do_item_unlink(item *it, const uint32_t hv); 22 void do_item_unlink_nolock(item *it, const uint32_t hv); 23 void do_item_remove(item *it); 24 void do_item_update(item *it); /** update LRU time to current and reposition */ 25 void do_item_update_nolock(item *it); 26 int do_item_replace(item *it, item *new_it, const uint32_t hv); 27 void do_item_link_fixup(item *it); 28 29 int item_is_flushed(item *it); 30 unsigned int do_get_lru_size(uint32_t id); 31 32 void do_item_linktail_q(item *it); 33 void do_item_unlinktail_q(item *it); 34 item *do_item_crawl_q(item *it); 35 36 void *item_lru_bump_buf_create(void); 37 38 #define LRU_PULL_EVICT 1 39 #define LRU_PULL_CRAWL_BLOCKS 2 40 #define LRU_PULL_RETURN_ITEM 4 /* fill info struct if available */ 41 42 struct lru_pull_tail_return { 43 item *it; 44 uint32_t hv; 45 }; 46 47 int lru_pull_tail(const int orig_id, const int cur_lru, 48 const uint64_t total_bytes, const uint8_t flags, const rel_time_t max_age, 49 struct lru_pull_tail_return *ret_it); 50 51 /*@null@*/ 52 char *item_cachedump(const unsigned int slabs_clsid, const unsigned int limit, unsigned int *bytes); 53 void item_stats(ADD_STAT add_stats, void *c); 54 void do_item_stats_add_crawl(const int i, const uint64_t reclaimed, 55 const uint64_t unfetched, const uint64_t checked); 56 void item_stats_totals(ADD_STAT add_stats, void *c); 57 /*@null@*/ 58 void item_stats_sizes(ADD_STAT add_stats, void *c); 59 void item_stats_sizes_init(void); 60 void item_stats_sizes_enable(ADD_STAT add_stats, void *c); 61 void item_stats_sizes_disable(ADD_STAT add_stats, void *c); 62 void item_stats_sizes_add(item *it); 63 void item_stats_sizes_remove(item *it); 64 bool item_stats_sizes_status(void); 65 66 /* stats getter for slab automover */ 67 typedef struct { 68 int64_t evicted; 69 int64_t outofmemory; 70 uint32_t age; 71 } item_stats_automove; 72 void fill_item_stats_automove(item_stats_automove *am); 73 74 item *do_item_get(const char *key, const size_t nkey, const uint32_t hv, conn *c, const bool do_update); 75 item *do_item_touch(const char *key, const size_t nkey, uint32_t exptime, const uint32_t hv, conn *c); 76 void do_item_bump(conn *c, item *it, const uint32_t hv); 77 void item_stats_reset(void); 78 extern pthread_mutex_t lru_locks[POWER_LARGEST]; 79 80 int start_lru_maintainer_thread(void *arg); 81 int stop_lru_maintainer_thread(void); 82 int init_lru_maintainer(void); 83 void lru_maintainer_pause(void); 84 void lru_maintainer_resume(void); 85 86 void *lru_bump_buf_create(void); 87