[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20220118131216.85338-5-jefflexu@linux.alibaba.com>
Date: Tue, 18 Jan 2022 21:12:00 +0800
From: Jeffle Xu <jefflexu@...ux.alibaba.com>
To: dhowells@...hat.com, linux-cachefs@...hat.com, xiang@...nel.org,
chao@...nel.org, linux-erofs@...ts.ozlabs.org
Cc: linux-fsdevel@...r.kernel.org, joseph.qi@...ux.alibaba.com,
bo.liu@...ux.alibaba.com, tao.peng@...ux.alibaba.com,
gerry@...ux.alibaba.com, eguan@...ux.alibaba.com,
linux-kernel@...r.kernel.org
Subject: [PATCH v2 04/20] cachefiles: extract generic daemon write function
... so that the following new devnode can reuse most of the code when
implementing its .write() callback.
Signed-off-by: Jeffle Xu <jefflexu@...ux.alibaba.com>
---
fs/cachefiles/daemon.c | 20 +++++++++++++++-----
1 file changed, 15 insertions(+), 5 deletions(-)
diff --git a/fs/cachefiles/daemon.c b/fs/cachefiles/daemon.c
index 7ac04ee2c0a0..aa2e5e354afb 100644
--- a/fs/cachefiles/daemon.c
+++ b/fs/cachefiles/daemon.c
@@ -209,10 +209,11 @@ static ssize_t cachefiles_daemon_read(struct file *file, char __user *_buffer,
/*
* Take a command from cachefilesd, parse it and act on it.
*/
-static ssize_t cachefiles_daemon_write(struct file *file,
- const char __user *_data,
- size_t datalen,
- loff_t *pos)
+static ssize_t cachefiles_daemon_do_write(struct file *file,
+ const char __user *_data,
+ size_t datalen,
+ loff_t *pos,
+ const struct cachefiles_daemon_cmd *cmds)
{
const struct cachefiles_daemon_cmd *cmd;
struct cachefiles_cache *cache = file->private_data;
@@ -261,7 +262,7 @@ static ssize_t cachefiles_daemon_write(struct file *file,
}
/* run the appropriate command handler */
- for (cmd = cachefiles_daemon_cmds; cmd->name[0]; cmd++)
+ for (cmd = cmds; cmd->name[0]; cmd++)
if (strcmp(cmd->name, data) == 0)
goto found_command;
@@ -284,6 +285,15 @@ static ssize_t cachefiles_daemon_write(struct file *file,
goto error;
}
+static ssize_t cachefiles_daemon_write(struct file *file,
+ const char __user *_data,
+ size_t datalen,
+ loff_t *pos)
+{
+ return cachefiles_daemon_do_write(file, _data, datalen, pos,
+ cachefiles_daemon_cmds);
+}
+
/*
* Poll for culling state
* - use EPOLLOUT to indicate culling state
--
2.27.0
Powered by blists - more mailing lists