public inbox for ltp@lists.linux.it
 help / color / mirror / Atom feed
* [LTP] [PATCH] dio_read: fix infinite loop when readsize >= filesize
@ 2026-03-24  8:08 Andrea Cervesato
  2026-03-24  8:20 ` Petr Vorel
  2026-03-24 13:21 ` Cyril Hrubis
  0 siblings, 2 replies; 5+ messages in thread
From: Andrea Cervesato @ 2026-03-24  8:08 UTC (permalink / raw)
  To: Linux Test Project

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>


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

^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2026-03-24 13:21 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-03-24  8:08 [LTP] [PATCH] dio_read: fix infinite loop when readsize >= filesize Andrea Cervesato
2026-03-24  8:20 ` Petr Vorel
2026-03-24  9:08   ` Andrea Cervesato via ltp
2026-03-24 13:09   ` Andrea Cervesato via ltp
2026-03-24 13:21 ` Cyril Hrubis

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox