summaryrefslogtreecommitdiff
path: root/fs/cachefiles/daemon.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/cachefiles/daemon.c')
-rw-r--r--fs/cachefiles/daemon.c96
1 files changed, 7 insertions, 89 deletions
diff --git a/fs/cachefiles/daemon.c b/fs/cachefiles/daemon.c
index 4117b145ac94..1a66e0af2837 100644
--- a/fs/cachefiles/daemon.c
+++ b/fs/cachefiles/daemon.c
@@ -76,10 +76,6 @@ static const struct cachefiles_daemon_cmd cachefiles_daemon_cmds[] = {
{ "inuse", cachefiles_daemon_inuse },
{ "secctx", cachefiles_daemon_secctx },
{ "tag", cachefiles_daemon_tag },
-#ifdef CONFIG_CACHEFILES_ONDEMAND
- { "copen", cachefiles_ondemand_copen },
- { "restore", cachefiles_ondemand_restore },
-#endif
{ "", NULL }
};
@@ -113,9 +109,6 @@ static int cachefiles_daemon_open(struct inode *inode, struct file *file)
INIT_LIST_HEAD(&cache->volumes);
INIT_LIST_HEAD(&cache->object_list);
spin_lock_init(&cache->object_list_lock);
- refcount_set(&cache->unbind_pincount, 1);
- xa_init_flags(&cache->reqs, XA_FLAGS_ALLOC);
- xa_init_flags(&cache->ondemand_ids, XA_FLAGS_ALLOC1);
/* set default caching limits
* - limit at 1% free space and/or free files
@@ -134,54 +127,6 @@ static int cachefiles_daemon_open(struct inode *inode, struct file *file)
return 0;
}
-void cachefiles_flush_reqs(struct cachefiles_cache *cache)
-{
- struct xarray *xa = &cache->reqs;
- struct cachefiles_req *req;
- unsigned long index;
-
- /*
- * Make sure the following two operations won't be reordered.
- * 1) set CACHEFILES_DEAD bit
- * 2) flush requests in the xarray
- * Otherwise the request may be enqueued after xarray has been
- * flushed, leaving the orphan request never being completed.
- *
- * CPU 1 CPU 2
- * ===== =====
- * flush requests in the xarray
- * test CACHEFILES_DEAD bit
- * enqueue the request
- * set CACHEFILES_DEAD bit
- */
- smp_mb();
-
- xa_lock(xa);
- xa_for_each(xa, index, req) {
- req->error = -EIO;
- complete(&req->done);
- __xa_erase(xa, index);
- }
- xa_unlock(xa);
-
- xa_destroy(&cache->reqs);
- xa_destroy(&cache->ondemand_ids);
-}
-
-void cachefiles_put_unbind_pincount(struct cachefiles_cache *cache)
-{
- if (refcount_dec_and_test(&cache->unbind_pincount)) {
- cachefiles_daemon_unbind(cache);
- cachefiles_open = 0;
- kfree(cache);
- }
-}
-
-void cachefiles_get_unbind_pincount(struct cachefiles_cache *cache)
-{
- refcount_inc(&cache->unbind_pincount);
-}
-
/*
* Release a cache.
*/
@@ -194,16 +139,14 @@ static int cachefiles_daemon_release(struct inode *inode, struct file *file)
ASSERT(cache);
set_bit(CACHEFILES_DEAD, &cache->flags);
-
- if (cachefiles_in_ondemand_mode(cache))
- cachefiles_flush_reqs(cache);
+ cachefiles_daemon_unbind(cache);
/* clean up the control file interface */
cache->cachefilesd = NULL;
file->private_data = NULL;
+ cachefiles_open = 0;
- cachefiles_put_unbind_pincount(cache);
-
+ kfree(cache);
_leave("");
return 0;
}
@@ -266,10 +209,7 @@ static ssize_t cachefiles_daemon_read(struct file *file, char __user *_buffer,
if (!test_bit(CACHEFILES_READY, &cache->flags))
return 0;
- if (cachefiles_in_ondemand_mode(cache))
- return cachefiles_ondemand_daemon_read(cache, _buffer, buflen);
- else
- return cachefiles_do_daemon_read(cache, _buffer, buflen);
+ return cachefiles_do_daemon_read(cache, _buffer, buflen);
}
/*
@@ -358,28 +298,13 @@ static __poll_t cachefiles_daemon_poll(struct file *file,
struct poll_table_struct *poll)
{
struct cachefiles_cache *cache = file->private_data;
- XA_STATE(xas, &cache->reqs, 0);
- struct cachefiles_req *req;
__poll_t mask;
poll_wait(file, &cache->daemon_pollwq, poll);
mask = 0;
- if (cachefiles_in_ondemand_mode(cache)) {
- if (!xa_empty(&cache->reqs)) {
- xas_lock(&xas);
- xas_for_each_marked(&xas, req, ULONG_MAX, CACHEFILES_REQ_NEW) {
- if (!cachefiles_ondemand_is_reopening_read(req)) {
- mask |= EPOLLIN;
- break;
- }
- }
- xas_unlock(&xas);
- }
- } else {
- if (test_bit(CACHEFILES_STATE_CHANGED, &cache->flags))
- mask |= EPOLLIN;
- }
+ if (test_bit(CACHEFILES_STATE_CHANGED, &cache->flags))
+ mask |= EPOLLIN;
if (test_bit(CACHEFILES_CULLING, &cache->flags))
mask |= EPOLLOUT;
@@ -779,14 +704,7 @@ static int cachefiles_daemon_bind(struct cachefiles_cache *cache, char *args)
return -EBUSY;
}
- if (IS_ENABLED(CONFIG_CACHEFILES_ONDEMAND)) {
- if (!strcmp(args, "ondemand")) {
- set_bit(CACHEFILES_ONDEMAND_MODE, &cache->flags);
- } else if (*args) {
- pr_err("Invalid argument to the 'bind' command\n");
- return -EINVAL;
- }
- } else if (*args) {
+ if (*args) {
pr_err("'bind' command doesn't take an argument\n");
return -EINVAL;
}