[LTP] [PATCH 2/2] syscalls/acct02: Fix failures with nearly full FS

Cyril Hrubis chrubis@suse.cz
Fri Jul 12 16:15:30 CEST 2019


While process accounting is running the kernel checks the percentage of
available space on disk. If the accounting is enabled and the free space
drops below 2% the accounting is disabled until we reach at least 4% of
free space. Which especially means that we have to have more than 4% of
free space when we start the accounting because we are starting in
disabled state. And when accounting is disabled the data are dropped
silently instead of being written to the file, which makes this test
fail because we end up with an empty file.

So this patch checks if there is at least 4.1% of free space before we
start the test and exit with TCONF otherwise.

Signed-off-by: Cyril Hrubis <chrubis@suse.cz>
CC: Christian Amann <camann@suse.com>
---
 testcases/kernel/syscalls/acct/acct02.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/testcases/kernel/syscalls/acct/acct02.c b/testcases/kernel/syscalls/acct/acct02.c
index f61faf206..6c375d5cb 100644
--- a/testcases/kernel/syscalls/acct/acct02.c
+++ b/testcases/kernel/syscalls/acct/acct02.c
@@ -146,8 +146,20 @@ static void run(void)
 
 static void setup(void)
 {
+	struct statfs buf;
+
 	clock_ticks = SAFE_SYSCONF(_SC_CLK_TCK);
 
+	SAFE_STATFS(".", &buf);
+
+	float avail = (100.00 * buf.f_bavail) / buf.f_blocks;
+
+	if (avail < 4.1) {
+		tst_brk(TCONF,
+			"Less than 4.1%% (%.2f) of free space on filesystem",
+			avail);
+	}
+
 	TEST(acct(NULL));
 	if (TST_RET == -1)
 		tst_brk(TBROK | TTERRNO,
-- 
2.21.0



More information about the ltp mailing list