diff options
author | Jeffle Xu <jefflexu@linux.alibaba.com> | 2022-04-25 14:21:28 +0200 |
---|---|---|
committer | Gao Xiang <hsiangkao@linux.alibaba.com> | 2022-05-17 18:11:18 +0200 |
commit | 4e4f1788af0e477bca079e5b1ffc42846b3bafee (patch) | |
tree | 1d4710cf2d6b258f0c7d79ad397c7b08392c7bd0 | |
parent | cachefiles: implement on-demand read (diff) | |
download | linux-4e4f1788af0e477bca079e5b1ffc42846b3bafee.tar.xz linux-4e4f1788af0e477bca079e5b1ffc42846b3bafee.zip |
cachefiles: enable on-demand read mode
Enable on-demand read mode by adding an optional parameter to the "bind"
command.
On-demand mode will be turned on when this parameter is "ondemand", i.e.
"bind ondemand". Otherwise cachefiles will work in the original mode.
Signed-off-by: Jeffle Xu <jefflexu@linux.alibaba.com>
Link: https://lore.kernel.org/r/20220509074028.74954-7-jefflexu@linux.alibaba.com
Acked-by: David Howells <dhowells@redhat.com>
Signed-off-by: Gao Xiang <hsiangkao@linux.alibaba.com>
-rw-r--r-- | fs/cachefiles/daemon.c | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/fs/cachefiles/daemon.c b/fs/cachefiles/daemon.c index 5b1d0642c749..aa4efcabb5e3 100644 --- a/fs/cachefiles/daemon.c +++ b/fs/cachefiles/daemon.c @@ -755,11 +755,6 @@ static int cachefiles_daemon_bind(struct cachefiles_cache *cache, char *args) cache->brun_percent >= 100) return -ERANGE; - if (*args) { - pr_err("'bind' command doesn't take an argument\n"); - return -EINVAL; - } - if (!cache->rootdirname) { pr_err("No cache directory specified\n"); return -EINVAL; @@ -771,6 +766,18 @@ 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) { + pr_err("'bind' command doesn't take an argument\n"); + return -EINVAL; + } + /* Make sure we have copies of the tag string */ if (!cache->tag) { /* |