[LTP] [PATCH 1/1] lib: Retry safe_clone() on ENOSPC|EUSERS
Petr Vorel
pvorel@suse.cz
Fri Mar 25 19:44:35 CET 2022
In some tests we are creating the namespaces faster than they are being
asynchronously cleaned up in the kernel. Thus retrying the clone() on
ENOSPC (or EUSERS for kernel < 4.9).
Before:
$ 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)
With fix:
$ sudo ./userns08 -i 10
userns08.c:67: TPASS: Denied write access to ./restricted : EACCES (13)
userns08.c:67: TPASS: Denied write access to ./restricted : EACCES (13)
userns08.c:67: TPASS: Denied write access to ./restricted : EACCES (13)
userns08.c:67: TPASS: Denied write access to ./restricted : EACCES (13)
userns08.c:67: TPASS: Denied write access to ./restricted : EACCES (13)
userns08.c:38: TINFO: clone3() failed => retrying: ENOSPC (28)
userns08.c:67: TPASS: Denied write access to ./restricted : EACCES (13)
userns08.c:67: TPASS: Denied write access to ./restricted : EACCES (13)
userns08.c:67: TPASS: Denied write access to ./restricted : EACCES (13)
userns08.c:67: TPASS: Denied write access to ./restricted : EACCES (13)
userns08.c:67: TPASS: Denied write access to ./restricted : EACCES (13)
Suggested-by: Cyril Hrubis <chrubis@suse.cz>
Signed-off-by: Petr Vorel <pvorel@suse.cz>
---
lib/tst_test.c | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/lib/tst_test.c b/lib/tst_test.c
index 384c73e163..527d265d0a 100644
--- a/lib/tst_test.c
+++ b/lib/tst_test.c
@@ -446,6 +446,14 @@ pid_t safe_clone(const char *file, const int lineno,
pid = tst_clone(args);
+ /* too fast creating namespaces => retrying */
+ if (pid < 0 && (errno == ENOSPC || errno == EUSERS)) {
+ tst_res_(file, lineno, TINFO | TERRNO, "%s() failed => retrying",
+ pid == -2 ? "clone" : "clone3");
+ usleep(100000);
+ pid = tst_clone(args);
+ }
+
switch (pid) {
case -1:
tst_brk_(file, lineno, TBROK | TERRNO, "clone3 failed");
--
2.35.1
More information about the ltp
mailing list