Skip to content

Commit 4e4f178

Browse files
lostjefflehsiangkao
authored andcommitted
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 <[email protected]> Link: https://lore.kernel.org/r/[email protected] Acked-by: David Howells <[email protected]> Signed-off-by: Gao Xiang <[email protected]>
1 parent 9032b6e commit 4e4f178

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

fs/cachefiles/daemon.c

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -755,11 +755,6 @@ static int cachefiles_daemon_bind(struct cachefiles_cache *cache, char *args)
755755
cache->brun_percent >= 100)
756756
return -ERANGE;
757757

758-
if (*args) {
759-
pr_err("'bind' command doesn't take an argument\n");
760-
return -EINVAL;
761-
}
762-
763758
if (!cache->rootdirname) {
764759
pr_err("No cache directory specified\n");
765760
return -EINVAL;
@@ -771,6 +766,18 @@ static int cachefiles_daemon_bind(struct cachefiles_cache *cache, char *args)
771766
return -EBUSY;
772767
}
773768

769+
if (IS_ENABLED(CONFIG_CACHEFILES_ONDEMAND)) {
770+
if (!strcmp(args, "ondemand")) {
771+
set_bit(CACHEFILES_ONDEMAND_MODE, &cache->flags);
772+
} else if (*args) {
773+
pr_err("Invalid argument to the 'bind' command\n");
774+
return -EINVAL;
775+
}
776+
} else if (*args) {
777+
pr_err("'bind' command doesn't take an argument\n");
778+
return -EINVAL;
779+
}
780+
774781
/* Make sure we have copies of the tag string */
775782
if (!cache->tag) {
776783
/*

0 commit comments

Comments
 (0)