* [PATCH v2 1/1] lib: Retry safe_clone() on ENOSPC|EUSERS
@ 2022-03-28 20:45 Petr Vorel
2022-03-28 20:47 ` Petr Vorel
0 siblings, 1 reply; 2+ messages in thread
From: Petr Vorel @ 2022-03-28 20:45 UTC (permalink / raw)
To: linux-kernel; +Cc: Petr Vorel, Cyril Hrubis, Andrea Cervesato
In some tests we are creating the namespaces faster than they are being
asynchronously cleaned up in the kernel:
$ sudo ./userns08 -i 10
userns08.c:65: TPASS: Denied write access to ./restricted : EACCES (13)
userns08.c:65: TPASS: Denied write access to ./restricted : EACCES (13)
userns08.c:65: TPASS: Denied write access to ./restricted : EACCES (13)
userns08.c:65: TPASS: Denied write access to ./restricted : EACCES (13)
userns08.c:65: TPASS: Denied write access to ./restricted : EACCES (13)
userns08.c:36: TBROK: clone3 failed: ENOSPC (28)
Thus retrying the clone() on ENOSPC (or EUSERS for kernel < 4.9).
Suggested-by: Cyril Hrubis <chrubis@suse.cz>
Signed-off-by: Petr Vorel <pvorel@suse.cz>
---
changes v1->v2:
* use TST_RETRY_FN_EXP_BACKOFF() (Cyril)
NOTE: 0.1s seems to be safe, although using TST_RETRY_FUNC() with 1s
(the default) would be of course OK.
Kind regards,
Petr
lib/tst_test.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/lib/tst_test.c b/lib/tst_test.c
index 384c73e163..2e89d954ec 100644
--- a/lib/tst_test.c
+++ b/lib/tst_test.c
@@ -436,6 +436,9 @@ pid_t safe_fork(const char *filename, unsigned int lineno)
return pid;
}
+/* too fast creating namespaces => retrying */
+#define TST_CHECK_ENOSPC(x) ((x) >= 0 || !(errno == ENOSPC || errno == EUSERS))
+
pid_t safe_clone(const char *file, const int lineno,
const struct tst_clone_args *args)
{
@@ -444,7 +447,7 @@ pid_t safe_clone(const char *file, const int lineno,
if (!tst_test->forks_child)
tst_brk(TBROK, "test.forks_child must be set!");
- pid = tst_clone(args);
+ pid = TST_RETRY_FN_EXP_BACKOFF(tst_clone(args), TST_CHECK_ENOSPC, 0.1);
switch (pid) {
case -1:
--
2.35.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH v2 1/1] lib: Retry safe_clone() on ENOSPC|EUSERS
2022-03-28 20:45 [PATCH v2 1/1] lib: Retry safe_clone() on ENOSPC|EUSERS Petr Vorel
@ 2022-03-28 20:47 ` Petr Vorel
0 siblings, 0 replies; 2+ messages in thread
From: Petr Vorel @ 2022-03-28 20:47 UTC (permalink / raw)
To: linux-kernel; +Cc: Cyril Hrubis, Andrea Cervesato
Oops, wrong list, sorry.
Kind regards,
Petr
> In some tests we are creating the namespaces faster than they are being
> asynchronously cleaned up in the kernel:
> $ sudo ./userns08 -i 10
> userns08.c:65: TPASS: Denied write access to ./restricted : EACCES (13)
> userns08.c:65: TPASS: Denied write access to ./restricted : EACCES (13)
> userns08.c:65: TPASS: Denied write access to ./restricted : EACCES (13)
> userns08.c:65: TPASS: Denied write access to ./restricted : EACCES (13)
> userns08.c:65: TPASS: Denied write access to ./restricted : EACCES (13)
> userns08.c:36: TBROK: clone3 failed: ENOSPC (28)
> Thus retrying the clone() on ENOSPC (or EUSERS for kernel < 4.9).
> Suggested-by: Cyril Hrubis <chrubis@suse.cz>
> Signed-off-by: Petr Vorel <pvorel@suse.cz>
> ---
> changes v1->v2:
> * use TST_RETRY_FN_EXP_BACKOFF() (Cyril)
> NOTE: 0.1s seems to be safe, although using TST_RETRY_FUNC() with 1s
> (the default) would be of course OK.
> Kind regards,
> Petr
> lib/tst_test.c | 5 ++++-
> 1 file changed, 4 insertions(+), 1 deletion(-)
> diff --git a/lib/tst_test.c b/lib/tst_test.c
> index 384c73e163..2e89d954ec 100644
> --- a/lib/tst_test.c
> +++ b/lib/tst_test.c
> @@ -436,6 +436,9 @@ pid_t safe_fork(const char *filename, unsigned int lineno)
> return pid;
> }
> +/* too fast creating namespaces => retrying */
> +#define TST_CHECK_ENOSPC(x) ((x) >= 0 || !(errno == ENOSPC || errno == EUSERS))
> +
> pid_t safe_clone(const char *file, const int lineno,
> const struct tst_clone_args *args)
> {
> @@ -444,7 +447,7 @@ pid_t safe_clone(const char *file, const int lineno,
> if (!tst_test->forks_child)
> tst_brk(TBROK, "test.forks_child must be set!");
> - pid = tst_clone(args);
> + pid = TST_RETRY_FN_EXP_BACKOFF(tst_clone(args), TST_CHECK_ENOSPC, 0.1);
> switch (pid) {
> case -1:
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2022-03-28 20:49 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-03-28 20:45 [PATCH v2 1/1] lib: Retry safe_clone() on ENOSPC|EUSERS Petr Vorel
2022-03-28 20:47 ` Petr Vorel
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.