[RHEL7,COMMIT] ve/net: allow to change max number of net devices for running CT

Submitted by Konstantin Khorenko on March 4, 2019, 12:30 p.m.

Details

Message ID 201903041230.x24CUY5t001841@finist-ce7.sw.ru
State New
Series "ve/net: allow to change max number of net devices for running CT"
Headers show

Commit Message

Konstantin Khorenko March 4, 2019, 12:30 p.m.
The commit is pushed to "branch-rh7-3.10.0-957.5.1.vz7.84.x-ovz" and will appear at https://src.openvz.org/scm/ovz/vzkernel.git
after rh7-3.10.0-957.5.1.vz7.84.2
------>
commit 727b6a3616f1410829256120509ed055fb8aa1f4
Author: Konstantin Khorenko <khorenko@virtuozzo.com>
Date:   Fri Mar 1 17:21:13 2019 +0300

    ve/net: allow to change max number of net devices for running CT
    
    If a Container hits "ve::netif_max_nr", we want to fix the situation by
    increasing the limit without a Container restart, so allow this.
    
    Note: too low value set can turn "ve::netif_avail_nr" to negative,
    that's OK, the code is ready for that.
    
    https://jira.sw.ru/browse/PSBM-92132
    
    Signed-off-by: Konstantin Khorenko <khorenko@virtuozzo.com>
    Reviewed-by: Pavel Tikhomirov <ptikhomirov@virtuozzo.com>
---
 kernel/ve/ve.c | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

Patch hide | download patch | download mbox

diff --git a/kernel/ve/ve.c b/kernel/ve/ve.c
index 37c65c93abef..f1aef51f8bd5 100644
--- a/kernel/ve/ve.c
+++ b/kernel/ve/ve.c
@@ -1307,7 +1307,12 @@  static u64 ve_read_u64(struct cgroup *cg, struct cftype *cft)
 		return atomic_read(&cgroup_ve(cg)->netns_avail_nr);
 	else if (cft->private == VE_CF_NETIF_MAX_NR)
 		return cgroup_ve(cg)->netif_max_nr;
-	else if (cft->private == VE_CF_NETIF_NR)
+	return 0;
+}
+
+static s64 ve_read_s64(struct cgroup *cg, struct cftype *cft)
+{
+	if (cft->private == VE_CF_NETIF_NR)
 		return atomic_read(&cgroup_ve(cg)->netif_avail_nr);
 	return 0;
 }
@@ -1598,12 +1603,12 @@  static struct cftype ve_cftypes[] = {
 		.name			= "netif_max_nr",
 		.flags			= CFTYPE_NOT_ON_ROOT,
 		.read_u64		= ve_read_u64,
-		.write_u64		= ve_write_u64,
+		.write_u64		= ve_write_running_u64,
 		.private		= VE_CF_NETIF_MAX_NR,
 	},
 	{
 		.name			= "netif_avail_nr",
-		.read_u64		= ve_read_u64,
+		.read_s64		= ve_read_s64,
 		.private		= VE_CF_NETIF_NR,
 	},
 	{