Lines Matching refs:cache
2 /* FS-Cache cache handling
21 * look up a cache tag
67 * release a reference to a cache tag
86 * select a cache in which to store an object
87 * - the cache addremove semaphore must be at least read-locked by the caller
95 struct fscache_cache *cache;
100 _leave(" = NULL [no cache]");
104 /* we check the parent to determine the cache to use */
108 * cache */
113 cache = object->cache;
115 test_bit(FSCACHE_IOERROR, &cache->flags))
116 cache = NULL;
119 _leave(" = %p [parent]", cache);
120 return cache;
147 if (!tag->cache) {
152 if (test_bit(FSCACHE_IOERROR, &tag->cache->flags))
155 _leave(" = %p [specific]", tag->cache);
156 return tag->cache;
159 /* netfs has no preference - just select first cache */
160 cache = list_entry(fscache_cache_list.next,
162 _leave(" = %p [first]", cache);
163 return cache;
167 * fscache_init_cache - Initialise a cache record
168 * @cache: The cache record to be initialised
169 * @ops: The cache operations to be installed in that record
173 * Initialise a record of a cache and fill in the name.
178 void fscache_init_cache(struct fscache_cache *cache,
185 memset(cache, 0, sizeof(*cache));
187 cache->ops = ops;
190 vsnprintf(cache->identifier, sizeof(cache->identifier), idfmt, va);
193 INIT_WORK(&cache->op_gc, fscache_operation_gc);
194 INIT_LIST_HEAD(&cache->link);
195 INIT_LIST_HEAD(&cache->object_list);
196 INIT_LIST_HEAD(&cache->op_gc_list);
197 spin_lock_init(&cache->object_list_lock);
198 spin_lock_init(&cache->op_gc_list_lock);
203 * fscache_add_cache - Declare a cache as being open for business
204 * @cache: The record describing the cache
205 * @ifsdef: The record of the cache object describing the top-level index
206 * @tagname: The tag describing this cache
208 * Add a cache to the system, making it available for netfs's to use.
213 int fscache_add_cache(struct fscache_cache *cache,
220 BUG_ON(!cache->ops);
223 cache->flags = 0;
230 tagname = cache->identifier;
234 _enter("{%s.%s},,%s", cache->ops->name, cache->identifier, tagname);
236 /* we use the cache tag to uniquely identify caches */
244 cache->kobj = kobject_create_and_add(tagname, fscache_root);
245 if (!cache->kobj)
248 ifsdef->cache = cache;
249 cache->fsdef = ifsdef;
253 tag->cache = cache;
254 cache->tag = tag;
256 /* add the cache to the list */
257 list_add(&cache->link, &fscache_cache_list);
259 /* add the cache's netfs definition index object to the cache's
261 spin_lock(&cache->object_list_lock);
262 list_add_tail(&ifsdef->cache_link, &cache->object_list);
263 spin_unlock(&cache->object_list_lock);
266 /* add the cache's netfs definition index object to the top level index
280 cache->tag->name, cache->ops->name);
281 kobject_uevent(cache->kobj, KOBJ_ADD);
283 _leave(" = 0 [%s]", cache->identifier);
304 * fscache_io_error - Note a cache I/O error
305 * @cache: The record describing the cache
307 * Note that an I/O error occurred in a cache and that it should no longer be
313 void fscache_io_error(struct fscache_cache *cache)
315 if (!test_and_set_bit(FSCACHE_IOERROR, &cache->flags))
317 cache->ops->name);
322 * request withdrawal of all the objects in a cache
325 static void fscache_withdraw_all_objects(struct fscache_cache *cache,
330 while (!list_empty(&cache->object_list)) {
331 spin_lock(&cache->object_list_lock);
333 if (!list_empty(&cache->object_list)) {
334 object = list_entry(cache->object_list.next,
346 spin_unlock(&cache->object_list_lock);
352 * fscache_withdraw_cache - Withdraw a cache from the active service
353 * @cache: The record describing the cache
355 * Withdraw a cache from service, unbinding all its cache objects from the
361 void fscache_withdraw_cache(struct fscache_cache *cache)
367 pr_notice("Withdrawing cache \"%s\"\n",
368 cache->tag->name);
370 /* make the cache unavailable for cookie acquisition */
371 if (test_and_set_bit(FSCACHE_CACHE_WITHDRAWN, &cache->flags))
375 list_del_init(&cache->link);
376 cache->tag->cache = NULL;
382 cache->ops->sync_cache(cache);
385 /* dissociate all the netfs pages backed by this cache from the block
386 * mappings in the cache */
388 cache->ops->dissociate_pages(cache);
392 * cache - which we do by passing them off to thread pool to be
396 fscache_withdraw_all_objects(cache, &dying_objects);
402 atomic_read(&cache->object_count) == 0);
405 list_empty(&cache->object_list));
409 kobject_put(cache->kobj);
411 clear_bit(FSCACHE_TAG_RESERVED, &cache->tag->flags);
412 fscache_release_cache_tag(cache->tag);
413 cache->tag = NULL;