[LTP] [PATCH] dio_read: fix infinite loop when readsize >= filesize
Andrea Cervesato
andrea.cervesato@suse.de
Tue Mar 24 09:08:00 CET 2026
From: Andrea Cervesato <andrea.cervesato@suse.com>
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.
Signed-off-by: Andrea Cervesato <andrea.cervesato@suse.com>
---
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(-)
diff --git a/testcases/kernel/io/ltp-aiodio/dio_read.c b/testcases/kernel/io/ltp-aiodio/dio_read.c
index 1c913cc2b814e3f6b0673b8926ffce526eb27655..8d1b8adf675e8fa2136b972c18007b2a60dab36a 100644
--- a/testcases/kernel/io/ltp-aiodio/dio_read.c
+++ b/testcases/kernel/io/ltp-aiodio/dio_read.c
@@ -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,
--
Andrea Cervesato <andrea.cervesato@suse.com>
More information about the ltp
mailing list