[Devel] [PATCH VZ10 v9 8/8] selftests/ve: Add mount accounting selftest
Konstantin Khorenko
khorenko at virtuozzo.com
Fri Sep 25 19:04:42 MSK 2026
On 9/15/26 19:22, Vladimir Riabchun wrote:
> There are 6 test cases, covered in the new test:
> 1. Simple mount accouting correctness, just mount/umount.
> 2. Verification of correct limit hits and changes, including
> negative values.
> 3. Partial mounts test, when mount limit is hit in the middle
> of creation.
> 4. Test that enabled pseudosuper allows overuse.
> 5. Test that pseudosuper doesn't affect mount accounting.
> 6. Failcount feature verification.
>
> https://virtuozzo.atlassian.net/browse/VSTOR-135520
>
> Feature: per-ve failcounters
> Signed-off-by: Vladimir Riabchun <vladimir.riabchun at virtuozzo.com>
> ---
> tools/testing/selftests/ve/.gitignore | 1 +
> tools/testing/selftests/ve/Makefile | 1 +
> .../selftests/ve/ve_mount_accounting_test.c | 550 ++++++++++++++++++
> tools/testing/selftests/ve/ve_selftest.h | 21 +
> 4 files changed, 573 insertions(+)
> create mode 100644 tools/testing/selftests/ve/ve_mount_accounting_test.c
>
<skipped>
> + * We can't enforce workqueue flush from userspace, so instead
> + * read several times until the value is the one we expect.
> + */
> +static int wait_on_mnt_avail(FIXTURE_DATA(ve_mnt_acc) * self, int expected)
> +{
> +#define WAIT_TIMEOUT_NS (4096UL * 1000 * 1000)
> + char path_avail[64];
> + int mnt_avail_nr = 0;
> + struct timespec delay = { .tv_nsec = 1000000 };
> +
> + snprintf(path_avail, sizeof(path_avail), "%d/ve.mnt_avail_nr", self->ctid);
> +
> + while (delay.tv_nsec <= WAIT_TIMEOUT_NS) {
> + if (read_s32_at(self->cgv2_fd, path_avail, &mnt_avail_nr)) {
> + fprintf(stderr, "Failed to read from %s\n", path_avail);
> + return 1;
> + }
> + if (mnt_avail_nr == expected)
> + return 0;
> +
> + do_rcu_barrier();
> + if (nanosleep(&delay, NULL)) {
> + fprintf(stderr, "nanosleep failed: %s\n", strerror(errno));
> + return 1;
> + }
> + delay.tv_nsec *= 2;
nanosleep() requires tv_nsec < 1e9 and fails with EINVAL otherwise.
The doubling goes 1ms, 2ms, ..., 512ms, and the next step is 1024ms,
which no longer fits tv_nsec. So the loop never gets anywhere near
WAIT_TIMEOUT_NS: after ~1s of total sleeping the next iteration bails
out with "nanosleep failed: Invalid argument" and returns 1, instead
of the intended ~8s of waiting and the timeout report with the
expected/read values.
This defeats the purpose of the helper: on a loaded machine, where
the counter takes a while to settle, the test fails early with a
misleading error - exactly the case this function was reworked for
in v9.
Please keep the delay in a plain nanoseconds variable and normalize
it before sleeping:
delay.tv_sec = ns / 1000000000;
delay.tv_nsec = ns % 1000000000;
As a side note, tv_nsec is long, so 2048ms would overflow it on a
32-bit build; the normalization fixes that too.
<skipped>
More information about the Devel
mailing list