[Devel] [PATCH RH8] ve/fs: Export fs.aio-max-nr via ve cgroup

Andrey Zhadchenko andrey.zhadchenko at virtuozzo.com
Wed Apr 7 22:44:57 MSK 2021


This member represents fs.aio-max-nr sysctl entries. I think being able
to c/r from libvzctl script is better in terms of keeping c/r work
in one place, so instead of handling fs.aio-max-nr with sysctl utility
from inside of ve context, I do it via scripts and for this sake
fs.aio-max-nr is exported via cgroup api.

https://jira.sw.ru/browse/PSBM-45646

Signed-off-by: Cyrill Gorcunov <gorcunov at virtuozzo.com>
Acked-by: Kirill Tkhai <ktkhai at virtuozzo.com>

ktkhai@: We don't need to migrate fs.aio-nr. It's set when aio requests are
queued. If we migrate requests in the future, the true aio-nr will be set
automatically. Now we don't migrate requests (we are almost wait them), so
it's 0 on src and dst.

Rebased to vz8. Introduced new ve_aio_max_nr_read/write functions instead
of old helpers.

(cherry picked from commit 8512756dc855983bb54d633ef9c0d11d38da28c4)
Signed-off-by: Andrey Zhadchenko <andrey.zhadchenko at virtuozzo.com>
---
 kernel/ve/ve.c | 33 +++++++++++++++++++++++++++++++++
 1 file changed, 33 insertions(+)

diff --git a/kernel/ve/ve.c b/kernel/ve/ve.c
index 031b104..3473896 100644
--- a/kernel/ve/ve.c
+++ b/kernel/ve/ve.c
@@ -1508,6 +1508,33 @@ static ssize_t ve_mount_opts_write(struct kernfs_open_file *of, char *buf,
 	return nbytes;
 }
 
+static u64 ve_aio_max_nr_read(struct cgroup_subsys_state *css,
+			      struct cftype *cft)
+{
+	return css_to_ve(css)->aio_max_nr;
+}
+
+static int ve_aio_max_nr_write(struct cgroup_subsys_state *css,
+			       struct cftype *cft, u64 val)
+{
+	struct ve_struct *ve = css_to_ve(css);
+
+	if (!ve_is_super(get_exec_env()) && !ve->is_pseudosuper)
+		return -EPERM;
+
+	down_write(&ve->op_sem);
+	if (ve->is_running || ve->ve_ns) {
+		up_write(&ve->op_sem);
+		return -EBUSY;
+	}
+
+	ve->aio_max_nr = val;
+
+	up_write(&ve->op_sem);
+
+	return 0;
+}
+
 static struct cftype ve_cftypes[] = {
 
 	{
@@ -1580,6 +1607,12 @@ static ssize_t ve_mount_opts_write(struct kernfs_open_file *of, char *buf,
 		.seq_show		= ve_mount_opts_read,
 		.write			= ve_mount_opts_write,
 	},
+	{
+		.name			= "aio_max_nr",
+		.flags			= CFTYPE_NOT_ON_ROOT,
+		.read_u64		= ve_aio_max_nr_read,
+		.write_u64		= ve_aio_max_nr_write,
+	},
 	{ }
 };
 
-- 
1.8.3.1



More information about the Devel mailing list