OpenVZ / Virtuozzo kernel development (devel@openvz.org)
 help / color / mirror / Atom feed
From: no-reply@sashiko.virtuozzo.com
To: Vladimir Riabchun <vladimir.riabchun@virtuozzo.com>,
	vasileios.almpanis@virtuozzo.com,
	Konstantin Khorenko <khorenko@virtuozzo.com>,
	ptikhomirov@virtuozzo.com
Cc: devel@openvz.org
Subject: Re: [Devel] [PATCH hci-8.1 1/4] ve: Remove STOPPED state
Date: Thu, 22 Oct 2026 15:11:14 +0000	[thread overview]
Message-ID: <010701a1642a92b7-37a13b94-dfda-460d-87f9-893f3c969e82-000000@eu-central-1.amazonses.com> (raw)
In-Reply-To: <20261022-ovl-use-orig-ve-v1-1-da84c00c8065@virtuozzo.com>

Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [Low] ve: renumbering VE_STATE_DEAD from 4 to 3 changes the state value logged by setns
- [Low] ve: commit message claims STOPPED removal blocks VE reuse, but it is only a cleanup
--

commit afa07824d11d984ebc29eb501787f9b9b4ecea47
Author: Vladimir Riabchun <vladimir.riabchun@virtuozzo.com>

ve: Remove STOPPED state

This patch merges VE_STATE_STOPPED into VE_STATE_DEAD. The stop path in
ve_exit_ns() and the error path in ve_start_container() now set DEAD
directly. It also drops the ve_set_state(DEAD) call in ve_destroy() and
renumbers VE_STATE_DEAD from 4 to 3.

Link: https://virtuozzo.atlassian.net/browse/VSTOR-142405

> diff --git a/include/linux/ve.h b/include/linux/ve.h
> --- a/include/linux/ve.h
> +++ b/include/linux/ve.h
> @@ -40,8 +40,7 @@ struct vfsmount;
>  #define VE_STATE_STARTING	0
>  #define VE_STATE_RUNNING	1
>  #define VE_STATE_STOPPING	2
> -#define VE_STATE_STOPPED	3
> -#define VE_STATE_DEAD		4
> +#define VE_STATE_DEAD		3

[Severity: Low]
Is the renumbering of VE_STATE_DEAD from 4 to 3 intended to be visible in
logs?

The raw state integer is printed in the setns check in
kernel/ve/ve_namespace.c:

    ve_name(ve_ns->ve), ve_ns->ve->state,

and in the ve_set_state() WARN_ONCE messages. Anything that parses the
integer in the "setns to the VE namespace of a non-running CT (state %d)"
message now sees 3 for a stopped CT, where it could previously see 3 or 4.

The cgroup state file is unaffected, since ve_state_show() still prints
"STOPPED" for VE_STATE_DEAD.

[ ... ]

> @@ -680,7 +680,7 @@ void ve_exit_ns(struct pid_namespace *pid_ns)
>  	ve_hook_iterate_fini(VE_SS_CHAIN, ve);
>  	ve_list_del(ve);
>  	ve_drop_context(ve);
> -	ve_set_state(ve, VE_STATE_STOPPED);
> +	ve_set_state(ve, VE_STATE_DEAD);
>  	up_write(&ve->op_sem);

[Severity: Low]
This isn't a bug, but the commit message doesn't seem to match what the
patch does. It says:

    We really don't want to reuse VE after its stop.
    Some resources from the old run can reference this CT, so new
    start may see leftovers.

    Fix this by transitioning from STOPPING to DEAD directly.

Is that description accurate?

ve_start_container() already rejected a restart for any state other than
STARTING:

    if (ve->state != VE_STATE_STARTING || ve_nsproxy)
        return -EBUSY;

STARTING is only assigned in ve_create(). A VE in STOPPED could therefore
not be restarted before this patch, and a VE in DEAD cannot be restarted
now.

The ve_set_state(DEAD) call removed from ve_destroy() wrote to an object
that kmem_cache_free() releases immediately afterwards:

    ve_set_state(ve, VE_STATE_DEAD);
    kmem_cache_free(ve_cachep, ve);

So DEAD was never observable there.

The later patches in the series (override_ve/revert_ve and the overlayfs
creator VE changes) don't check VE_STATE_DEAD or VE_IS_RUNNING. They take
and drop references with get_ve() and put_ve(). It looks like the
"leftovers" problem is addressed by those reference changes and not by
this patch.

Could the commit message be reworded to say that this is a state machine
cleanup that merges STOPPED into DEAD and removes a dead store in
ve_destroy()?

[ ... ]

-- 
Sashiko AI review · https://sashiko.vzint.dev/#/patchset/20261022-ovl-use-orig-ve-v1-0-da84c00c8065@virtuozzo.com?part=1

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

  reply	other threads:[~2026-10-22 15:12 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-22 15:05 [Devel] [PATCH hci-8.1 0/4] Fix kernel crash in overlayfs Vladimir Riabchun
2026-10-22 15:05 ` [Devel] [PATCH hci-8.1 1/4] ve: Remove STOPPED state Vladimir Riabchun
2026-10-22 15:11   ` no-reply [this message]
2026-10-22 15:28     ` Vladimir Riabchun
2026-10-22 15:05 ` [Devel] [PATCH hci-8.1 2/4] ve: Introduce override_ve/revert_ve helpers Vladimir Riabchun
2026-10-22 15:10   ` no-reply
2026-10-26 12:35     ` Vladimir Riabchun
2026-10-22 15:05 ` [Devel] [PATCH hci-8.1 3/4] ovl: Keep creator VE in overlayfs superblock Vladimir Riabchun
2026-10-22 15:12   ` no-reply
2026-10-22 15:05 ` [Devel] [PATCH hci-8.1 4/4] ve/overlayfs: Override VE together with creds Vladimir Riabchun
2026-10-22 15:17   ` no-reply
2026-10-26 12:37     ` Vladimir Riabchun

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=010701a1642a92b7-37a13b94-dfda-460d-87f9-893f3c969e82-000000@eu-central-1.amazonses.com \
    --to=no-reply@sashiko.virtuozzo.com \
    --cc=devel@openvz.org \
    --cc=khorenko@virtuozzo.com \
    --cc=ptikhomirov@virtuozzo.com \
    --cc=vasileios.almpanis@virtuozzo.com \
    --cc=vladimir.riabchun@virtuozzo.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox