[LTP] [PATCH v2] Refactoring mmap16.c test using new LTP API

Cyril Hrubis chrubis@suse.cz
Wed Feb 16 13:12:17 CET 2022


Hi!
Pushed with a minor changes, thanks.

The biggest issue was that the original test did run the actuall test 10
times, my guess that it was to make sure that we are able to reproduce
the issue. The rest of the changes is cosmetic, such as better
description and code formatting.

Full diff:

diff --git a/testcases/kernel/syscalls/mmap/mmap16.c b/testcases/kernel/syscalls/mmap/mmap16.c
index a892051ac..cb146d120 100644
--- a/testcases/kernel/syscalls/mmap/mmap16.c
+++ b/testcases/kernel/syscalls/mmap/mmap16.c
@@ -7,9 +7,22 @@
 /*\
  * [Description]
  *
- * This is a regression test for commits:
- * https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=0572639ff66dcffe62d37adfe4c4576f9fc398f4
- * https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=d6320cbfc92910a3e5f10c42d98c231c98db4f60
+ * This is a regression test for a silent data corruption for a mmaped file
+ * when filesystem gets out of space.
+ *
+ * Fixed by commits:
+ *
+ *  commit 0572639ff66dcffe62d37adfe4c4576f9fc398f4
+ *  Author: Xiaoguang Wang <wangxg.fnst@cn.fujitsu.com>
+ *  Date:   Thu Feb 12 23:00:17 2015 -0500
+ *
+ *      ext4: fix mmap data corruption in nodelalloc mode when blocksize < pagesize
+ *
+ *  commit d6320cbfc92910a3e5f10c42d98c231c98db4f60
+ *  Author: Jan Kara <jack@suse.cz>
+ *  Date:   Wed Oct 1 21:49:46 2014 -0400
+ *
+ *      ext4: fix mmap data corruption when blocksize < pagesize
  */
 
 #define _GNU_SOURCE
@@ -25,8 +38,8 @@
 #define FILE_PARENT "mntpoint/testfilep"
 #define FILE_CHILD "mntpoint/testfilec"
 #define FS_BLOCKSIZE 1024
+#define LOOPS 10
 
-static int page_size;
 static int parentfd = -1;
 static int childfd = -1;
 
@@ -83,7 +96,7 @@ static void do_child(void)
 	exit(1);
 }
 
-static void run(void)
+static void run_single(void)
 {
 	int ret, status;
 	pid_t child;
@@ -138,6 +151,14 @@ static void run(void)
 		tst_res(TPASS, "bug is not reproduced");
 }
 
+static void run(void)
+{
+	int i;
+
+	for (i = 0; i < LOOPS; i++)
+		run_single();
+}
+
 static void cleanup(void)
 {
 	if (childfd >= 0)
@@ -154,32 +175,25 @@ static struct tst_test test = {
 	.needs_root = 1,
 	.needs_device = 1,
 	.needs_checkpoints = 1,
-	.needs_tmpdir = 1,
 	.mount_device = 1,
 	.mntpoint = MNTPOINT,
 	.dev_fs_type = "ext4",
-	.dev_fs_opts =
-		(const char *const[]){
-			"-b",
-			"1024",
-			NULL,
-		},
-	.dev_extra_opts =
-		(const char *const[]){
-			"10240",
-			NULL,
-		},
-	.needs_cmds =
-		(const char *const[]){
-			"mkfs.ext4",
-			NULL,
-		},
-	.tags =
-		(const struct tst_tag[]){
-			{ "linux-git",
-			  "d6320cbfc92910a3e5f10c42d98c231c98db4f60" },
-			{ "linux-git",
-			  "0572639ff66dcffe62d37adfe4c4576f9fc398f4" },
-			{},
-		},
+	.dev_fs_opts = (const char *const[]){
+		"-b",
+		"1024",
+		NULL,
+	},
+	.dev_extra_opts = (const char *const[]){
+		"10240",
+		NULL,
+	},
+	.needs_cmds = (const char *const[]){
+		"mkfs.ext4",
+		NULL,
+	},
+	.tags = (const struct tst_tag[]){
+		{"linux-git", "d6320cbfc929"},
+		{"linux-git", "0572639ff66d"},
+		{},
+	},
 };

-- 
Cyril Hrubis
chrubis@suse.cz


More information about the ltp mailing list