Lines Matching refs:cache
2 /* Bind and unbind a cache from the filesystem backing it
25 * bind a directory as a cache
27 int cachefiles_daemon_bind(struct cachefiles_cache *cache, char *args)
30 cache->frun_percent,
31 cache->fcull_percent,
32 cache->fstop_percent,
33 cache->brun_percent,
34 cache->bcull_percent,
35 cache->bstop_percent,
39 ASSERT(cache->fstop_percent >= 0 &&
40 cache->fstop_percent < cache->fcull_percent &&
41 cache->fcull_percent < cache->frun_percent &&
42 cache->frun_percent < 100);
44 ASSERT(cache->bstop_percent >= 0 &&
45 cache->bstop_percent < cache->bcull_percent &&
46 cache->bcull_percent < cache->brun_percent &&
47 cache->brun_percent < 100);
54 if (!cache->rootdirname) {
55 pr_err("No cache directory specified\n");
60 if (test_bit(CACHEFILES_READY, &cache->flags)) {
66 if (!cache->tag) {
69 cache->tag = kstrdup("CacheFiles", GFP_KERNEL);
70 if (!cache->tag)
74 /* add the cache */
75 return cachefiles_daemon_add_cache(cache);
79 * add a cache
81 static int cachefiles_daemon_add_cache(struct cachefiles_cache *cache)
93 ret = cachefiles_get_security_ID(cache);
97 cachefiles_begin_secure(cache, &saved_cred);
113 /* look up the directory at the root of the cache */
114 ret = kern_path(cache->rootdirname, LOOKUP_DIRECTORY, &path);
118 cache->mnt = path.mnt;
135 /* determine the security of the on-disk cache as this governs
137 ret = cachefiles_determine_cache_security(cache, root, &saved_cred);
141 /* get the cache size and blocksize */
154 cache->bsize = stats.f_bsize;
155 cache->bshift = 0;
157 cache->bshift = PAGE_SHIFT - ilog2(stats.f_bsize);
160 cache->bsize, cache->bshift);
168 cache->fstop = stats.f_files * cache->fstop_percent;
169 cache->fcull = stats.f_files * cache->fcull_percent;
170 cache->frun = stats.f_files * cache->frun_percent;
173 (unsigned long long) cache->frun,
174 (unsigned long long) cache->fcull,
175 (unsigned long long) cache->fstop);
177 stats.f_blocks >>= cache->bshift;
179 cache->bstop = stats.f_blocks * cache->bstop_percent;
180 cache->bcull = stats.f_blocks * cache->bcull_percent;
181 cache->brun = stats.f_blocks * cache->brun_percent;
184 (unsigned long long) cache->brun,
185 (unsigned long long) cache->bcull,
186 (unsigned long long) cache->bstop);
188 /* get the cache directory and check its type */
189 cachedir = cachefiles_get_directory(cache, root, "cache");
203 graveyard = cachefiles_get_directory(cache, root, "graveyard");
209 cache->graveyard = graveyard;
211 /* publish the cache */
212 fscache_init_cache(&cache->cache,
218 &cache->cache);
220 ret = fscache_add_cache(&cache->cache, &fsdef->fscache, cache->tag);
225 set_bit(CACHEFILES_READY, &cache->flags);
228 pr_info("File cache on %s registered\n", cache->cache.identifier);
230 /* check how much space the cache has */
231 cachefiles_has_space(cache, 0, 0);
232 cachefiles_end_secure(cache, saved_cred);
236 dput(cache->graveyard);
237 cache->graveyard = NULL;
239 mntput(cache->mnt);
240 cache->mnt = NULL;
247 cachefiles_end_secure(cache, saved_cred);
253 * unbind a cache on fd release
255 void cachefiles_daemon_unbind(struct cachefiles_cache *cache)
259 if (test_bit(CACHEFILES_READY, &cache->flags)) {
260 pr_info("File cache on %s unregistering\n",
261 cache->cache.identifier);
263 fscache_withdraw_cache(&cache->cache);
266 dput(cache->graveyard);
267 mntput(cache->mnt);
269 kfree(cache->rootdirname);
270 kfree(cache->secctx);
271 kfree(cache->tag);