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

Xiao Yang yangx.jy@cn.fujitsu.com
Wed Feb 12 10:42:19 CET 2020


On 2020/2/12 15:31, Yang Xu wrote:
> 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;
Hi,

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

> +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;

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
> +}
> +
>  static struct tst_test test = {
> +	.setup = setup,
>  	.needs_tmpdir = 1,
>  	.test = test_io,
>  	.tcnt = ARRAY_SIZE(testcases),





More information about the ltp mailing list