Received: by 2002:a05:6512:2355:0:0:0:0 with SMTP id p21csp5528715lfu; Mon, 28 Mar 2022 16:03:00 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyg+4sVSBHC9YmqBytQ4hJy3iMyws+1woPMG5YJJ7C4CtOtDYXbV2NauT6bmZp+W0EsdWgT X-Received: by 2002:a05:6808:aa6:b0:2ef:3ff8:b1ca with SMTP id r6-20020a0568080aa600b002ef3ff8b1camr774549oij.57.1648508580645; Mon, 28 Mar 2022 16:03:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1648508580; cv=none; d=google.com; s=arc-20160816; b=WXqhRtNTVg7LOgbVPXnzCHtyMMb4E1aK51GpyeUbiuii3P8lPZ9cXXNJq8ctirXM9z ot3xXLMVgbNZV897/+OPRVuXGbdsMoAQA1jepv7TZ5f5bqZE+MV04SPXj/jaDY3zd9OA c9ys6kx9wKcl/HYBo2HuOA+zN7fE/O+ei9Nql6cVHW72MtOvFpJ1Bcu2FSHTXRPmSYkX cUTbpNM1HcTIs0SG5wgUfrXssEMZUty6kfdAm1OjyhOjlfiMYy7+4DJyS5bM/KP3n9nR fCFdOB4lCe3FEXoMeHAUrUtfaBZM7Ue6nX7Mlp8J3jfofBAbgl3yE9SmD5sxstqd7Iel ckdQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature:dkim-signature; bh=X6NIxGNottqljoTasC6vRjEbRw8uZfFfQW5dJ7q06EE=; b=liYRcfepA9Ssbrrbt8itHBEbePHOWGbLMPNOzEcLj/TmHlqb/qU8rUQe09jVDzS4R0 uWcOJEAd5hHEQpEj26siZHRyaJPh+Dy10/CS5RbFG2xcC7CHuOmrY2cr3pi2NSRSErw4 7BpiFhnoidB2/pR93WbQRd+nGQi1h5qxZ5xdkp1hxKFLGTOUHSBOT9iXIYj4CMCEgLvN +Ay1Z2H6sd4ThSLfvKuJKSn6ijyoZiaP9jx9Tbf9ZjnzF5Qkbv/RULnWbenmZstdKsor Fe2By3cN1OBw7L/r1xURcjDNyhqKiWINZ0FoEN7WgtST9ZtbE2sZVsegKzmDF8Olh32/ 8yNw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.cz header.s=susede2_rsa header.b=0nlol1R2; dkim=neutral (no key) header.i=@suse.cz header.s=susede2_ed25519; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id d124-20020acab482000000b002ef0c3475ffsi9658797oif.127.2022.03.28.16.03.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 28 Mar 2022 16:03:00 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@suse.cz header.s=susede2_rsa header.b=0nlol1R2; dkim=neutral (no key) header.i=@suse.cz header.s=susede2_ed25519; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 9B08C2A7BB0; Mon, 28 Mar 2022 15:08:38 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345661AbiC1Uue (ORCPT + 99 others); Mon, 28 Mar 2022 16:50:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51736 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346295AbiC1Us1 (ORCPT ); Mon, 28 Mar 2022 16:48:27 -0400 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5429E6BDF4 for ; Mon, 28 Mar 2022 13:46:00 -0700 (PDT) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id CE2E01F866; Mon, 28 Mar 2022 20:45:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1648500358; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=X6NIxGNottqljoTasC6vRjEbRw8uZfFfQW5dJ7q06EE=; b=0nlol1R2bRwpSjdo6iljCXyGvsJZ9rqc4M5SZkH7VHMIk+oKL/db9qNTZr53F3PMd7RW4K fj7EJYrYC3GcUgm5WB0r0gjKttGguU0iOChVgcnFdAL9QOmjU7UxcxcGrX8qoZXt2InNb6 xX24HHVgL0AR6cweuMjQQHz4ETffyB4= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1648500358; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=X6NIxGNottqljoTasC6vRjEbRw8uZfFfQW5dJ7q06EE=; b=REBhHBKOTDn3Nt/pTVAKvNYOwcut5kaaYYn64pB/Ag2CuiY/scNaWxuamuT0vGVx4gpqMf 3YFMv8QRD7a2CgCA== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 926411332D; Mon, 28 Mar 2022 20:45:58 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id ZSc4IYYeQmLIUgAAMHmgww (envelope-from ); Mon, 28 Mar 2022 20:45:58 +0000 From: Petr Vorel To: linux-kernel@vger.kernel.org Cc: Petr Vorel , Cyril Hrubis , Andrea Cervesato Subject: [PATCH v2 1/1] lib: Retry safe_clone() on ENOSPC|EUSERS Date: Mon, 28 Mar 2022 22:45:54 +0200 Message-Id: <20220328204554.2528-1-pvorel@suse.cz> X-Mailer: git-send-email 2.35.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 Signed-off-by: Petr Vorel --- 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