[LTP] [PATCH v2] aio02: Drop O_DIRECT flag for tmpfs

Yang Xu xuyang2018.jy@cn.fujitsu.com
Wed Feb 12 08:31:55 CET 2020


tmpfs doesn't support O_DIRECT flag, drop it. userer still can run aio02
with different filesystem by mounting specified filesystem on $TMPDIR.

Signed-off-by: Yang Xu <xuyang2018.jy@cn.fujitsu.com>
---
 testcases/kernel/io/aio/aio02.c | 15 ++++++++++++++-
 1 file changed, 14 insertions(+), 1 deletion(-)

diff --git a/testcases/kernel/io/aio/aio02.c b/testcases/kernel/io/aio/aio02.c
index e283afba9..3bb89c45f 100644
--- a/testcases/kernel/io/aio/aio02.c
+++ b/testcases/kernel/io/aio/aio02.c
@@ -18,7 +18,8 @@
 #define AIO_MAXIO 32
 #define AIO_BLKSIZE (64*1024)
 
-static int wait_count = 0;
+static int wait_count;
+static unsigned int use_tmpfs;
 
 #define DESC_FLAGS_OPR(x, y) .desc = (x == IO_CMD_PWRITE ? "WRITE: " #y: "READ : " #y), \
 	.flags = y, .operation = x
@@ -206,6 +207,11 @@ static void test_io(unsigned int n)
 	int status;
 	struct testcase *tc = testcases + n;
 
+	if (use_tmpfs && (tc->flags & O_DIRECT)) {
+		tst_res(TINFO, "Drop O_DIRECT flag for tmpfs");
+		tc->flags &= (~O_DIRECT);
+	}
+
 	status = io_tio("file", tc->flags, tc->operation);
 	if (status)
 		tst_res(TFAIL, "%s, status = %d", tc->desc, status);
@@ -213,7 +219,14 @@ static void test_io(unsigned int n)
 		tst_res(TPASS, "%s", tc->desc);
 }
 
+static void setup(void)
+{
+	if (tst_fs_type(".") == TST_TMPFS_MAGIC)
+		use_tmpfs = 1;
+}
+
 static struct tst_test test = {
+	.setup = setup,
 	.needs_tmpdir = 1,
 	.test = test_io,
 	.tcnt = ARRAY_SIZE(testcases),
-- 
2.18.0





More information about the ltp mailing list