Lines Matching refs:entry
70 struct squashfs_cache_entry *entry; in squashfs_cache_get() local
76 if (cache->entry[i].block == block) in squashfs_cache_get()
100 if (cache->entry[i].refcount == 0) in squashfs_cache_get()
106 entry = &cache->entry[i]; in squashfs_cache_get()
113 entry->block = block; in squashfs_cache_get()
114 entry->refcount = 1; in squashfs_cache_get()
115 entry->pending = 1; in squashfs_cache_get()
116 entry->num_waiters = 0; in squashfs_cache_get()
117 entry->error = 0; in squashfs_cache_get()
120 entry->length = squashfs_read_data(sb, entry->data, in squashfs_cache_get()
121 block, length, &entry->next_index, in squashfs_cache_get()
126 if (entry->length < 0) in squashfs_cache_get()
127 entry->error = entry->length; in squashfs_cache_get()
129 entry->pending = 0; in squashfs_cache_get()
136 if (entry->num_waiters) { in squashfs_cache_get()
138 wake_up_all(&entry->wait_queue); in squashfs_cache_get()
151 entry = &cache->entry[i]; in squashfs_cache_get()
152 if (entry->refcount == 0) in squashfs_cache_get()
154 entry->refcount++; in squashfs_cache_get()
160 if (entry->pending) { in squashfs_cache_get()
161 entry->num_waiters++; in squashfs_cache_get()
163 wait_event(entry->wait_queue, !entry->pending); in squashfs_cache_get()
172 cache->name, i, entry->block, entry->refcount, entry->error); in squashfs_cache_get()
174 if (entry->error) in squashfs_cache_get()
177 return entry; in squashfs_cache_get()
184 void squashfs_cache_put(struct squashfs_cache_entry *entry) in squashfs_cache_put() argument
186 struct squashfs_cache *cache = entry->cache; in squashfs_cache_put()
189 entry->refcount--; in squashfs_cache_put()
190 if (entry->refcount == 0) { in squashfs_cache_put()
216 if (cache->entry[i].data) { in squashfs_cache_delete()
218 kfree(cache->entry[i].data[j]); in squashfs_cache_delete()
219 kfree(cache->entry[i].data); in squashfs_cache_delete()
223 kfree(cache->entry); in squashfs_cache_delete()
244 cache->entry = kcalloc(entries, sizeof(*(cache->entry)), GFP_KERNEL); in squashfs_cache_init()
245 if (cache->entry == NULL) { in squashfs_cache_init()
261 struct squashfs_cache_entry *entry = &cache->entry[i]; in squashfs_cache_init() local
263 init_waitqueue_head(&cache->entry[i].wait_queue); in squashfs_cache_init()
264 entry->cache = cache; in squashfs_cache_init()
265 entry->block = SQUASHFS_INVALID_BLK; in squashfs_cache_init()
266 entry->data = kcalloc(cache->pages, sizeof(void *), GFP_KERNEL); in squashfs_cache_init()
267 if (entry->data == NULL) { in squashfs_cache_init()
273 entry->data[j] = kmalloc(PAGE_CACHE_SIZE, GFP_KERNEL); in squashfs_cache_init()
274 if (entry->data[j] == NULL) { in squashfs_cache_init()
294 int squashfs_copy_data(void *buffer, struct squashfs_cache_entry *entry, in squashfs_copy_data() argument
302 return min(length, entry->length - offset); in squashfs_copy_data()
304 while (offset < entry->length) { in squashfs_copy_data()
305 void *buff = entry->data[offset / PAGE_CACHE_SIZE] in squashfs_copy_data()
307 int bytes = min_t(int, entry->length - offset, in squashfs_copy_data()
337 struct squashfs_cache_entry *entry; in squashfs_read_metadata() local
342 entry = squashfs_cache_get(sb, msblk->block_cache, *block, 0); in squashfs_read_metadata()
343 if (entry->error) in squashfs_read_metadata()
344 return entry->error; in squashfs_read_metadata()
345 else if (*offset >= entry->length) in squashfs_read_metadata()
348 bytes = squashfs_copy_data(buffer, entry, *offset, length); in squashfs_read_metadata()
354 if (*offset == entry->length) { in squashfs_read_metadata()
355 *block = entry->next_index; in squashfs_read_metadata()
359 squashfs_cache_put(entry); in squashfs_read_metadata()