Lines Matching refs:cache

2 /* Manage high-level VFS aspects of a cache.
14 * Bring a cache online.
16 int cachefiles_add_cache(struct cachefiles_cache *cache)
27 cache_cookie = fscache_acquire_cache(cache->tag);
32 ret = cachefiles_get_security_ID(cache);
36 cachefiles_begin_secure(cache, &saved_cred);
38 /* look up the directory at the root of the cache */
39 ret = kern_path(cache->rootdirname, LOOKUP_DIRECTORY, &path);
43 cache->mnt = path.mnt;
48 pr_warn("File cache on idmapped mounts not supported");
57 * - We want to be able to sync the filesystem when stopping the cache
75 /* determine the security of the on-disk cache as this governs
77 ret = cachefiles_determine_cache_security(cache, root, &saved_cred);
81 /* get the cache size and blocksize */
94 cache->bsize = stats.f_bsize;
95 cache->bshift = ilog2(stats.f_bsize);
98 cache->bsize, cache->bshift);
106 cache->fstop = stats.f_files * cache->fstop_percent;
107 cache->fcull = stats.f_files * cache->fcull_percent;
108 cache->frun = stats.f_files * cache->frun_percent;
111 (unsigned long long) cache->frun,
112 (unsigned long long) cache->fcull,
113 (unsigned long long) cache->fstop);
116 cache->bstop = stats.f_blocks * cache->bstop_percent;
117 cache->bcull = stats.f_blocks * cache->bcull_percent;
118 cache->brun = stats.f_blocks * cache->brun_percent;
121 (unsigned long long) cache->brun,
122 (unsigned long long) cache->bcull,
123 (unsigned long long) cache->bstop);
125 /* get the cache directory and check its type */
126 cachedir = cachefiles_get_directory(cache, root, "cache", NULL);
132 cache->store = cachedir;
135 graveyard = cachefiles_get_directory(cache, root, "graveyard", NULL);
141 cache->graveyard = graveyard;
142 cache->cache = cache_cookie;
144 ret = fscache_add_cache(cache_cookie, &cachefiles_cache_ops, cache);
149 set_bit(CACHEFILES_READY, &cache->flags);
152 pr_info("File cache on %s registered\n", cache_cookie->name);
154 /* check how much space the cache has */
155 cachefiles_has_space(cache, 0, 0, cachefiles_has_space_check);
156 cachefiles_end_secure(cache, saved_cred);
157 _leave(" = 0 [%px]", cache->cache);
161 cachefiles_put_directory(cache->graveyard);
162 cache->graveyard = NULL;
164 cachefiles_put_directory(cache->store);
165 cache->store = NULL;
166 mntput(cache->mnt);
167 cache->mnt = NULL;
170 cachefiles_end_secure(cache, saved_cred);
171 put_cred(cache->cache_cred);
172 cache->cache_cred = NULL;
175 cache->cache = NULL;
182 * cache
184 int cachefiles_has_space(struct cachefiles_cache *cache,
193 .mnt = cache->mnt,
194 .dentry = cache->mnt->mnt_root,
198 // (unsigned long long) cache->frun,
199 // (unsigned long long) cache->fcull,
200 // (unsigned long long) cache->fstop,
201 // (unsigned long long) cache->brun,
202 // (unsigned long long) cache->bcull,
203 // (unsigned long long) cache->bstop,
214 cachefiles_io_error(cache, "statfs failed");
220 b_writing = atomic_long_read(&cache->b_writing);
242 if (stats.f_ffree < cache->fstop ||
243 b_avail < cache->bstop)
247 if (stats.f_ffree < cache->fcull ||
248 b_avail < cache->bcull)
251 if (test_bit(CACHEFILES_CULLING, &cache->flags) &&
252 stats.f_ffree >= cache->frun &&
253 b_avail >= cache->brun &&
254 test_and_clear_bit(CACHEFILES_CULLING, &cache->flags)
257 cachefiles_state_changed(cache);
275 if (!test_and_set_bit(CACHEFILES_CULLING, &cache->flags)) {
277 cachefiles_state_changed(cache);
287 static void cachefiles_withdraw_objects(struct cachefiles_cache *cache)
294 spin_lock(&cache->object_list_lock);
296 while (!list_empty(&cache->object_list)) {
297 object = list_first_entry(&cache->object_list,
304 spin_unlock(&cache->object_list_lock);
306 spin_lock(&cache->object_list_lock);
310 spin_unlock(&cache->object_list_lock);
317 static void cachefiles_withdraw_volumes(struct cachefiles_cache *cache)
324 spin_lock(&cache->object_list_lock);
325 if (!list_empty(&cache->volumes)) {
326 volume = list_first_entry(&cache->volumes,
330 spin_unlock(&cache->object_list_lock);
341 * Sync a cache to backing disk.
343 static void cachefiles_sync_cache(struct cachefiles_cache *cache)
348 _enter("%s", cache->cache->name);
352 cachefiles_begin_secure(cache, &saved_cred);
353 down_read(&cache->mnt->mnt_sb->s_umount);
354 ret = sync_filesystem(cache->mnt->mnt_sb);
355 up_read(&cache->mnt->mnt_sb->s_umount);
356 cachefiles_end_secure(cache, saved_cred);
359 cachefiles_io_error(cache,
365 * Withdraw cache objects.
367 void cachefiles_withdraw_cache(struct cachefiles_cache *cache)
369 struct fscache_cache *fscache = cache->cache;
371 pr_info("File cache on %s unregistering\n", fscache->name);
376 * cache - which we do by passing them off to thread pool to be
378 cachefiles_withdraw_objects(cache);
381 cachefiles_withdraw_volumes(cache);
382 cachefiles_sync_cache(cache);
383 cache->cache = NULL;