[LTP] [PATCH v4] Refactoring aiodio_sparse.c using LTP API

Cyril Hrubis chrubis@suse.cz
Tue Feb 22 13:46:23 CET 2022


Hi!
Pushed with a few changes, thanks.

I've mainly added a few elements to the tst_test structure to match the
fixes we did for dio_sparse.c and also removed a few obvious comments.


diff --git a/testcases/kernel/io/ltp-aiodio/aiodio_sparse.c b/testcases/kernel/io/ltp-aiodio/aiodio_sparse.c
index 33a25a28c..2aa5662bb 100644
--- a/testcases/kernel/io/ltp-aiodio/aiodio_sparse.c
+++ b/testcases/kernel/io/ltp-aiodio/aiodio_sparse.c
@@ -35,10 +35,10 @@ static char *str_writesize;
 static char *str_filesize;
 static char *str_numaio;
 
-static int numchildren = 1000;
+static int numchildren = 16;
 static long long writesize = 1024;
 static long long filesize = 100 * 1024 * 1024;
-static long long alignment = 512;
+static long long alignment;
 static int numaio = 16;
 
 static void check_event(struct io_event event)
@@ -76,9 +76,6 @@ static void aiodio_sparse(char *filename, long long align, long long ws,
 	for (i = 0; i < naio; i++)
 		iocbs[i] = iocb + i;
 
-	/*
-	 * allocate the iocbs array and iocbs with buffers
-	 */
 	offset = 0;
 	for (i = 0; i < naio; i++) {
 		void *bufptr;
@@ -89,16 +86,10 @@ static void aiodio_sparse(char *filename, long long align, long long ws,
 		offset += ws;
 	}
 
-	/*
-	 * start the 1st naio write requests
-	 */
 	w = io_submit(myctx, naio, iocbs);
 	if (w < 0)
 		tst_brk(TBROK, "io_submit: %s", tst_strerrno(-w));
 
-	/*
-	 * As AIO requests finish, keep issuing more AIO until done.
-	 */
 	aio_inflight = naio;
 
 	while (offset < fs) {
@@ -129,9 +120,6 @@ static void aiodio_sparse(char *filename, long long align, long long ws,
 		aio_inflight++;
 	}
 
-	/*
-	 * wait for AIO requests in flight.
-	 */
 	while (aio_inflight > 0) {
 		int n;
 
@@ -175,8 +163,7 @@ static void setup(void)
 	if ((numaio * writesize) > filesize) {
 		numaio = filesize / writesize;
 		tst_res(TINFO,
-			"Numbers of AIO have been reduced to %d so we fit "
-			"filesize",
+			"Numbers of AIO have been reduced to %d so we fit filesize",
 			numaio);
 	}
 
@@ -192,8 +179,10 @@ static void setup(void)
 
 static void cleanup(void)
 {
-	*run_child = 0;
-	SAFE_MUNMAP(run_child, sizeof(int));
+	if (run_child) {
+		*run_child = 0;
+		SAFE_MUNMAP(run_child, sizeof(int));
+	}
 }
 
 static void run(void)
@@ -230,12 +219,17 @@ static struct tst_test test = {
 	.needs_tmpdir = 1,
 	.forks_child = 1,
 	.options = (struct tst_option[]) {
-		{"n:", &str_numchildren, "Number of threads (default 1000)"},
+		{"n:", &str_numchildren, "Number of threads (default 16)"},
 		{"w:", &str_writesize, "Size of writing blocks (default 1K)"},
 		{"s:", &str_filesize, "Size of file (default 100M)"},
 		{"o:", &str_numaio, "Number of AIO control blocks (default 16)"},
 		{},
 	},
+	.skip_filesystems = (const char *[]) {
+		"tmpfs",
+		NULL
+	},
+	.timeout = 1800,
 };
 #else
 TST_TEST_TCONF("test requires libaio and its development packages");

-- 
Cyril Hrubis
chrubis@suse.cz


More information about the ltp mailing list