From patchwork Tue Nov 26 04:54:22 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Li Wang X-Patchwork-Id: 1200725 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.linux.it (client-ip=2001:1418:10:5::2; helo=picard.linux.it; envelope-from=ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.b="ac6NUp7m"; dkim-atps=neutral Received: from picard.linux.it (picard.linux.it [IPv6:2001:1418:10:5::2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 47MWm56WBcz9sPV for ; Tue, 26 Nov 2019 15:54:43 +1100 (AEDT) Received: from picard.linux.it (localhost [IPv6:::1]) by picard.linux.it (Postfix) with ESMTP id 846753C2284 for ; Tue, 26 Nov 2019 05:54:39 +0100 (CET) X-Original-To: ltp@lists.linux.it Delivered-To: ltp@picard.linux.it Received: from in-7.smtp.seeweb.it (in-7.smtp.seeweb.it [IPv6:2001:4b78:1:20::7]) by picard.linux.it (Postfix) with ESMTP id 135CC3C131B for ; Tue, 26 Nov 2019 05:54:37 +0100 (CET) Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [205.139.110.120]) by in-7.smtp.seeweb.it (Postfix) with ESMTP id A3FB9201554 for ; Tue, 26 Nov 2019 05:54:35 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1574744073; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=OiuEfjtr+EpKeQ0CWXqqnTs1I+tz/mkxCu3Hc+w20D8=; b=ac6NUp7mhk1mZSAFsRbNqwJfHFn5tH1qHqH88uxe9mDQmTUAGofByHVynZdK/onZextDO1 JD1uJFOmSrAqDCYLETTxLy050/W64o7rA7UwHX6PzDaXv2mBWgWGJ0pBVMC4VJYk2VKRbT KsOzRqNOQnVbZND7BprStFadWZbVDts= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-330-xZ6lZwgQMeiZ1ilSa8rKow-1; Mon, 25 Nov 2019 23:54:30 -0500 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id BDF44DB20; Tue, 26 Nov 2019 04:54:28 +0000 (UTC) Received: from localhost.localdomain.com (unknown [10.66.81.246]) by smtp.corp.redhat.com (Postfix) with ESMTP id A8B9A600C6; Tue, 26 Nov 2019 04:54:26 +0000 (UTC) From: Li Wang To: ltp@lists.linux.it Date: Tue, 26 Nov 2019 12:54:22 +0800 Message-Id: <20191126045422.12808-1-liwang@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-MC-Unique: xZ6lZwgQMeiZ1ilSa8rKow-1 X-Mimecast-Spam-Score: 0 X-Virus-Scanned: clamav-milter 0.99.2 at in-7.smtp.seeweb.it X-Virus-Status: Clean X-Spam-Status: No, score=0.1 required=7.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU, SPF_HELO_NONE, SPF_PASS autolearn=disabled version=3.4.0 X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on in-7.smtp.seeweb.it Subject: [LTP] [PATCH v3] tst_fill_fs: enhance the filesystem filling routine X-BeenThere: ltp@lists.linux.it X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux Test Project List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it Sender: "ltp" Do more tries with size in half when write() getting ENOSPC, until the size is less than the filesystem block size. Though we can't really fill a filesystem full, this could make the routine more robust. Signed-off-by: Li Wang Cc: Jan Stancek Cc: Martin Doucha Suggested-by: Cyril Hrubis --- Notes: v2 --> v3 * move the condition judgment into while loop * reserve the print&return part in the loop lib/tst_fill_fs.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/lib/tst_fill_fs.c b/lib/tst_fill_fs.c index 4003dce97..121dd2f20 100644 --- a/lib/tst_fill_fs.c +++ b/lib/tst_fill_fs.c @@ -6,6 +6,7 @@ #include #include #include +#include #define TST_NO_DEFAULT_MAIN #include "tst_test.h" @@ -19,6 +20,8 @@ void tst_fill_fs(const char *path, int verbose) size_t len; ssize_t ret; int fd; + struct statvfs fi; + statvfs(path, &fi); for (;;) { len = random() % (1024 * 102400); @@ -41,6 +44,13 @@ void tst_fill_fs(const char *path, int verbose) ret = write(fd, buf, MIN(len, sizeof(buf))); if (ret < 0) { + /* retry on ENOSPC to make sure filesystem is really full */ + if (errno == ENOSPC && len >= fi.f_bsize/2) { + SAFE_FSYNC(fd); + len /= 2; + continue; + } + SAFE_CLOSE(fd); if (errno != ENOSPC)