Skip to contentSkip to conversation

Fix dio_append/aiodio_append tests

PATCH Superseded Andrea Cervesato 3 participants 4 messages Jan 30, 2024

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Fix dio_append/aiodio_append tests

From: Andrea Cervesato <[email protected]>

Ensure that dio_append and aiodio_append will end all children if parent asked for it. The way we have to do it, is to ensure that *run_child variable is checked before opening the file to read.

---
 testcases/kernel/io/ltp-aiodio/common.h     | 12 ++++++++++--
 testcases/kernel/io/ltp-aiodio/dio_append.c |  4 ++--
 2 files changed, 12 insertions(+), 4 deletions(-)
testcases/kernel/io/ltp-aiodio/common.h +10 -2
index 200bbe18e..9a2d27166 100644
@@ -62,8 +62,12 @@ static inline void io_read(const char *filename, int filesize, volatile int *run
 	int i;
 	int r;
 
-	while ((fd = open(filename, O_RDONLY, 0666)) < 0)
+	while ((fd = open(filename, O_RDONLY, 0666)) < 0) {
+		if (!*run_child)
+			return;
+
 		usleep(100);
+	}
 
 	tst_res(TINFO, "child %i reading file", getpid());
 
@@ -102,8 +106,12 @@ static inline void io_read_eof(const char *filename, volatile int *run_child)
 	int fd;
 	int r;
 
-	while ((fd = open(filename, O_RDONLY, 0666)) < 0)
+	while ((fd = open(filename, O_RDONLY, 0666)) < 0) {
+		if (!*run_child)
+			return;
+
 		usleep(100);
+	}
 
 	tst_res(TINFO, "child %i reading file", getpid());
 
testcases/kernel/io/ltp-aiodio/dio_append.c +2 -2
index 057ae73d9..bd48a8252 100644
@@ -33,7 +33,7 @@ static void setup(void)
 {
 	numchildren = 16;
 	writesize = 64 * 1024;
-	appends = 1000;
+	appends = 10000;
 
 	if (tst_parse_int(str_numchildren, &numchildren, 1, INT_MAX))
 		tst_brk(TBROK, "Invalid number of children '%s'", str_numchildren);
@@ -97,7 +97,7 @@ static struct tst_test test = {
 	.options = (struct tst_option[]) {
 		{"n:", &str_numchildren, "Number of processes (default 16)"},
 		{"w:", &str_writesize, "Write size for each append (default 64K)"},
-		{"c:", &str_appends, "Number of appends (default 1000)"},
+		{"c:", &str_appends, "Number of appends (default 10000)"},
 		{}
 	},
 	.skip_filesystems = (const char *[]) {
Signature · 5 lines
2.35.3


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
#1 lore raw

Hi,

Quoted 5 lines · Andrea Cervesato

From: Andrea Cervesato <[email protected]>

Ensure that dio_append and aiodio_append will end all children if parent asked for it. The way we have to do it, is to ensure that *run_child variable is checked before opening the file to read.

If you can please mention that append has been increased by 10000 in dio_append, once patch is merged.

Quoted 52 lines
---
  testcases/kernel/io/ltp-aiodio/common.h     | 12 ++++++++++--
  testcases/kernel/io/ltp-aiodio/dio_append.c |  4 ++--
  2 files changed, 12 insertions(+), 4 deletions(-)
testcases/kernel/io/ltp-aiodio/common.h +10 -2
index 200bbe18e..9a2d27166 100644
@@ -62,8 +62,12 @@ static inline void io_read(const char *filename, int filesize, volatile int *run
  	int i;
  	int r;
 
-	while ((fd = open(filename, O_RDONLY, 0666)) < 0)
+	while ((fd = open(filename, O_RDONLY, 0666)) < 0) {
+		if (!*run_child)
+			return;
+
  		usleep(100);
+	}
 
  	tst_res(TINFO, "child %i reading file", getpid());
 
@@ -102,8 +106,12 @@ static inline void io_read_eof(const char *filename, volatile int *run_child)
  	int fd;
  	int r;
 
-	while ((fd = open(filename, O_RDONLY, 0666)) < 0)
+	while ((fd = open(filename, O_RDONLY, 0666)) < 0) {
+		if (!*run_child)
+			return;
+
  		usleep(100);
+	}
 
  	tst_res(TINFO, "child %i reading file", getpid());
 
testcases/kernel/io/ltp-aiodio/dio_append.c +1 -1
index 057ae73d9..bd48a8252 100644
@@ -33,7 +33,7 @@ static void setup(void)
  {
  	numchildren = 16;
  	writesize = 64 * 1024;
-	appends = 1000;
+	appends = 10000;
 
  	if (tst_parse_int(str_numchildren, &numchildren, 1, INT_MAX))
  		tst_brk(TBROK, "Invalid number of children '%s'", str_numchildren);

testcases/kernel/io/ltp-aiodio/dio_append.c static struct tst_test test = { · line 103

Quoted 8 lines
testcases/kernel/io/ltp-aiodio/dio_append.c +1 -1
@@ -97,7 +97,7 @@ static struct tst_test test = {
  	.options = (struct tst_option[]) {
  		{"n:", &str_numchildren, "Number of processes (default 16)"},
  		{"w:", &str_writesize, "Write size for each append (default 64K)"},
-		{"c:", &str_appends, "Number of appends (default 1000)"},
+		{"c:", &str_appends, "Number of appends (default 10000)"},
  		{}
  	},
  	.skip_filesystems = (const char *[]) {

Thanks,

Andrea

Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
#2 lore raw
In reply to Andrea Cervesato

Hi!

testcases/kernel/io/ltp-aiodio/dio_append.c static void setup(void) · line 36

Quoted 10 lines
testcases/kernel/io/ltp-aiodio/dio_append.c +1 -1
index 057ae73d9..bd48a8252 100644
@@ -33,7 +33,7 @@ static void setup(void)
 {
 	numchildren = 16;
 	writesize = 64 * 1024;
-	appends = 1000;
+	appends = 10000;

Since we are increasing this we should probably check the free space as well, so we should add something as:

	if (!tst_fs_has_free(".", appends, writesize))
		tst_brk(TCONF, "Not enough space to run the test");

Or even better put a function:

void tst_assert_free_space(const char *path, unsigned int size, unsigned int mult)

into the test library and this function would tst_brk(TCONF, ) if there is not enough space and tst_res(TWARN, ) if the free space is let's say only 10% more than the test would need to run. And we can use that in all of these tests.

Quoted 17 lines
testcases/kernel/io/ltp-aiodio/dio_append.c +1 -1
 	if (tst_parse_int(str_numchildren, &numchildren, 1, INT_MAX))
 		tst_brk(TBROK, "Invalid number of children '%s'", str_numchildren);
@@ -97,7 +97,7 @@ static struct tst_test test = {
 	.options = (struct tst_option[]) {
 		{"n:", &str_numchildren, "Number of processes (default 16)"},
 		{"w:", &str_writesize, "Write size for each append (default 64K)"},
-		{"c:", &str_appends, "Number of appends (default 1000)"},
+		{"c:", &str_appends, "Number of appends (default 10000)"},
 		{}
 	},
 	.skip_filesystems = (const char *[]) {
Signature · 5 lines
2.35.3


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
Signature · 5 lines
Cyril Hrubis
[email protected]

-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
#3 lore raw

Hi!

Quoted 11 lines

testcases/kernel/io/ltp-aiodio/dio_append.c static void setup(void) · line 36

Quoted 4 lines
testcases/kernel/io/ltp-aiodio/dio_append.c +1 -1
 	numchildren = 16;
 	writesize = 64 * 1024;
-	appends = 1000;
+	appends = 10000;

Since we are increasing this we should probably check the free space as well, so we should add something as:

	if (!tst_fs_has_free(".", appends, writesize))
		tst_brk(TCONF, "Not enough space to run the test");
Quoted 8 lines

Or even better put a function:

void tst_assert_free_space(const char *path, unsigned int size, unsigned int mult)

into the test library and this function would tst_brk(TCONF, ) if there is not enough space and tst_res(TWARN, ) if the free space is let's say only 10% more than the test would need to run. And we can use that in all of these tests.

Also this can be done in a follow up patch. I guess that the cleanest option would be to split the patch into two, one that fixes the race condition, that one should go in ASAP. And second that raises the appended file size followed by a patch to check for a free space.

Signature · 5 lines
Cyril Hrubis
[email protected]

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