lib: Retry safe_clone() on ENOSPC|EUSERS
PATCH 1/1 lib: Retry safe_clone() on ENOSPC|EUSERS
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 <[email protected]>
Signed-off-by Petr Vorel <[email protected]>
--- lib/tst_test.c | 8 ++++++++ 1 file changed, 8 insertions(+)
lib/tst_test.c +8 -0
@@ -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" );
Signature · 5 lines
2.35.1 -- Mailing list info: https://lists.linux.it/listinfo/ltp
Hi!
lib/tst_test.c pid_t safe_clone(const char *file, const int lineno, · line 454
Quoted 6 lines
lib/tst_test.c +6
-0+/* 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);
Wouldn't it make sense to use the exponential backof macro we have in tst_common.h?
Signature · 5 lines
Cyril Hrubis [email protected] -- Mailing list info: https://lists.linux.it/listinfo/ltp
Quoted 10 lines
Hi!
lib/tst_test.c pid_t safe_clone(const char *file, const int lineno, · line 454
Quoted 6 lines
lib/tst_test.c +6
-0+/* 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);Wouldn't it make sense to use the exponential backof macro we have in
tst_common.h?
+1 => I'll send v2.
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp