Lines Matching full:entry

56 	struct squashfs_cache_entry *entry;  in squashfs_cache_get()  local
62 if (cache->entry[i].block == block) { in squashfs_cache_get()
84 * At least one unused cache entry. A simple in squashfs_cache_get()
85 * round-robin strategy is used to choose the entry to in squashfs_cache_get()
90 if (cache->entry[i].refcount == 0) in squashfs_cache_get()
96 entry = &cache->entry[i]; in squashfs_cache_get()
99 * Initialise chosen cache entry, and fill it in from in squashfs_cache_get()
103 entry->block = block; in squashfs_cache_get()
104 entry->refcount = 1; in squashfs_cache_get()
105 entry->pending = 1; in squashfs_cache_get()
106 entry->num_waiters = 0; in squashfs_cache_get()
107 entry->error = 0; in squashfs_cache_get()
110 entry->length = squashfs_read_data(sb, block, length, in squashfs_cache_get()
111 &entry->next_index, entry->actor); in squashfs_cache_get()
115 if (entry->length < 0) in squashfs_cache_get()
116 entry->error = entry->length; in squashfs_cache_get()
118 entry->pending = 0; in squashfs_cache_get()
121 * While filling this entry one or more other processes in squashfs_cache_get()
125 if (entry->num_waiters) { in squashfs_cache_get()
127 wake_up_all(&entry->wait_queue); in squashfs_cache_get()
137 * previously unused there's one less cache entry available in squashfs_cache_get()
140 entry = &cache->entry[i]; in squashfs_cache_get()
141 if (entry->refcount == 0) in squashfs_cache_get()
143 entry->refcount++; in squashfs_cache_get()
146 * If the entry is currently being filled in by another process in squashfs_cache_get()
149 if (entry->pending) { in squashfs_cache_get()
150 entry->num_waiters++; in squashfs_cache_get()
152 wait_event(entry->wait_queue, !entry->pending); in squashfs_cache_get()
161 cache->name, i, entry->block, entry->refcount, entry->error); in squashfs_cache_get()
163 if (entry->error) in squashfs_cache_get()
164 ERROR("Unable to read %s cache entry [%llx]\n", cache->name, in squashfs_cache_get()
166 return entry; in squashfs_cache_get()
171 * Release cache entry, once usage count is zero it can be reused.
173 void squashfs_cache_put(struct squashfs_cache_entry *entry) in squashfs_cache_put() argument
175 struct squashfs_cache *cache = entry->cache; in squashfs_cache_put()
178 entry->refcount--; in squashfs_cache_put()
179 if (entry->refcount == 0) { in squashfs_cache_put()
205 if (cache->entry[i].data) { in squashfs_cache_delete()
207 kfree(cache->entry[i].data[j]); in squashfs_cache_delete()
208 kfree(cache->entry[i].data); in squashfs_cache_delete()
210 kfree(cache->entry[i].actor); in squashfs_cache_delete()
213 kfree(cache->entry); in squashfs_cache_delete()
220 * size block_size. To avoid vmalloc fragmentation issues each entry
234 cache->entry = kcalloc(entries, sizeof(*(cache->entry)), GFP_KERNEL); in squashfs_cache_init()
235 if (cache->entry == NULL) { in squashfs_cache_init()
253 struct squashfs_cache_entry *entry = &cache->entry[i]; in squashfs_cache_init() local
255 init_waitqueue_head(&cache->entry[i].wait_queue); in squashfs_cache_init()
256 entry->cache = cache; in squashfs_cache_init()
257 entry->block = SQUASHFS_INVALID_BLK; in squashfs_cache_init()
258 entry->data = kcalloc(cache->pages, sizeof(void *), GFP_KERNEL); in squashfs_cache_init()
259 if (entry->data == NULL) { in squashfs_cache_init()
260 ERROR("Failed to allocate %s cache entry\n", name); in squashfs_cache_init()
265 entry->data[j] = kmalloc(PAGE_SIZE, GFP_KERNEL); in squashfs_cache_init()
266 if (entry->data[j] == NULL) { in squashfs_cache_init()
272 entry->actor = squashfs_page_actor_init(entry->data, in squashfs_cache_init()
274 if (entry->actor == NULL) { in squashfs_cache_init()
275 ERROR("Failed to allocate %s cache entry\n", name); in squashfs_cache_init()
289 * Copy up to length bytes from cache entry to buffer starting at offset bytes
290 * into the cache entry. If there's not length bytes then copy the number of
293 int squashfs_copy_data(void *buffer, struct squashfs_cache_entry *entry, in squashfs_copy_data() argument
301 return min(length, entry->length - offset); in squashfs_copy_data()
303 while (offset < entry->length) { in squashfs_copy_data()
304 void *buff = entry->data[offset / PAGE_SIZE] in squashfs_copy_data()
306 int bytes = min_t(int, entry->length - offset, in squashfs_copy_data()
336 struct squashfs_cache_entry *entry; in squashfs_read_metadata() local
344 entry = squashfs_cache_get(sb, msblk->block_cache, *block, 0); in squashfs_read_metadata()
345 if (entry->error) { in squashfs_read_metadata()
346 res = entry->error; in squashfs_read_metadata()
348 } else if (*offset >= entry->length) { in squashfs_read_metadata()
353 bytes = squashfs_copy_data(buffer, entry, *offset, length); in squashfs_read_metadata()
359 if (*offset == entry->length) { in squashfs_read_metadata()
360 *block = entry->next_index; in squashfs_read_metadata()
364 squashfs_cache_put(entry); in squashfs_read_metadata()
370 squashfs_cache_put(entry); in squashfs_read_metadata()