* [LTP] [PATCH v1] Fix dio_append/aiodio_append tests
@ 2024-01-30 10:33 Andrea Cervesato
2024-01-30 10:35 ` Andrea Cervesato via ltp
2024-01-30 12:09 ` Cyril Hrubis
0 siblings, 2 replies; 4+ messages in thread
From: Andrea Cervesato @ 2024-01-30 10:33 UTC (permalink / raw)
To: ltp
From: Andrea Cervesato <andrea.cervesato@suse.com>
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.
Signed-off-by: Andrea Cervesato <andrea.cervesato@suse.com>
---
testcases/kernel/io/ltp-aiodio/common.h | 12 ++++++++++--
testcases/kernel/io/ltp-aiodio/dio_append.c | 4 ++--
2 files changed, 12 insertions(+), 4 deletions(-)
diff --git a/testcases/kernel/io/ltp-aiodio/common.h b/testcases/kernel/io/ltp-aiodio/common.h
index 200bbe18e..9a2d27166 100644
--- a/testcases/kernel/io/ltp-aiodio/common.h
+++ b/testcases/kernel/io/ltp-aiodio/common.h
@@ -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());
diff --git a/testcases/kernel/io/ltp-aiodio/dio_append.c b/testcases/kernel/io/ltp-aiodio/dio_append.c
index 057ae73d9..bd48a8252 100644
--- a/testcases/kernel/io/ltp-aiodio/dio_append.c
+++ b/testcases/kernel/io/ltp-aiodio/dio_append.c
@@ -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 *[]) {
--
2.35.3
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply related [flat|nested] 4+ messages in thread* Re: [LTP] [PATCH v1] Fix dio_append/aiodio_append tests
2024-01-30 10:33 [LTP] [PATCH v1] Fix dio_append/aiodio_append tests Andrea Cervesato
@ 2024-01-30 10:35 ` Andrea Cervesato via ltp
2024-01-30 12:09 ` Cyril Hrubis
1 sibling, 0 replies; 4+ messages in thread
From: Andrea Cervesato via ltp @ 2024-01-30 10:35 UTC (permalink / raw)
To: Andrea Cervesato, ltp
Hi,
On 1/30/24 11:33, Andrea Cervesato wrote:
> From: Andrea Cervesato <andrea.cervesato@suse.com>
>
> 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.
> Signed-off-by: Andrea Cervesato <andrea.cervesato@suse.com>
> ---
> testcases/kernel/io/ltp-aiodio/common.h | 12 ++++++++++--
> testcases/kernel/io/ltp-aiodio/dio_append.c | 4 ++--
> 2 files changed, 12 insertions(+), 4 deletions(-)
>
> diff --git a/testcases/kernel/io/ltp-aiodio/common.h b/testcases/kernel/io/ltp-aiodio/common.h
> index 200bbe18e..9a2d27166 100644
> --- a/testcases/kernel/io/ltp-aiodio/common.h
> +++ b/testcases/kernel/io/ltp-aiodio/common.h
> @@ -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());
>
> diff --git a/testcases/kernel/io/ltp-aiodio/dio_append.c b/testcases/kernel/io/ltp-aiodio/dio_append.c
> index 057ae73d9..bd48a8252 100644
> --- a/testcases/kernel/io/ltp-aiodio/dio_append.c
> +++ b/testcases/kernel/io/ltp-aiodio/dio_append.c
> @@ -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 *[]) {
Thanks,
Andrea
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: [LTP] [PATCH v1] Fix dio_append/aiodio_append tests
2024-01-30 10:33 [LTP] [PATCH v1] Fix dio_append/aiodio_append tests Andrea Cervesato
2024-01-30 10:35 ` Andrea Cervesato via ltp
@ 2024-01-30 12:09 ` Cyril Hrubis
2024-01-30 12:18 ` Cyril Hrubis
1 sibling, 1 reply; 4+ messages in thread
From: Cyril Hrubis @ 2024-01-30 12:09 UTC (permalink / raw)
To: Andrea Cervesato; +Cc: ltp
Hi!
> diff --git a/testcases/kernel/io/ltp-aiodio/dio_append.c b/testcases/kernel/io/ltp-aiodio/dio_append.c
> index 057ae73d9..bd48a8252 100644
> --- a/testcases/kernel/io/ltp-aiodio/dio_append.c
> +++ b/testcases/kernel/io/ltp-aiodio/dio_append.c
> @@ -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.
> 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 *[]) {
> --
> 2.35.3
>
>
> --
> Mailing list info: https://lists.linux.it/listinfo/ltp
--
Cyril Hrubis
chrubis@suse.cz
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: [LTP] [PATCH v1] Fix dio_append/aiodio_append tests
2024-01-30 12:09 ` Cyril Hrubis
@ 2024-01-30 12:18 ` Cyril Hrubis
0 siblings, 0 replies; 4+ messages in thread
From: Cyril Hrubis @ 2024-01-30 12:18 UTC (permalink / raw)
To: Andrea Cervesato; +Cc: ltp
Hi!
> > 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.
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.
--
Cyril Hrubis
chrubis@suse.cz
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2024-01-30 12:18 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-01-30 10:33 [LTP] [PATCH v1] Fix dio_append/aiodio_append tests Andrea Cervesato
2024-01-30 10:35 ` Andrea Cervesato via ltp
2024-01-30 12:09 ` Cyril Hrubis
2024-01-30 12:18 ` Cyril Hrubis
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox