Lines Matching refs:cache
61 int (*handler)(struct cachefiles_cache *cache, char *args);
90 struct cachefiles_cache *cache; in cachefiles_daemon_open() local
103 cache = kzalloc(sizeof(struct cachefiles_cache), GFP_KERNEL); in cachefiles_daemon_open()
104 if (!cache) { in cachefiles_daemon_open()
109 mutex_init(&cache->daemon_mutex); in cachefiles_daemon_open()
110 init_waitqueue_head(&cache->daemon_pollwq); in cachefiles_daemon_open()
111 INIT_LIST_HEAD(&cache->volumes); in cachefiles_daemon_open()
112 INIT_LIST_HEAD(&cache->object_list); in cachefiles_daemon_open()
113 spin_lock_init(&cache->object_list_lock); in cachefiles_daemon_open()
114 refcount_set(&cache->unbind_pincount, 1); in cachefiles_daemon_open()
115 xa_init_flags(&cache->reqs, XA_FLAGS_ALLOC); in cachefiles_daemon_open()
116 xa_init_flags(&cache->ondemand_ids, XA_FLAGS_ALLOC1); in cachefiles_daemon_open()
123 cache->frun_percent = 7; in cachefiles_daemon_open()
124 cache->fcull_percent = 5; in cachefiles_daemon_open()
125 cache->fstop_percent = 1; in cachefiles_daemon_open()
126 cache->brun_percent = 7; in cachefiles_daemon_open()
127 cache->bcull_percent = 5; in cachefiles_daemon_open()
128 cache->bstop_percent = 1; in cachefiles_daemon_open()
130 file->private_data = cache; in cachefiles_daemon_open()
131 cache->cachefilesd = file; in cachefiles_daemon_open()
135 static void cachefiles_flush_reqs(struct cachefiles_cache *cache) in cachefiles_flush_reqs() argument
137 struct xarray *xa = &cache->reqs; in cachefiles_flush_reqs()
164 xa_destroy(&cache->reqs); in cachefiles_flush_reqs()
165 xa_destroy(&cache->ondemand_ids); in cachefiles_flush_reqs()
168 void cachefiles_put_unbind_pincount(struct cachefiles_cache *cache) in cachefiles_put_unbind_pincount() argument
170 if (refcount_dec_and_test(&cache->unbind_pincount)) { in cachefiles_put_unbind_pincount()
171 cachefiles_daemon_unbind(cache); in cachefiles_put_unbind_pincount()
173 kfree(cache); in cachefiles_put_unbind_pincount()
177 void cachefiles_get_unbind_pincount(struct cachefiles_cache *cache) in cachefiles_get_unbind_pincount() argument
179 refcount_inc(&cache->unbind_pincount); in cachefiles_get_unbind_pincount()
187 struct cachefiles_cache *cache = file->private_data; in cachefiles_daemon_release() local
191 ASSERT(cache); in cachefiles_daemon_release()
193 set_bit(CACHEFILES_DEAD, &cache->flags); in cachefiles_daemon_release()
195 if (cachefiles_in_ondemand_mode(cache)) in cachefiles_daemon_release()
196 cachefiles_flush_reqs(cache); in cachefiles_daemon_release()
199 cache->cachefilesd = NULL; in cachefiles_daemon_release()
202 cachefiles_put_unbind_pincount(cache); in cachefiles_daemon_release()
208 static ssize_t cachefiles_do_daemon_read(struct cachefiles_cache *cache, in cachefiles_do_daemon_read() argument
217 cachefiles_has_space(cache, 0, 0, cachefiles_has_space_check); in cachefiles_do_daemon_read()
220 f_released = atomic_xchg(&cache->f_released, 0); in cachefiles_do_daemon_read()
221 b_released = atomic_long_xchg(&cache->b_released, 0); in cachefiles_do_daemon_read()
222 clear_bit(CACHEFILES_STATE_CHANGED, &cache->flags); in cachefiles_do_daemon_read()
234 test_bit(CACHEFILES_CULLING, &cache->flags) ? '1' : '0', in cachefiles_do_daemon_read()
235 (unsigned long long) cache->frun, in cachefiles_do_daemon_read()
236 (unsigned long long) cache->fcull, in cachefiles_do_daemon_read()
237 (unsigned long long) cache->fstop, in cachefiles_do_daemon_read()
238 (unsigned long long) cache->brun, in cachefiles_do_daemon_read()
239 (unsigned long long) cache->bcull, in cachefiles_do_daemon_read()
240 (unsigned long long) cache->bstop, in cachefiles_do_daemon_read()
259 struct cachefiles_cache *cache = file->private_data; in cachefiles_daemon_read() local
263 if (!test_bit(CACHEFILES_READY, &cache->flags)) in cachefiles_daemon_read()
266 if (cachefiles_in_ondemand_mode(cache)) in cachefiles_daemon_read()
267 return cachefiles_ondemand_daemon_read(cache, _buffer, buflen); in cachefiles_daemon_read()
269 return cachefiles_do_daemon_read(cache, _buffer, buflen); in cachefiles_daemon_read()
281 struct cachefiles_cache *cache = file->private_data; in cachefiles_daemon_write() local
287 ASSERT(cache); in cachefiles_daemon_write()
289 if (test_bit(CACHEFILES_DEAD, &cache->flags)) in cachefiles_daemon_write()
337 mutex_lock(&cache->daemon_mutex); in cachefiles_daemon_write()
340 if (!test_bit(CACHEFILES_DEAD, &cache->flags)) in cachefiles_daemon_write()
341 ret = cmd->handler(cache, args); in cachefiles_daemon_write()
343 mutex_unlock(&cache->daemon_mutex); in cachefiles_daemon_write()
357 struct cachefiles_cache *cache = file->private_data; in cachefiles_daemon_poll() local
360 poll_wait(file, &cache->daemon_pollwq, poll); in cachefiles_daemon_poll()
363 if (cachefiles_in_ondemand_mode(cache)) { in cachefiles_daemon_poll()
364 if (!xa_empty(&cache->reqs)) in cachefiles_daemon_poll()
367 if (test_bit(CACHEFILES_STATE_CHANGED, &cache->flags)) in cachefiles_daemon_poll()
371 if (test_bit(CACHEFILES_CULLING, &cache->flags)) in cachefiles_daemon_poll()
381 static int cachefiles_daemon_range_error(struct cachefiles_cache *cache, in cachefiles_daemon_range_error() argument
393 static int cachefiles_daemon_frun(struct cachefiles_cache *cache, char *args) in cachefiles_daemon_frun() argument
406 if (frun <= cache->fcull_percent || frun >= 100) in cachefiles_daemon_frun()
407 return cachefiles_daemon_range_error(cache, args); in cachefiles_daemon_frun()
409 cache->frun_percent = frun; in cachefiles_daemon_frun()
417 static int cachefiles_daemon_fcull(struct cachefiles_cache *cache, char *args) in cachefiles_daemon_fcull() argument
430 if (fcull <= cache->fstop_percent || fcull >= cache->frun_percent) in cachefiles_daemon_fcull()
431 return cachefiles_daemon_range_error(cache, args); in cachefiles_daemon_fcull()
433 cache->fcull_percent = fcull; in cachefiles_daemon_fcull()
441 static int cachefiles_daemon_fstop(struct cachefiles_cache *cache, char *args) in cachefiles_daemon_fstop() argument
454 if (fstop >= cache->fcull_percent) in cachefiles_daemon_fstop()
455 return cachefiles_daemon_range_error(cache, args); in cachefiles_daemon_fstop()
457 cache->fstop_percent = fstop; in cachefiles_daemon_fstop()
465 static int cachefiles_daemon_brun(struct cachefiles_cache *cache, char *args) in cachefiles_daemon_brun() argument
478 if (brun <= cache->bcull_percent || brun >= 100) in cachefiles_daemon_brun()
479 return cachefiles_daemon_range_error(cache, args); in cachefiles_daemon_brun()
481 cache->brun_percent = brun; in cachefiles_daemon_brun()
489 static int cachefiles_daemon_bcull(struct cachefiles_cache *cache, char *args) in cachefiles_daemon_bcull() argument
502 if (bcull <= cache->bstop_percent || bcull >= cache->brun_percent) in cachefiles_daemon_bcull()
503 return cachefiles_daemon_range_error(cache, args); in cachefiles_daemon_bcull()
505 cache->bcull_percent = bcull; in cachefiles_daemon_bcull()
513 static int cachefiles_daemon_bstop(struct cachefiles_cache *cache, char *args) in cachefiles_daemon_bstop() argument
526 if (bstop >= cache->bcull_percent) in cachefiles_daemon_bstop()
527 return cachefiles_daemon_range_error(cache, args); in cachefiles_daemon_bstop()
529 cache->bstop_percent = bstop; in cachefiles_daemon_bstop()
537 static int cachefiles_daemon_dir(struct cachefiles_cache *cache, char *args) in cachefiles_daemon_dir() argument
548 if (cache->rootdirname) { in cachefiles_daemon_dir()
557 cache->rootdirname = dir; in cachefiles_daemon_dir()
565 static int cachefiles_daemon_secctx(struct cachefiles_cache *cache, char *args) in cachefiles_daemon_secctx() argument
576 if (cache->secctx) { in cachefiles_daemon_secctx()
585 cache->secctx = secctx; in cachefiles_daemon_secctx()
593 static int cachefiles_daemon_tag(struct cachefiles_cache *cache, char *args) in cachefiles_daemon_tag() argument
604 if (cache->tag) in cachefiles_daemon_tag()
611 cache->tag = tag; in cachefiles_daemon_tag()
619 static int cachefiles_daemon_cull(struct cachefiles_cache *cache, char *args) in cachefiles_daemon_cull() argument
630 if (!test_bit(CACHEFILES_READY, &cache->flags)) { in cachefiles_daemon_cull()
635 if (test_bit(CACHEFILES_DEAD, &cache->flags)) { in cachefiles_daemon_cull()
645 cachefiles_begin_secure(cache, &saved_cred); in cachefiles_daemon_cull()
646 ret = cachefiles_cull(cache, path.dentry, args); in cachefiles_daemon_cull()
647 cachefiles_end_secure(cache, saved_cred); in cachefiles_daemon_cull()
667 static int cachefiles_daemon_debug(struct cachefiles_cache *cache, char *args) in cachefiles_daemon_debug() argument
690 static int cachefiles_daemon_inuse(struct cachefiles_cache *cache, char *args) in cachefiles_daemon_inuse() argument
701 if (!test_bit(CACHEFILES_READY, &cache->flags)) { in cachefiles_daemon_inuse()
706 if (test_bit(CACHEFILES_DEAD, &cache->flags)) { in cachefiles_daemon_inuse()
716 cachefiles_begin_secure(cache, &saved_cred); in cachefiles_daemon_inuse()
717 ret = cachefiles_check_in_use(cache, path.dentry, args); in cachefiles_daemon_inuse()
718 cachefiles_end_secure(cache, saved_cred); in cachefiles_daemon_inuse()
737 static int cachefiles_daemon_bind(struct cachefiles_cache *cache, char *args) in cachefiles_daemon_bind() argument
740 cache->frun_percent, in cachefiles_daemon_bind()
741 cache->fcull_percent, in cachefiles_daemon_bind()
742 cache->fstop_percent, in cachefiles_daemon_bind()
743 cache->brun_percent, in cachefiles_daemon_bind()
744 cache->bcull_percent, in cachefiles_daemon_bind()
745 cache->bstop_percent, in cachefiles_daemon_bind()
748 if (cache->fstop_percent >= cache->fcull_percent || in cachefiles_daemon_bind()
749 cache->fcull_percent >= cache->frun_percent || in cachefiles_daemon_bind()
750 cache->frun_percent >= 100) in cachefiles_daemon_bind()
753 if (cache->bstop_percent >= cache->bcull_percent || in cachefiles_daemon_bind()
754 cache->bcull_percent >= cache->brun_percent || in cachefiles_daemon_bind()
755 cache->brun_percent >= 100) in cachefiles_daemon_bind()
758 if (!cache->rootdirname) { in cachefiles_daemon_bind()
764 if (test_bit(CACHEFILES_READY, &cache->flags)) { in cachefiles_daemon_bind()
771 set_bit(CACHEFILES_ONDEMAND_MODE, &cache->flags); in cachefiles_daemon_bind()
782 if (!cache->tag) { in cachefiles_daemon_bind()
787 cache->tag = kstrdup("CacheFiles", GFP_KERNEL); in cachefiles_daemon_bind()
788 if (!cache->tag) in cachefiles_daemon_bind()
792 return cachefiles_add_cache(cache); in cachefiles_daemon_bind()
798 static void cachefiles_daemon_unbind(struct cachefiles_cache *cache) in cachefiles_daemon_unbind() argument
802 if (test_bit(CACHEFILES_READY, &cache->flags)) in cachefiles_daemon_unbind()
803 cachefiles_withdraw_cache(cache); in cachefiles_daemon_unbind()
805 cachefiles_put_directory(cache->graveyard); in cachefiles_daemon_unbind()
806 cachefiles_put_directory(cache->store); in cachefiles_daemon_unbind()
807 mntput(cache->mnt); in cachefiles_daemon_unbind()
808 put_cred(cache->cache_cred); in cachefiles_daemon_unbind()
810 kfree(cache->rootdirname); in cachefiles_daemon_unbind()
811 kfree(cache->secctx); in cachefiles_daemon_unbind()
812 kfree(cache->tag); in cachefiles_daemon_unbind()