From: Cyrill Gorcunov <gorcu...@virtuozzo.com>

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 <gorcu...@virtuozzo.com>
Acked-by: Kirill Tkhai <ktk...@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.

 - Added #ifdef CONFIG_AIO since ve_struct->aio_max_nr
   is also guarded by it.

(cherry picked from vz7 commit 8512756dc855 ("ve/fs: Export fs.aio-max-nr
via ve cgroup"))

Signed-off-by: Andrey Zhadchenko <andrey.zhadche...@virtuozzo.com>

(cherry picked from vz8 commit 9bd5a424b740077666a5612392581789e1fb2b20)
Signed-off-by: Andrey Zhadchenko <andrey.zhadche...@virtuozzo.com>
---
 kernel/ve/ve.c | 37 +++++++++++++++++++++++++++++++++++++
 1 file changed, 37 insertions(+)

diff --git a/kernel/ve/ve.c b/kernel/ve/ve.c
index aad35ae..e8616d9 100644
--- a/kernel/ve/ve.c
+++ b/kernel/ve/ve.c
@@ -1304,6 +1304,35 @@ static ssize_t ve_mount_opts_write(struct 
kernfs_open_file *of, char *buf,
        return nbytes;
 }
 
+#ifdef CONFIG_AIO
+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;
+}
+#endif
+
 static struct cftype ve_cftypes[] = {
 
        {
@@ -1366,6 +1395,14 @@ 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,
        },
+#ifdef CONFIG_AIO
+       {
+               .name                   = "aio_max_nr",
+               .flags                  = CFTYPE_NOT_ON_ROOT,
+               .read_u64               = ve_aio_max_nr_read,
+               .write_u64              = ve_aio_max_nr_write,
+       },
+#endif
        { }
 };
 
-- 
1.8.3.1

_______________________________________________
Devel mailing list
Devel@openvz.org
https://lists.openvz.org/mailman/listinfo/devel

Reply via email to