It is more consistent to use guards everywhere in the patch and not only
in some places and in other places don't.
Fixes: 8a771a3d6bea ("ve: Introduce VE namespace")
https://virtuozzo.atlassian.net/browse/VSTOR-118289
Signed-off-by: Pavel Tikhomirov <[email protected]>
Feature: ve: ve generic structures
---
kernel/nsproxy.c | 10 +++++-----
kernel/ve/ve_namespace.c | 18 +++++++++---------
2 files changed, 14 insertions(+), 14 deletions(-)
diff --git a/kernel/nsproxy.c b/kernel/nsproxy.c
index ccf53bd9579d..2827d4f277ad 100644
--- a/kernel/nsproxy.c
+++ b/kernel/nsproxy.c
@@ -430,11 +430,11 @@ static int validate_nsset(struct nsset *nsset, struct pid
*pid)
#endif
#ifdef CONFIG_VE
if (flags & CLONE_NEWVE) {
- task_lock(tsk);
- ve_ns = tsk->ve_ns;
- if (ve_ns)
- get_ve_ns(ve_ns);
- task_unlock(tsk);
+ scoped_guard(task_lock, tsk) {
+ ve_ns = tsk->ve_ns;
+ if (ve_ns)
+ get_ve_ns(ve_ns);
+ }
if (!ve_ns) {
rcu_read_unlock();
ret = -ESRCH;
diff --git a/kernel/ve/ve_namespace.c b/kernel/ve/ve_namespace.c
index d3985d52e0e5..e76a41a0fbca 100644
--- a/kernel/ve/ve_namespace.c
+++ b/kernel/ve/ve_namespace.c
@@ -135,11 +135,11 @@ void switch_ve_namespace(struct task_struct *p, struct
ve_namespace *new)
* task p to confirm to the ve_ns
*/
- task_lock(p);
- old = p->ve_ns;
- p->ve_ns = new;
- p->task_ve = new ? new->ve : &ve0;
- task_unlock(p);
+ scoped_guard(task_lock, p) {
+ old = p->ve_ns;
+ p->ve_ns = new;
+ p->task_ve = new ? new->ve : &ve0;
+ }
if (old)
put_ve_ns(old);
@@ -166,10 +166,10 @@ static struct ns_common *ve_ns_get(struct task_struct
*task)
{
struct ve_namespace *ns = NULL;
- task_lock(task);
- if (task->ve_ns)
- ns = get_ve_ns(task->ve_ns);
- task_unlock(task);
+ scoped_guard(task_lock, task) {
+ if (task->ve_ns)
+ ns = get_ve_ns(task->ve_ns);
+ }
return ns ? &ns->ns : NULL;
}
--
2.51.1
_______________________________________________
Devel mailing list
[email protected]
https://lists.openvz.org/mailman/listinfo/devel