[Devel] [PATCH RHEL7 COMMIT] net: Cleanup in copy_net_ns()
Konstantin Khorenko
khorenko at virtuozzo.com
Wed May 27 21:34:56 MSK 2020
The commit is pushed to "branch-rh7-3.10.0-1127.8.2.vz7.161.x-ovz" and will appear at https://src.openvz.org/scm/ovz/vzkernel.git
after rh7-3.10.0-1127.8.2.vz7.161.3
------>
commit 692368eb77ff13d9edcde4ca0c62bd7e74363c57
Author: Kirill Tkhai <ktkhai at virtuozzo.com>
Date: Wed May 27 21:34:55 2020 +0300
net: Cleanup in copy_net_ns()
ms commit 5ba049a5cc8e
Line up destructors actions in the revers order
to constructors. Next patches will add more actions,
and this will be comfortable, if there is the such
order.
Signed-off-by: Kirill Tkhai <ktkhai at virtuozzo.com>
Acked-by: Andrei Vagin <avagin at virtuozzo.com>
Signed-off-by: David S. Miller <davem at davemloft.net>
=====================
Patchset description:
Parallel per-net init/exit
https://jira.sw.ru/browse/PSBM-104158
---
net/core/net_namespace.c | 23 +++++++++++++++--------
1 file changed, 15 insertions(+), 8 deletions(-)
diff --git a/net/core/net_namespace.c b/net/core/net_namespace.c
index 954f78c526d3d..c461acce68bb5 100644
--- a/net/core/net_namespace.c
+++ b/net/core/net_namespace.c
@@ -406,28 +406,35 @@ struct net *copy_net_ns(unsigned long flags,
return ERR_PTR(-ENOSPC);
if (atomic_dec_if_positive(&ve->netns_avail_nr) < 0) {
- dec_net_namespaces(ucounts);
- return ERR_PTR(-ENOMEM);
+ rv = -ENOMEM;
+ goto dec_ucounts;
+
}
net = net_alloc();
if (!net) {
- dec_net_namespaces(ucounts);
- atomic_inc(&ve->netns_avail_nr);
- return ERR_PTR(-ENOMEM);
+ rv = -ENOMEM;
+ goto inc_avail_nr;
}
+ atomic_set(&net->passive, 1);
+ net->ucounts = ucounts;
get_user_ns(user_ns);
- mutex_lock(&net_mutex);
- net->ucounts = ucounts;
+ rv = mutex_lock_killable(&net_mutex);
+ if (rv < 0)
+ goto put_userns;
+
rv = setup_net(net, user_ns);
mutex_unlock(&net_mutex);
if (rv < 0) {
- dec_net_namespaces(ucounts);
+put_userns:
put_user_ns(user_ns);
net_drop_ns(net);
+inc_avail_nr:
atomic_inc(&ve->netns_avail_nr);
+dec_ucounts:
+ dec_net_namespaces(ucounts);
return ERR_PTR(rv);
}
return net;
More information about the Devel
mailing list