Skip to contentSkip to conversation

aio02: Use mounted filesystem instead of temp directory

PATCH New Yang Xu 3 participants 10 messages Feb 12, 2020 – Feb 13, 2020

lore
Share & tools
lore

Yang Xu

author
#0 lore raw

PATCH 1/1 aio02: Use mounted filesystem instead of temp directory

tmpfs doesn't support O_DIRECT flag, open file with this flag on tmpfs will report EINVAL error. I thin we should test this case on ext2 filesystem instead of temp directory.

---
 testcases/kernel/io/aio/aio02.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)
testcases/kernel/io/aio/aio02.c +6 -3
index e283afba9..205d1b088 100644
@@ -17,7 +17,8 @@
 
 #define AIO_MAXIO 32
 #define AIO_BLKSIZE (64*1024)
-
+#define MNTPOINT   "mnt_point"
+#define FILE_TEST MNTPOINT"/file"
 static int wait_count = 0;
 
 #define DESC_FLAGS_OPR(x, y) .desc = (x == IO_CMD_PWRITE ? "WRITE: " #y: "READ : " #y), \
@@ -206,7 +207,7 @@ static void test_io(unsigned int n)
 	int status;
 	struct testcase *tc = testcases + n;
 
-	status = io_tio("file", tc->flags, tc->operation);
+	status = io_tio(FILE_TEST, tc->flags, tc->operation);
 	if (status)
 		tst_res(TFAIL, "%s, status = %d", tc->desc, status);
 	else
@@ -214,7 +215,9 @@ static void test_io(unsigned int n)
 }
 
 static struct tst_test test = {
-	.needs_tmpdir = 1,
+	.mount_device = 1,
+	.mntpoint = MNTPOINT,
+	.needs_root = 1,
 	.test = test_io,
 	.tcnt = ARRAY_SIZE(testcases),
 };
Signature · 1 line
2.18.0
#1 lore raw

PATCH 1/1 aio02: Use mounted filesystem instead of temp directory

Quoted 3 lines · Yang Xu

tmpfs doesn't support O_DIRECT flag, open file with this flag on tmpfs will report EINVAL error. I thin we should test this case on ext2 filesystem instead of temp directory.

Hi Xu,

Thanks for your quick fix. :-)

I don't want to use the fixed file system to run aio02. I perfer to just drop O_DIRECT flag for tmpfs, as below:
1) Drop O_DIRECT flag for tmpfs.
2) Keep O_DIRECT flag for other filesystem.
In this case, user still can run aio02 with different filesystem by mounting specified filesystem on $TMPDIR.

Best Regards,
Xiao Yang

Quoted 39 lines
---
  testcases/kernel/io/aio/aio02.c | 9 ++++++---
  1 file changed, 6 insertions(+), 3 deletions(-)
testcases/kernel/io/aio/aio02.c +6 -3
index e283afba9..205d1b088 100644
@@ -17,7 +17,8 @@
 
  #define AIO_MAXIO 32
  #define AIO_BLKSIZE (64*1024)
-
+#define MNTPOINT   "mnt_point"
+#define FILE_TEST MNTPOINT"/file"
  static int wait_count = 0;
 
  #define DESC_FLAGS_OPR(x, y) .desc = (x == IO_CMD_PWRITE ? "WRITE: " #y: "READ : " #y), \
@@ -206,7 +207,7 @@ static void test_io(unsigned int n)
  	int status;
  	struct testcase *tc = testcases + n;
 
-	status = io_tio("file", tc->flags, tc->operation);
+	status = io_tio(FILE_TEST, tc->flags, tc->operation);
  	if (status)
  		tst_res(TFAIL, "%s, status = %d", tc->desc, status);
  	else
@@ -214,7 +215,9 @@ static void test_io(unsigned int n)
  }
 
  static struct tst_test test = {
-	.needs_tmpdir = 1,
+	.mount_device = 1,
+	.mntpoint = MNTPOINT,
+	.needs_root = 1,
  	.test = test_io,
  	.tcnt = ARRAY_SIZE(testcases),
  };
author
#2 lore raw

PATCH 1/1 aio02: Use mounted filesystem instead of temp directory

Quoted 6 lines · Xiao Yang
Quoted 3 lines · Yang Xu

tmpfs doesn't support O_DIRECT flag, open file with this flag on tmpfs will report EINVAL error. I thin we should test this case on ext2 filesystem instead of temp directory.

Hi Xu,

Quoted 9 lines

Thanks for your quick fix. :-)

I don't want to use the fixed file system to run aio02. I perfer to just drop O_DIRECT flag for tmpfs, as below:
1) Drop O_DIRECT flag for tmpfs.
2) Keep O_DIRECT flag for other filesystem.
In this case, user still can run aio02 with different filesystem by mounting specified filesystem on $TMPDIR.

Sound reasonable to me, I will filter O_DIRECT flag for tmpfs.

Quoted 44 lines

Best Regards,
Xiao Yang

Quoted 41 lines

---
? testcases/kernel/io/aio/aio02.c | 9 ++++++---
? 1 file changed, 6 insertions(+), 3 deletions(-)

testcases/kernel/io/aio/aio02.c +0 -0
index e283afba9..205d1b088 100644
@@ -17,7 +17,8 @@
 

? #define AIO_MAXIO 32
? #define AIO_BLKSIZE (64*1024)

testcases/kernel/io/aio/aio02.c +2 -1
-
+#define MNTPOINT?? "mnt_point"
+#define FILE_TEST MNTPOINT"/file"

? static int wait_count = 0;

? #define DESC_FLAGS_OPR(x, y) .desc = (x == IO_CMD_PWRITE ? "WRITE: " #y: "READ : " #y), \

testcases/kernel/io/aio/aio02.c +1 -1
@@ -206,7 +207,7 @@ static void test_io(unsigned int n)
 ????? int status;
 ????? struct testcase *tc = testcases + n;
 
-??? status = io_tio("file", tc->flags, tc->operation);
+??? status = io_tio(FILE_TEST, tc->flags, tc->operation);
 ????? if (status)
 ????????? tst_res(TFAIL, "%s, status = %d", tc->desc, status);

????? else

testcases/kernel/io/aio/aio02.c +3 -1
@@ -214,7 +215,9 @@ static void test_io(unsigned int n)
 ? }
 
 ? static struct tst_test test = {
-??? .needs_tmpdir = 1,
+??? .mount_device = 1,
+??? .mntpoint = MNTPOINT,
+??? .needs_root = 1,
 ????? .test = test_io,
 ????? .tcnt = ARRAY_SIZE(testcases),
 ? };
author
#3 lore raw

PATCH v2 1/1 aio02: Drop O_DIRECT flag for tmpfs

In reply to Xiao Yang

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

---
 testcases/kernel/io/aio/aio02.c | 15 ++++++++++++++-
 1 file changed, 14 insertions(+), 1 deletion(-)
testcases/kernel/io/aio/aio02.c +14 -1
index e283afba9..3bb89c45f 100644
@@ -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),
Signature · 1 line
2.18.0
#4 lore raw

PATCH v2 1/1 aio02: Drop O_DIRECT flag for tmpfs

Quoted 13 lines · Yang Xu

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

---
 testcases/kernel/io/aio/aio02.c | 15 ++++++++++++++-
 1 file changed, 14 insertions(+), 1 deletion(-)
testcases/kernel/io/aio/aio02.c +0 -0
index e283afba9..3bb89c45f 100644

testcases/kernel/io/aio/aio02.c line 21

Quoted 5 lines
testcases/kernel/io/aio/aio02.c +1 -1
@@ -18,7 +18,8 @@
 #define AIO_MAXIO 32
 #define AIO_BLKSIZE (64*1024)
 
-static int wait_count = 0;
+static int wait_count;

Hi,

Why do you set wait_count to 0?
Isn't it default behavior?

Quoted 17 lines
testcases/kernel/io/aio/aio02.c +6 -0
+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);

testcases/kernel/io/aio/aio02.c static void test_io(unsigned int n) · line 225

Quoted 7 lines
testcases/kernel/io/aio/aio02.c +4 -0
@@ -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;

Could you simple the fix by moving 'tst_fs_type(".") == TST_TMPFS_MAGIC ' into test_io().
(i.e. Drop unused setup() and use_tmpfs.)

Thanks,
Xiao Yang

Quoted 7 lines
testcases/kernel/io/aio/aio02.c +3 -0
+}
+
 static struct tst_test test = {
+	.setup = setup,
 	.needs_tmpdir = 1,
 	.test = test_io,
 	.tcnt = ARRAY_SIZE(testcases),
#5 lore raw

PATCH v2 1/1 aio02: Drop O_DIRECT flag for tmpfs

Quoted 17 lines · Xiao Yang
Quoted 16 lines · Yang Xu

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

---
  testcases/kernel/io/aio/aio02.c | 15 ++++++++++++++-
  1 file changed, 14 insertions(+), 1 deletion(-)
testcases/kernel/io/aio/aio02.c +0 -0
index e283afba9..3bb89c45f 100644
@@ -18,7 +18,8 @@
  #define AIO_MAXIO 32
  #define AIO_BLKSIZE (64*1024)
 
Quoted 6 lines

testcases/kernel/io/aio/aio02.c line 21

Quoted 2 lines
testcases/kernel/io/aio/aio02.c +1 -1
-static int wait_count = 0;
+static int wait_count;

Hi,

Why do you set wait_count to 0?
Isn't it default behavior?

Please ignore the comment. Sorry, I misunderstand the change.

Quoted 40 lines
Quoted 17 lines
testcases/kernel/io/aio/aio02.c +6 -0
+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);

testcases/kernel/io/aio/aio02.c static void test_io(unsigned int n) · line 225

Quoted 7 lines
testcases/kernel/io/aio/aio02.c +4 -0
@@ -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;

Could you simple the fix by moving 'tst_fs_type(".") == TST_TMPFS_MAGIC ' into test_io().
(i.e. Drop unused setup() and use_tmpfs.)

Thanks,
Xiao Yang

Quoted 7 lines
testcases/kernel/io/aio/aio02.c +3 -0
+}
+
  static struct tst_test test = {
+	.setup = setup,
  	.needs_tmpdir = 1,
  	.test = test_io,
  	.tcnt = ARRAY_SIZE(testcases),
author
#6 lore raw

PATCH v2 1/1 aio02: Drop O_DIRECT flag for tmpfs

Quoted 19 lines · Xiao Yang
Quoted 18 lines · Xiao Yang
Quoted 17 lines · Yang Xu

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

---
? testcases/kernel/io/aio/aio02.c | 15 ++++++++++++++- ? 1 file changed, 14 insertions(+), 1 deletion(-)

testcases/kernel/io/aio/aio02.c +0 -0
index e283afba9..3bb89c45f 100644
@@ -18,7 +18,8 @@

? #define AIO_MAXIO 32
? #define AIO_BLKSIZE (64*1024)

Quoted 35 lines
Quoted 6 lines

testcases/kernel/io/aio/aio02.c line 21

Quoted 2 lines
testcases/kernel/io/aio/aio02.c +1 -1
-static int wait_count = 0;
+static int wait_count;

Hi,

Why do you set wait_count to 0?
Isn't it default behavior?

Please ignore the comment.? Sorry, I misunderstand the change.

Quoted 28 lines
Quoted 18 lines

+static unsigned int use_tmpfs;

? #define DESC_FLAGS_OPR(x, y) .desc = (x == IO_CMD_PWRITE ? "WRITE:
" #y: "READ : " #y), \
????? .flags = y, .operation = x

testcases/kernel/io/aio/aio02.c +5 -0
@@ -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);

testcases/kernel/io/aio/aio02.c static void test_io(unsigned int n) · line 225

Quoted 7 lines
testcases/kernel/io/aio/aio02.c +4 -0
@@ -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;

Could you simple the fix by moving 'tst_fs_type(".") == TST_TMPFS_MAGIC ' into test_io().
(i.e. Drop unused setup() and use_tmpfs.)

Hi Xiao

Of course, I put this in setup becuase it only run a time. But tst_fs_type function is simple and move it into test_io is also ok. I will accept your advise.

Best Regards
Yang Xu

Quoted 14 lines
Quoted 13 lines

Thanks,
Xiao Yang

Quoted 7 lines
testcases/kernel/io/aio/aio02.c +3 -0
+}
+
 ? static struct tst_test test = {
+??? .setup = setup,
 ????? .needs_tmpdir = 1,
 ????? .test = test_io,
 ????? .tcnt = ARRAY_SIZE(testcases),
author
#7 lore raw

PATCH v3 1/1 aio02: Drop O_DIRECT flag for tmpfs

In reply to Xiao Yang

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

Also remove unused static value initialization.

---
 testcases/kernel/io/aio/aio02.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
testcases/kernel/io/aio/aio02.c +6 -1
index e283afba9..6dec073a2 100644
@@ -18,7 +18,7 @@
 #define AIO_MAXIO 32
 #define AIO_BLKSIZE (64*1024)
 
-static int wait_count = 0;
+static int wait_count;
 
 #define DESC_FLAGS_OPR(x, y) .desc = (x == IO_CMD_PWRITE ? "WRITE: " #y: "READ : " #y), \
 	.flags = y, .operation = x
@@ -206,6 +206,11 @@ static void test_io(unsigned int n)
 	int status;
 	struct testcase *tc = testcases + n;
 
+	if ((tst_fs_type(".") == TST_TMPFS_MAGIC) && (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);
Signature · 1 line
2.18.0
#8 lore raw

PATCH v3 1/1 aio02: Drop O_DIRECT flag for tmpfs

----- Original Message -----

Quoted 10 lines

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

Also remove unused static value initialization.

---
 testcases/kernel/io/aio/aio02.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
#9 lore raw

PATCH v3 1/1 aio02: Drop O_DIRECT flag for tmpfs

Quoted 5 lines · Jan Stancek

----- Original Message -----

Quoted 3 lines

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

Quoted 10 lines
Quoted 7 lines

Also remove unused static value initialization.

---
  testcases/kernel/io/aio/aio02.c | 7 ++++++-
  1 file changed, 6 insertions(+), 1 deletion(-)

Hi all,

Thanks, I will push it with a minor change:
Keep original tc->flags and change cloned new_flags for tmpfs so that running aio02
in loops can report the 'Drop ...' hint for each changed subtest. As below:
Without the change:
-----------------------------------------------------------------------------------
[root@Fedora-30 aio]# ./aio02 -i 2
tst_test.c:1215: INFO: Timeout per run is 0h 05m 00s aio02.c:210: INFO: Drop O_DIRECT flag for tmpfs
aio02.c:218: PASS: WRITE: O_WRONLY | O_TRUNC | O_DIRECT | O_LARGEFILE | O_CREAT
aio02.c:210: INFO: Drop O_DIRECT flag for tmpfs
aio02.c:218: PASS: READ : O_RDONLY | O_DIRECT | O_LARGEFILE aio02.c:218: PASS: WRITE: O_RDWR | O_TRUNC
aio02.c:218: PASS: READ : O_RDWR
aio02.c:218: PASS: WRITE: O_WRONLY | O_TRUNC
aio02.c:218: PASS: READ : O_RDONLY
aio02.c:218: PASS: WRITE: O_WRONLY | O_TRUNC | O_DIRECT | O_LARGEFILE | O_CREAT
aio02.c:218: PASS: READ : O_RDONLY | O_DIRECT | O_LARGEFILE aio02.c:218: PASS: WRITE: O_RDWR | O_TRUNC
aio02.c:218: PASS: READ : O_RDWR
aio02.c:218: PASS: WRITE: O_WRONLY | O_TRUNC
aio02.c:218: PASS: READ : O_RDONLY
...
-----------------------------------------------------------------------------------
With the change:
-----------------------------------------------------------------------------------
[root@Fedora-30 aio]# ./aio02 -i 2
tst_test.c:1215: INFO: Timeout per run is 0h 05m 00s aio02.c:212: INFO: Drop O_DIRECT flag for tmpfs
aio02.c:220: PASS: WRITE: O_WRONLY | O_TRUNC | O_DIRECT | O_LARGEFILE | O_CREAT
aio02.c:212: INFO: Drop O_DIRECT flag for tmpfs
aio02.c:220: PASS: READ : O_RDONLY | O_DIRECT | O_LARGEFILE aio02.c:220: PASS: WRITE: O_RDWR | O_TRUNC
aio02.c:220: PASS: READ : O_RDWR
aio02.c:220: PASS: WRITE: O_WRONLY | O_TRUNC
aio02.c:220: PASS: READ : O_RDONLY
aio02.c:212: INFO: Drop O_DIRECT flag for tmpfs
aio02.c:220: PASS: WRITE: O_WRONLY | O_TRUNC | O_DIRECT | O_LARGEFILE | O_CREAT
aio02.c:212: INFO: Drop O_DIRECT flag for tmpfs
aio02.c:220: PASS: READ : O_RDONLY | O_DIRECT | O_LARGEFILE aio02.c:220: PASS: WRITE: O_RDWR | O_TRUNC
aio02.c:220: PASS: READ : O_RDWR
aio02.c:220: PASS: WRITE: O_WRONLY | O_TRUNC
aio02.c:220: PASS: READ : O_RDONLY
...
-----------------------------------------------------------------------------------

Thanks,
Xiao Yang