[LTP] [PATCH v1] aiocp: Filter out O_DIRECT before read

Ping Fang pifang@redhat.com
Thu Feb 9 10:03:07 CET 2023


When aiocp executed with -f DIRECT will fail.

<<<test_start>>>
tag=AD049 stime=1675520824
cmdline="aiocp -b 8k -n 8 -f DIRECT"
contacts=""
analysis=exit
<<<test_output>>>
tst_test.c:1560: TINFO: Timeout per run is 0h 30m 30s
aiocp.c:211: TINFO: Maximum AIO blocks: 65536
tst_device.c:585: TINFO: Use uevent strategy
aiocp.c:250: TINFO: Fill srcfile.bin with random data
aiocp.c:279: TINFO: Copy srcfile.bin -> dstfile.bin
aiocp.c:291: TINFO: Comparing srcfile.bin with dstfile.bin
aiocp.c:306: TBROK: read(3,0x7ffcd743abe0,4096) failed, returned -1: EINVAL (22)
...

syscall read manual ERROR section said that:
EINVAL fd  is  attached to an object which is unsuitable for reading;
or the file was opened with the O_DIRECT flag, and either the address
specified in buf, the value specified in  count, or the file offset is
not suitably aligned.

We need filter out O_DIRECT flag before read.

Signed-off-by: Ping Fang <pifang@redhat.com>
---
 testcases/kernel/io/ltp-aiodio/aiocp.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/testcases/kernel/io/ltp-aiodio/aiocp.c b/testcases/kernel/io/ltp-aiodio/aiocp.c
index bc0e209b2..e4252d641 100644
--- a/testcases/kernel/io/ltp-aiodio/aiocp.c
+++ b/testcases/kernel/io/ltp-aiodio/aiocp.c
@@ -297,8 +297,8 @@ static void run(void)
 		return;
 	}
 
-	srcfd = SAFE_OPEN(srcname, srcflags | O_RDONLY, 0666);
-	dstfd = SAFE_OPEN(dstname, srcflags | O_RDONLY, 0666);
+	srcfd = SAFE_OPEN(srcname, (srcflags & ~O_DIRECT) | O_RDONLY, 0666);
+	dstfd = SAFE_OPEN(dstname, (srcflags & ~O_DIRECT) | O_RDONLY, 0666);
 
 	reads = howmany(filesize, buffsize);
 
-- 
2.31.1



More information about the ltp mailing list