Lines Matching refs:lru
86 struct lru *lru;
92 struct lru {
101 static void lru_init(struct lru *lru)
103 lru->cursor = NULL;
104 lru->count = 0;
105 INIT_LIST_HEAD(&lru->iterators);
108 static void lru_destroy(struct lru *lru)
110 WARN_ON_ONCE(lru->cursor);
111 WARN_ON_ONCE(!list_empty(&lru->iterators));
115 * Insert a new entry into the lru.
117 static void lru_insert(struct lru *lru, struct lru_entry *le)
120 * Don't be tempted to set to 1, makes the lru aspect
125 if (lru->cursor) {
126 list_add_tail(&le->list, lru->cursor);
129 lru->cursor = &le->list;
131 lru->count++;
145 * Initialize an lru_iter and add it to the list of cursors in the lru.
147 static void lru_iter_begin(struct lru *lru, struct lru_iter *it)
149 it->lru = lru;
150 it->stop = lru->cursor ? to_le(lru->cursor->prev) : NULL;
151 it->e = lru->cursor ? to_le(lru->cursor) : NULL;
152 list_add(&it->list, &lru->iterators);
156 * Remove an lru_iter from the list of cursors in the lru.
194 * the lru accordingly.
196 static void lru_iter_invalidate(struct lru *lru, struct lru_entry *e)
200 list_for_each_entry(it, &lru->iterators, list) {
220 * Remove a specific entry from the lru.
222 static void lru_remove(struct lru *lru, struct lru_entry *le)
224 lru_iter_invalidate(lru, le);
225 if (lru->count == 1) {
226 lru->cursor = NULL;
228 if (lru->cursor == &le->list)
229 lru->cursor = lru->cursor->next;
232 lru->count--;
257 static struct lru_entry *lru_evict(struct lru *lru, le_predicate pred, void *context, bool no_sleep)
260 struct list_head *h = lru->cursor;
270 while (tested < lru->count) {
283 lru->cursor = le->list.next;
284 lru_remove(lru, le);
291 lru->cursor = le->list.next;
347 struct lru_entry lru;
371 * - maintains clean/dirty state along with lru
394 struct lru lru[LIST_SIZE];
525 return container_of(le, struct dm_buffer, lru);
553 lru_init(&bc->lru[LIST_CLEAN]);
554 lru_init(&bc->lru[LIST_DIRTY]);
564 lru_destroy(&bc->lru[LIST_CLEAN]);
565 lru_destroy(&bc->lru[LIST_DIRTY]);
575 return bc->lru[list_mode].count;
622 lru_reference(&b->lru);
664 * Wraps the buffer predicate turning it into an lru predicate. Adds
688 le = lru_evict(&bc->lru[list_mode], __evict_pred, &w, bc->no_sleep);
721 lru_remove(&bc->lru[b->list_mode], &b->lru);
723 lru_insert(&bc->lru[b->list_mode], &b->lru);
731 * Runs through the lru associated with 'old_mode', if the predicate matches then
742 le = lru_evict(&bc->lru[old_mode], __evict_pred, &w, bc->no_sleep);
748 lru_insert(&bc->lru[b->list_mode], &b->lru);
783 struct lru *lru = &bc->lru[list_mode];
786 if (!lru->cursor)
789 first = le = to_le(lru->cursor);
862 lru_insert(&bc->lru[b->list_mode], &b->lru);
887 lru_remove(&bc->lru[b->list_mode], &b->lru);
943 lru_remove(&bc->lru[b->list_mode], &b->lru);
970 * are linked to lru[LIST_CLEAN] with their lru_list field.
973 * lru[LIST_DIRTY] with their lru_list field. When the write
977 * dirty_lru too. They are later added to lru in the process
1633 list_del(&b->lru.list);
1671 list_add(&b->lru.list, &c->reserved_buffers);
2113 lru_iter_begin(&c->cache.lru[LIST_DIRTY], &it);
2551 list_del(&b->lru.list);
2593 list_del(&b->lru.list);