Lines Matching full:entry

34  * Multiple I/O requests may be using an L2 table cache entry at any given
35 * time. That means an entry may be in use across several requests and
36 * reference counting is needed to free the entry at the correct time. In
37 * particular, an entry evicted from the cache will only be freed once all
40 * An in-flight I/O request will hold a reference to a L2 table cache entry for
50 * table will be deleted in favor of the existing cache entry.
75 CachedL2Table *entry, *next_entry; in qed_free_l2_cache() local
77 QTAILQ_FOREACH_SAFE(entry, &l2_cache->entries, node, next_entry) { in qed_free_l2_cache()
78 qemu_vfree(entry->table); in qed_free_l2_cache()
79 g_free(entry); in qed_free_l2_cache()
84 * Allocate an uninitialized entry from the cache
86 * The returned entry has a reference count of 1 and is owned by the caller.
87 * The caller must allocate the actual table field for this entry and it must
92 CachedL2Table *entry; in qed_alloc_l2_cache_entry() local
94 entry = g_malloc0(sizeof(*entry)); in qed_alloc_l2_cache_entry()
95 entry->ref++; in qed_alloc_l2_cache_entry()
97 trace_qed_alloc_l2_cache_entry(l2_cache, entry); in qed_alloc_l2_cache_entry()
99 return entry; in qed_alloc_l2_cache_entry()
103 * Decrease an entry's reference count and free if necessary when the reference
108 void qed_unref_l2_cache_entry(CachedL2Table *entry) in qed_unref_l2_cache_entry() argument
110 if (!entry) { in qed_unref_l2_cache_entry()
114 entry->ref--; in qed_unref_l2_cache_entry()
115 trace_qed_unref_l2_cache_entry(entry, entry->ref); in qed_unref_l2_cache_entry()
116 if (entry->ref == 0) { in qed_unref_l2_cache_entry()
117 qemu_vfree(entry->table); in qed_unref_l2_cache_entry()
118 g_free(entry); in qed_unref_l2_cache_entry()
123 * Find an entry in the L2 cache. This may return NULL and it's up to the
126 * For a cached entry, this function increases the reference count and returns
127 * the entry.
133 CachedL2Table *entry; in qed_find_l2_cache_entry() local
135 QTAILQ_FOREACH(entry, &l2_cache->entries, node) { in qed_find_l2_cache_entry()
136 if (entry->offset == offset) { in qed_find_l2_cache_entry()
137 trace_qed_find_l2_cache_entry(l2_cache, entry, offset, entry->ref); in qed_find_l2_cache_entry()
138 entry->ref++; in qed_find_l2_cache_entry()
139 return entry; in qed_find_l2_cache_entry()
146 * Commit an L2 cache entry into the cache. This is meant to be used as part of
147 * the process to satisfy a cache miss. A caller would allocate an entry which
148 * is not actually in the L2 cache and then once the entry was valid and
149 * present on disk, the entry can be committed into the cache.
152 * called until the entry is present on disk and the L1 has been updated to
153 * point to the entry.
163 CachedL2Table *entry; in qed_commit_l2_cache_entry() local
165 entry = qed_find_l2_cache_entry(l2_cache, l2_table->offset); in qed_commit_l2_cache_entry()
166 if (entry) { in qed_commit_l2_cache_entry()
167 qed_unref_l2_cache_entry(entry); in qed_commit_l2_cache_entry()
172 /* Evict an unused cache entry so we have space. If all entries are in use in qed_commit_l2_cache_entry()
177 QTAILQ_FOREACH_SAFE(entry, &l2_cache->entries, node, next) { in qed_commit_l2_cache_entry()
178 if (entry->ref > 1) { in qed_commit_l2_cache_entry()
182 QTAILQ_REMOVE(&l2_cache->entries, entry, node); in qed_commit_l2_cache_entry()
184 qed_unref_l2_cache_entry(entry); in qed_commit_l2_cache_entry()