public inbox for ltp@lists.linux.it
 help / color / mirror / Atom feed
* [LTP] [PATCH v1] fs_fill_btrfs: btrfs fs_fill test set mkfs.btrfs -s 4k
@ 2023-12-18 13:11 Wei Gao via ltp
  2024-01-30 12:23 ` Petr Vorel
  0 siblings, 1 reply; 2+ messages in thread
From: Wei Gao via ltp @ 2023-12-18 13:11 UTC (permalink / raw)
  To: ltp

On PPC64 the page size is 64K and this causes trouble on btrfs
filesystems of small size(LTP currently use 300M), the threads
could compete for a very small number of pages/blocks to actually
write the data. So force the test case with sector size 4k.
e.g. mkfs.btrfs -s 4k

Signed-off-by: Wei Gao <wegao@suse.com>
---
 runtest/fs                                  |   1 +
 testcases/kernel/fs/fs_fill/fs_fill.c       |   4 +
 testcases/kernel/fs/fs_fill/fs_fill_btrfs.c | 134 ++++++++++++++++++++
 3 files changed, 139 insertions(+)
 create mode 100644 testcases/kernel/fs/fs_fill/fs_fill_btrfs.c

diff --git a/runtest/fs b/runtest/fs
index 1d753e0dd..3649a1a82 100644
--- a/runtest/fs
+++ b/runtest/fs
@@ -82,6 +82,7 @@ quota_remount_test01 quota_remount_test01.sh
 isofs isofs.sh
 
 fs_fill fs_fill
+fs_fill_btrfs fs_fill_btrfs
 
 binfmt_misc01 binfmt_misc01.sh
 binfmt_misc02 binfmt_misc02.sh
diff --git a/testcases/kernel/fs/fs_fill/fs_fill.c b/testcases/kernel/fs/fs_fill/fs_fill.c
index 2ecd8e2ad..4dcc6d3b6 100644
--- a/testcases/kernel/fs/fs_fill/fs_fill.c
+++ b/testcases/kernel/fs/fs_fill/fs_fill.c
@@ -129,5 +129,9 @@ static struct tst_test test = {
 	.setup = setup,
 	.cleanup = cleanup,
 	.test = testrun,
+	.skip_filesystems = (const char *[]) {
+		"btrfs",
+		NULL
+	},
 	.tcnt = 2
 };
diff --git a/testcases/kernel/fs/fs_fill/fs_fill_btrfs.c b/testcases/kernel/fs/fs_fill/fs_fill_btrfs.c
new file mode 100644
index 000000000..315d283a4
--- /dev/null
+++ b/testcases/kernel/fs/fs_fill/fs_fill_btrfs.c
@@ -0,0 +1,134 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+/*
+ * Copyright (c) 2017 Cyril Hrubis <chrubis@suse.cz>
+ */
+
+/*
+ * Runs several threads that fills up the filesystem repeatedly.
+ */
+
+#define _GNU_SOURCE
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <errno.h>
+#include <fcntl.h>
+#include <pthread.h>
+#include "tst_safe_pthread.h"
+#include "tst_test.h"
+
+#define MNTPOINT "mntpoint"
+#define THREADS_DIR MNTPOINT "/subdir"
+
+static volatile int run;
+static unsigned int nthreads;
+static int enospc_cnt;
+static struct worker *workers;
+
+struct worker {
+	enum tst_fill_access_pattern pattern;
+	char dir[PATH_MAX];
+};
+
+static void *worker(void *p)
+{
+	struct worker *w = p;
+	DIR *d;
+	struct dirent *ent;
+	char file[PATH_MAX];
+
+	while (run) {
+		tst_fill_fs(w->dir, 1, w->pattern);
+
+		tst_atomic_inc(&enospc_cnt);
+
+		d = SAFE_OPENDIR(w->dir);
+		while ((ent = SAFE_READDIR(d))) {
+
+			if (!strcmp(ent->d_name, ".") ||
+			    !strcmp(ent->d_name, ".."))
+				continue;
+
+			snprintf(file, sizeof(file), "%s/%s",
+				 w->dir, ent->d_name);
+
+			tst_res(TINFO, "Unlinking %s", file);
+
+			SAFE_UNLINK(file);
+			break;
+		}
+		SAFE_CLOSEDIR(d);
+	}
+
+	return NULL;
+}
+
+static void testrun(unsigned int n)
+{
+	pthread_t threads[nthreads];
+	unsigned int i, ms;
+
+	tst_atomic_store(0, &enospc_cnt);
+
+	run = 1;
+	for (i = 0; i < nthreads; i++) {
+		workers[i].pattern = n;
+		SAFE_PTHREAD_CREATE(&threads[i], NULL, worker, &workers[i]);
+	}
+
+	for (ms = 0; ; ms++) {
+		usleep(1000);
+
+		if (ms >= 1000 && tst_atomic_load(&enospc_cnt))
+			break;
+
+		if (tst_atomic_load(&enospc_cnt) > 100)
+			break;
+	}
+
+	run = 0;
+	for (i = 0; i < nthreads; i++)
+		SAFE_PTHREAD_JOIN(threads[i], NULL);
+
+	tst_res(TPASS, "Got %i ENOSPC runtime %ims", enospc_cnt, ms);
+}
+
+static void setup(void)
+{
+	unsigned int i;
+
+	nthreads = tst_ncpus_conf() + 2;
+	workers = SAFE_MALLOC(sizeof(struct worker) * nthreads);
+
+	/*
+	 * Avoid creating the thread directories in the root of the filesystem
+	 * to not hit the root entries limit on a FAT16 filesystem.
+	 */
+	SAFE_MKDIR(THREADS_DIR, 0700);
+
+	for (i = 0; i < nthreads; i++) {
+		snprintf(workers[i].dir, sizeof(workers[i].dir),
+			 THREADS_DIR "/thread%i", i + 1);
+		SAFE_MKDIR(workers[i].dir, 0700);
+	}
+
+	tst_res(TINFO, "Running %i writer threads", nthreads);
+}
+
+static void cleanup(void)
+{
+	free(workers);
+}
+
+static struct tst_test test = {
+	.max_runtime = 60,
+	.needs_root = 1,
+	.mount_device = 1,
+	.mntpoint = MNTPOINT,
+	.dev_fs_opts = (const char *const[]){"-s 4k", NULL},
+	.dev_fs_type = "btrfs",
+	.setup = setup,
+	.cleanup = cleanup,
+	.test = testrun,
+	.tcnt = 2
+};
-- 
2.35.3


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [LTP] [PATCH v1] fs_fill_btrfs: btrfs fs_fill test set mkfs.btrfs -s 4k
  2023-12-18 13:11 [LTP] [PATCH v1] fs_fill_btrfs: btrfs fs_fill test set mkfs.btrfs -s 4k Wei Gao via ltp
@ 2024-01-30 12:23 ` Petr Vorel
  0 siblings, 0 replies; 2+ messages in thread
From: Petr Vorel @ 2024-01-30 12:23 UTC (permalink / raw)
  To: Wei Gao; +Cc: ltp

Hi,

> On PPC64 the page size is 64K and this causes trouble on btrfs
> filesystems of small size(LTP currently use 300M), the threads
> could compete for a very small number of pages/blocks to actually
> write the data. So force the test case with sector size 4k.
> e.g. mkfs.btrfs -s 4k

there were other fixes merged, therefore closing this.

7d39a10b7 ("fs_fill: Increase timeout to 5 min")
848dd6fba ("fs_fill: Increase test loop device size to 1GB")

Kind regards,
Petr

-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2024-01-30 12:23 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-12-18 13:11 [LTP] [PATCH v1] fs_fill_btrfs: btrfs fs_fill test set mkfs.btrfs -s 4k Wei Gao via ltp
2024-01-30 12:23 ` Petr Vorel

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox