dio_read: fix infinite loop when readsize >= filesize
PATCH 1/1 dio_read: fix infinite loop when readsize >= filesize
From: Andrea Cervesato <[email protected]>
The do_direct_reads() function had exit conditions inside the inner for loop. When readsize >= filesize, the for loop condition is never true, causing the while(1) loop to spin infinitely without checking if writers completed or runtime expired.
Move the exit condition checks outside the for loop to ensure they are evaluated on every iteration, regardless of readsize/filesize parameters.
---
There's a sporadic failure in DOR000 that causes test to loop indefinetly under s390x. This patch tries to fix the issue by ensuring test will check runtime and if children completed.
--- testcases/kernel/io/ltp-aiodio/dio_read.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-)
testcases/kernel/io/ltp-aiodio/dio_read.c +12 -12
@@ -66,20 +66,20 @@ static int do_direct_reads(char *filename, char *bufptr, long long fsize, long l fd =SAFE_OPEN (filename,O_RDONLY |O_DIRECT ,0666 );while (1 ) { -for (offset =0 ; offset + rsize < fsize; offset += rsize) { -char *bufoff; +if (*children_completed >= numchildren) { +tst_res (TINFO , +"Writers finshed, exiting reader (iteration %i)" , + iter); + goto exit; + } -if (*children_completed >= numchildren) { -tst_res (TINFO , -"Writers finshed, exiting reader (iteration %i)" , - iter); - goto exit; - } +if (!tst_remaining_runtime ()) { +tst_res (TINFO ,"Test out of runtime, exiting" ); + goto exit; + } -if (!tst_remaining_runtime ()) { -tst_res (TINFO ,"Test out of runtime, exiting" ); - goto exit; - } +for (offset =0 ; offset + rsize < fsize; offset += rsize) { +char *bufoff; w =pread (fd, bufptr, rsize, offset);if (w <0 )
---
base-commit: 475f2dbdce80cca84caf408c910cf4da4779d5a8
change-id: 20260324-fix_dio_read-31b9148b1c98
Best regards,
Signature · 5 lines
Andrea Cervesato <[email protected]> -- Mailing list info: https://lists.linux.it/listinfo/ltp
Hi Andrea,
Quoted 9 lines
The
do_direct_reads()function had exit conditions inside the inner for loop. When readsize >= filesize, the for loop condition is never true, causing the while(1) loop to spin infinitely without checking if writers completed or runtime expired.Move the exit condition checks outside the for loop to ensure they are evaluated on every iteration, regardless of readsize/filesize parameters.
Quoted 5 lines
Signed-off-by Andrea Cervesato <[email protected]>---
There's a sporadic failure in DOR000 that causes test to loop indefinetly under s390x. This patch tries to fix the issue by ensuring test will check runtime and if children completed.
As a fix for indefinite loop LGTM. But why it happen readsize >= filesize? These are related to -r and -s values, but we always use -r 512k -w 512k -s 32M. I wonder why this happen only on s390x? (I'd expect ppc64le which has different page size.
Also that means that pread() is skipped when this happen.
Kind regards,
Petr
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
Hi Petr,
Quoted 6 lines
As a fix for indefinite loop LGTM. But why it happen readsize >= filesize? These are related to -r and -s values, but we always use -r 512k -w 512k -s 32M. I wonder why this happen only on s390x? (I'd expect ppc64le which has different page size.
Also that means that
pread()is skipped when this happen.
I was trying to fix this sporadic failure on s390x and I discovered this bug in the test so I send a patch. As you said, the DOR000 might still fail.
What happens at the moment is that children seem to stuck. This fix should reduce the amount of messages and debug it a bit better. Let's see..
--
Andrea Cervesato
SUSE QE Automation Engineer Linux
[email protected]
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
Thanks for the review.
Merged.
--
Andrea Cervesato
SUSE QE Automation Engineer Linux
[email protected]
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
Hi!
Quoted 8 lines
The
do_direct_reads()function had exit conditions inside the inner for loop. When readsize >= filesize, the for loop condition is never true, causing the while(1) loop to spin infinitely without checking if writers completed or runtime expired.Move the exit condition checks outside the for loop to ensure they are evaluated on every iteration, regardless of readsize/filesize parameters.
I was looking at this when I was rewriting the runtest files and I was wondering why we do not check that filesize <= readsize && filesize <= writesize in the test setup() instead.
Signature · 5 lines
Cyril Hrubis [email protected] -- Mailing list info: https://lists.linux.it/listinfo/ltp