Lines Matching refs:cache
16 int cachefiles_add_cache(struct cachefiles_cache *cache) in cachefiles_add_cache() argument
27 cache_cookie = fscache_acquire_cache(cache->tag); in cachefiles_add_cache()
32 ret = cachefiles_get_security_ID(cache); in cachefiles_add_cache()
36 cachefiles_begin_secure(cache, &saved_cred); in cachefiles_add_cache()
39 ret = kern_path(cache->rootdirname, LOOKUP_DIRECTORY, &path); in cachefiles_add_cache()
43 cache->mnt = path.mnt; in cachefiles_add_cache()
77 ret = cachefiles_determine_cache_security(cache, root, &saved_cred); in cachefiles_add_cache()
94 cache->bsize = stats.f_bsize; in cachefiles_add_cache()
95 cache->bshift = ilog2(stats.f_bsize); in cachefiles_add_cache()
98 cache->bsize, cache->bshift); in cachefiles_add_cache()
106 cache->fstop = stats.f_files * cache->fstop_percent; in cachefiles_add_cache()
107 cache->fcull = stats.f_files * cache->fcull_percent; in cachefiles_add_cache()
108 cache->frun = stats.f_files * cache->frun_percent; in cachefiles_add_cache()
111 (unsigned long long) cache->frun, in cachefiles_add_cache()
112 (unsigned long long) cache->fcull, in cachefiles_add_cache()
113 (unsigned long long) cache->fstop); in cachefiles_add_cache()
116 cache->bstop = stats.f_blocks * cache->bstop_percent; in cachefiles_add_cache()
117 cache->bcull = stats.f_blocks * cache->bcull_percent; in cachefiles_add_cache()
118 cache->brun = stats.f_blocks * cache->brun_percent; in cachefiles_add_cache()
121 (unsigned long long) cache->brun, in cachefiles_add_cache()
122 (unsigned long long) cache->bcull, in cachefiles_add_cache()
123 (unsigned long long) cache->bstop); in cachefiles_add_cache()
126 cachedir = cachefiles_get_directory(cache, root, "cache", NULL); in cachefiles_add_cache()
132 cache->store = cachedir; in cachefiles_add_cache()
135 graveyard = cachefiles_get_directory(cache, root, "graveyard", NULL); in cachefiles_add_cache()
141 cache->graveyard = graveyard; in cachefiles_add_cache()
142 cache->cache = cache_cookie; in cachefiles_add_cache()
144 ret = fscache_add_cache(cache_cookie, &cachefiles_cache_ops, cache); in cachefiles_add_cache()
149 set_bit(CACHEFILES_READY, &cache->flags); in cachefiles_add_cache()
155 cachefiles_has_space(cache, 0, 0, cachefiles_has_space_check); in cachefiles_add_cache()
156 cachefiles_end_secure(cache, saved_cred); in cachefiles_add_cache()
157 _leave(" = 0 [%px]", cache->cache); in cachefiles_add_cache()
161 cachefiles_put_directory(cache->graveyard); in cachefiles_add_cache()
162 cache->graveyard = NULL; in cachefiles_add_cache()
164 cachefiles_put_directory(cache->store); in cachefiles_add_cache()
165 cache->store = NULL; in cachefiles_add_cache()
166 mntput(cache->mnt); in cachefiles_add_cache()
167 cache->mnt = NULL; in cachefiles_add_cache()
170 cachefiles_end_secure(cache, saved_cred); in cachefiles_add_cache()
173 cache->cache = NULL; in cachefiles_add_cache()
182 int cachefiles_has_space(struct cachefiles_cache *cache, in cachefiles_has_space() argument
191 .mnt = cache->mnt, in cachefiles_has_space()
192 .dentry = cache->mnt->mnt_root, in cachefiles_has_space()
212 cachefiles_io_error(cache, "statfs failed"); in cachefiles_has_space()
218 b_writing = atomic_long_read(&cache->b_writing); in cachefiles_has_space()
240 if (stats.f_ffree < cache->fstop || in cachefiles_has_space()
241 b_avail < cache->bstop) in cachefiles_has_space()
245 if (stats.f_ffree < cache->fcull || in cachefiles_has_space()
246 b_avail < cache->bcull) in cachefiles_has_space()
249 if (test_bit(CACHEFILES_CULLING, &cache->flags) && in cachefiles_has_space()
250 stats.f_ffree >= cache->frun && in cachefiles_has_space()
251 b_avail >= cache->brun && in cachefiles_has_space()
252 test_and_clear_bit(CACHEFILES_CULLING, &cache->flags) in cachefiles_has_space()
255 cachefiles_state_changed(cache); in cachefiles_has_space()
273 if (!test_and_set_bit(CACHEFILES_CULLING, &cache->flags)) { in cachefiles_has_space()
275 cachefiles_state_changed(cache); in cachefiles_has_space()
285 static void cachefiles_withdraw_objects(struct cachefiles_cache *cache) in cachefiles_withdraw_objects() argument
292 spin_lock(&cache->object_list_lock); in cachefiles_withdraw_objects()
294 while (!list_empty(&cache->object_list)) { in cachefiles_withdraw_objects()
295 object = list_first_entry(&cache->object_list, in cachefiles_withdraw_objects()
302 spin_unlock(&cache->object_list_lock); in cachefiles_withdraw_objects()
304 spin_lock(&cache->object_list_lock); in cachefiles_withdraw_objects()
308 spin_unlock(&cache->object_list_lock); in cachefiles_withdraw_objects()
315 static void cachefiles_withdraw_volumes(struct cachefiles_cache *cache) in cachefiles_withdraw_volumes() argument
322 spin_lock(&cache->object_list_lock); in cachefiles_withdraw_volumes()
323 if (!list_empty(&cache->volumes)) { in cachefiles_withdraw_volumes()
324 volume = list_first_entry(&cache->volumes, in cachefiles_withdraw_volumes()
328 spin_unlock(&cache->object_list_lock); in cachefiles_withdraw_volumes()
341 static void cachefiles_sync_cache(struct cachefiles_cache *cache) in cachefiles_sync_cache() argument
346 _enter("%s", cache->cache->name); in cachefiles_sync_cache()
350 cachefiles_begin_secure(cache, &saved_cred); in cachefiles_sync_cache()
351 down_read(&cache->mnt->mnt_sb->s_umount); in cachefiles_sync_cache()
352 ret = sync_filesystem(cache->mnt->mnt_sb); in cachefiles_sync_cache()
353 up_read(&cache->mnt->mnt_sb->s_umount); in cachefiles_sync_cache()
354 cachefiles_end_secure(cache, saved_cred); in cachefiles_sync_cache()
357 cachefiles_io_error(cache, in cachefiles_sync_cache()
365 void cachefiles_withdraw_cache(struct cachefiles_cache *cache) in cachefiles_withdraw_cache() argument
367 struct fscache_cache *fscache = cache->cache; in cachefiles_withdraw_cache()
376 cachefiles_withdraw_objects(cache); in cachefiles_withdraw_cache()
379 cachefiles_withdraw_volumes(cache); in cachefiles_withdraw_cache()
380 cachefiles_sync_cache(cache); in cachefiles_withdraw_cache()
381 cache->cache = NULL; in cachefiles_withdraw_cache()