[Devel] [PATCH RHEL7 COMMIT] vznetstat: Make sure the statistics is allocated for VE
Konstantin Khorenko
khorenko at virtuozzo.com
Fri Jul 17 12:55:05 PDT 2015
The commit is pushed to "branch-rh7-3.10.0-123.1.2-ovz" and will appear at https://src.openvz.org/scm/ovz/vzkernel.git
after rh7-3.10.0-123.1.2.vz7.5.25
------>
commit 3ad7b9565dc63734b584ce1f4c67ffb5456aa306
Author: Cyrill Gorcunov <gorcunov at virtuozzo.com>
Date: Fri Jul 17 23:55:04 2015 +0400
vznetstat: Make sure the statistics is allocated for VE
Currently the ip_vznetstat doesn't allocate statistics for new
VEs but rather relies on fact that ip6_vznetstat module is loaded,
which is not always the true. It's rather messy at moment:
ip_vznetstat allocates stat for all existing VE's in module
init procedure, while ip6_vznetstat allocates statistics for
every new VE's, better might be to move all this stuff into
general vznetstat module in future.
https://jira.sw.ru/browse/PSBM-34837
Signed-off-by: Cyrill Gorcunov <gorcunov at virtuozzo.com>
CC: Andrey Vagin <avagin at virtuozzo.com>
CC: Vladimir Davydov <vdavydov at virtuozzo.com>
CC: Konstantin Khorenko <khorenko at virtuozzo.com>
CC: Igor Sukhih <igor at parallels.com>
---
kernel/ve/vznetstat/ip_vznetstat.c | 38 ++++++++++++++++++++++++++++++++++++++
1 file changed, 38 insertions(+)
diff --git a/kernel/ve/vznetstat/ip_vznetstat.c b/kernel/ve/vznetstat/ip_vznetstat.c
index 1eb637b..4fbadf2 100644
--- a/kernel/ve/vznetstat/ip_vznetstat.c
+++ b/kernel/ve/vznetstat/ip_vznetstat.c
@@ -192,6 +192,42 @@ void ip_vznetstat_touch(void)
}
EXPORT_SYMBOL(ip_vznetstat_touch);
+static int init_venet_acct_ip_stat_hook(void *data)
+{
+ struct ve_struct *ve = (struct ve_struct *)data;
+ struct venet_stat *stat;
+
+ if (!ve->stat) {
+ stat = venet_acct_find_create_stat(ve->veid);
+ if (!stat)
+ return -ENOMEM;
+ init_venet_acct_ip_stat(ve, stat);
+ } else
+ venet_acct_get_stat(ve->stat);
+
+ __module_get(THIS_MODULE);
+ return 0;
+}
+
+static void fini_venet_acct_ip_stat_hook(void *data)
+{
+ struct ve_struct *ve = (struct ve_struct *)data;
+
+ /* module was load after VE ? */
+ if (!ve->stat)
+ return;
+
+ venet_acct_put_stat(ve->stat);
+ module_put(THIS_MODULE);
+}
+
+static struct ve_hook venet_acct_ip_stat_hook = {
+ .init = init_venet_acct_ip_stat_hook,
+ .fini = fini_venet_acct_ip_stat_hook,
+ .priority = HOOK_PRIO_NET_ACCT,
+ .owner = THIS_MODULE,
+};
+
/*
* ---------------------------------------------------------------------------
* Initialization
@@ -216,6 +252,7 @@ int __init ip_venetstat_init(void)
if (ret < 0)
goto err;
+ ve_hook_register(VE_SS_CHAIN, &venet_acct_ip_stat_hook);
return 0;
err:
mutex_lock(&ve_list_lock);
@@ -233,6 +270,7 @@ void __exit ip_venetstat_exit(void)
struct ve_struct *ve;
venet_acct_unregister_ip_hooks();
+ ve_hook_unregister(&venet_acct_ip_stat_hook);
mutex_lock(&ve_list_lock);
for_each_ve(ve) {
More information about the Devel
mailing list