Lines Matching refs:cache

67 	struct squashfs_cache *cache, u64 block, int length)  in squashfs_cache_get()  argument
72 spin_lock(&cache->lock); in squashfs_cache_get()
75 for (i = 0; i < cache->entries; i++) in squashfs_cache_get()
76 if (cache->entry[i].block == block) in squashfs_cache_get()
79 if (i == cache->entries) { in squashfs_cache_get()
84 if (cache->unused == 0) { in squashfs_cache_get()
85 cache->num_waiters++; in squashfs_cache_get()
86 spin_unlock(&cache->lock); in squashfs_cache_get()
87 wait_event(cache->wait_queue, cache->unused); in squashfs_cache_get()
88 spin_lock(&cache->lock); in squashfs_cache_get()
89 cache->num_waiters--; in squashfs_cache_get()
98 i = cache->next_blk; in squashfs_cache_get()
99 for (n = 0; n < cache->entries; n++) { in squashfs_cache_get()
100 if (cache->entry[i].refcount == 0) in squashfs_cache_get()
102 i = (i + 1) % cache->entries; in squashfs_cache_get()
105 cache->next_blk = (i + 1) % cache->entries; in squashfs_cache_get()
106 entry = &cache->entry[i]; in squashfs_cache_get()
112 cache->unused--; in squashfs_cache_get()
118 spin_unlock(&cache->lock); in squashfs_cache_get()
122 cache->block_size); in squashfs_cache_get()
124 spin_lock(&cache->lock); in squashfs_cache_get()
137 spin_unlock(&cache->lock); in squashfs_cache_get()
140 spin_unlock(&cache->lock); in squashfs_cache_get()
151 entry = &cache->entry[i]; in squashfs_cache_get()
153 cache->unused--; in squashfs_cache_get()
162 spin_unlock(&cache->lock); in squashfs_cache_get()
165 spin_unlock(&cache->lock); in squashfs_cache_get()
172 cache->name, i, entry->block, entry->refcount, entry->error); in squashfs_cache_get()
175 ERROR("Unable to read %s cache entry [%llx]\n", cache->name, in squashfs_cache_get()
186 struct squashfs_cache *cache = entry->cache; in squashfs_cache_put() local
188 spin_lock(&cache->lock); in squashfs_cache_put()
191 cache->unused++; in squashfs_cache_put()
196 if (cache->num_waiters) { in squashfs_cache_put()
197 spin_unlock(&cache->lock); in squashfs_cache_put()
198 wake_up(&cache->wait_queue); in squashfs_cache_put()
202 spin_unlock(&cache->lock); in squashfs_cache_put()
208 void squashfs_cache_delete(struct squashfs_cache *cache) in squashfs_cache_delete() argument
212 if (cache == NULL) in squashfs_cache_delete()
215 for (i = 0; i < cache->entries; i++) { in squashfs_cache_delete()
216 if (cache->entry[i].data) { in squashfs_cache_delete()
217 for (j = 0; j < cache->pages; j++) 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()
224 kfree(cache); in squashfs_cache_delete()
237 struct squashfs_cache *cache = kzalloc(sizeof(*cache), GFP_KERNEL); in squashfs_cache_init() local
239 if (cache == NULL) { in squashfs_cache_init()
244 cache->entry = kcalloc(entries, sizeof(*(cache->entry)), GFP_KERNEL); in squashfs_cache_init()
245 if (cache->entry == NULL) { in squashfs_cache_init()
250 cache->next_blk = 0; in squashfs_cache_init()
251 cache->unused = entries; in squashfs_cache_init()
252 cache->entries = entries; in squashfs_cache_init()
253 cache->block_size = block_size; in squashfs_cache_init()
254 cache->pages = block_size >> PAGE_CACHE_SHIFT; in squashfs_cache_init()
255 cache->name = name; in squashfs_cache_init()
256 cache->num_waiters = 0; in squashfs_cache_init()
257 spin_lock_init(&cache->lock); in squashfs_cache_init()
258 init_waitqueue_head(&cache->wait_queue); in squashfs_cache_init()
261 struct squashfs_cache_entry *entry = &cache->entry[i]; in squashfs_cache_init()
263 init_waitqueue_head(&cache->entry[i].wait_queue); in squashfs_cache_init()
264 entry->cache = cache; in squashfs_cache_init()
266 entry->data = kcalloc(cache->pages, sizeof(void *), GFP_KERNEL); in squashfs_cache_init()
272 for (j = 0; j < cache->pages; j++) { in squashfs_cache_init()
281 return cache; in squashfs_cache_init()
284 squashfs_cache_delete(cache); in squashfs_cache_init()