Skip to contentSkip to conversation

lapi/syscalls: Add syscall numbers for preadv2

PATCH Superseded Xiao Yang 3 participants 9 messages Sep 28, 2018 – Feb 27, 2019

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Xiao Yang

author
#0 lore raw

PATCH 1/3 lapi/syscalls: Add syscall numbers for preadv2

---
 include/lapi/syscalls/aarch64.in   | 1 +
 include/lapi/syscalls/arm.in       | 1 +
 include/lapi/syscalls/hppa.in      | 1 +
 include/lapi/syscalls/i386.in      | 1 +
 include/lapi/syscalls/ia64.in      | 1 +
 include/lapi/syscalls/powerpc.in   | 1 +
 include/lapi/syscalls/powerpc64.in | 1 +
 include/lapi/syscalls/s390.in      | 1 +
 include/lapi/syscalls/s390x.in     | 1 +
 include/lapi/syscalls/sh.in        | 1 +
 include/lapi/syscalls/sparc.in     | 1 +
 include/lapi/syscalls/sparc64.in   | 1 +
 include/lapi/syscalls/x86_64.in    | 1 +
 13 files changed, 13 insertions(+)
include/lapi/syscalls/aarch64.in +1 -0
index 9ac7f99..0b6ba3b 100644
@@ -258,4 +258,5 @@ getrandom 278
 memfd_create 279
 mlock2 284
 copy_file_range 285
+preadv2 286
 _sysctl 1078
include/lapi/syscalls/arm.in +1 -0
index 0a7f98a..279130f 100644
@@ -343,4 +343,5 @@ memfd_create (__NR_SYSCALL_BASE+385)
 execveat (__NR_SYSCALL_BASE+387)
 mlock2 (__NR_SYSCALL_BASE+390)
 copy_file_range (__NR_SYSCALL_BASE+391)
+preadv2 (__NR_SYSCALL_BASE+392)
 statx (__NR_SYSCALL_BASE+397)
include/lapi/syscalls/hppa.in +1 -0
index 3db9780..0fa6f4e 100644
@@ -19,3 +19,4 @@ vmsplice 294
 memfd_create 340
 mlock2 345
 copy_file_range 346
+preadv2 347
include/lapi/syscalls/i386.in +1 -0
index a000564..ee8c4e9 100644
@@ -343,4 +343,5 @@ memfd_create 356
 execveat 358
 mlock2 376
 copy_file_range 377
+preadv2 378
 statx 383
include/lapi/syscalls/ia64.in +1 -0
index 2788193..b9f00bc 100644
@@ -298,3 +298,4 @@ getrandom 1339
 memfd_create 1340
 mlock2 1346
 copy_file_range 1347
+preadv2 1348
include/lapi/syscalls/powerpc.in +1 -0
index c0b4226..1e429f4 100644
@@ -349,4 +349,5 @@ getrandom 359
 memfd_create 360
 mlock2 378
 copy_file_range 379
+preadv2 380
 statx 383
include/lapi/syscalls/powerpc64.in +1 -0
index c0b4226..1e429f4 100644
@@ -349,4 +349,5 @@ getrandom 359
 memfd_create 360
 mlock2 378
 copy_file_range 379
+preadv2 380
 statx 383
include/lapi/syscalls/s390.in +1 -0
index 47a04de..8780815 100644
@@ -334,3 +334,4 @@ memfd_create 350
 execveat 354
 mlock2 374
 copy_file_range 375
+preadv2 376
include/lapi/syscalls/s390x.in +1 -0
index 83732ff..b029e72 100644
@@ -333,3 +333,4 @@ getrandom 349
 memfd_create 350
 mlock2 374
 copy_file_range 375
+preadv2 376
include/lapi/syscalls/sh.in +1 -0
index 407be7a..ebf8dad 100644
@@ -366,3 +366,4 @@ kcmp 378
 memfd_create 385
 mlock2 390
 copy_file_range 391
+preadv2 392
include/lapi/syscalls/sparc.in +1 -0
index 2b06a79..8d8a54e 100644
@@ -338,3 +338,4 @@ getrandom 347
 memfd_create 348
 mlock2 356
 copy_file_range 357
+preadv2 358
include/lapi/syscalls/sparc64.in +1 -0
index 8c8a866..140e9ce 100644
@@ -314,3 +314,4 @@ getrandom 347
 memfd_create 348
 mlock2 356
 copy_file_range 357
+preadv2 358
include/lapi/syscalls/x86_64.in +1 -0
index 4ce8477..1966da2 100644
@@ -310,4 +310,5 @@ memfd_create 319
 execveat 322
 mlock2 325
 copy_file_range 326
+preadv2 327
 statx 332
Signature · 1 line
1.8.3.1
author
#1 lore raw

PATCH 2/3 syscalls/preadv201: Add new testcase

Check the basic functionality of the preadv2(2).

---
 configure.ac                                  |   1 +
 m4/ltp-preadv2.m4                             |   9 ++
 runtest/ltplite                               |   2 +
 runtest/stress.part3                          |   2 +
 runtest/syscalls                              |   3 +
 testcases/kernel/syscalls/preadv2/.gitignore  |   2 +
 testcases/kernel/syscalls/preadv2/Makefile    |  14 +++
 testcases/kernel/syscalls/preadv2/preadv2.h   |  26 ++++++
 testcases/kernel/syscalls/preadv2/preadv201.c | 119 ++++++++++++++++++++++++++
 9 files changed, 178 insertions(+)
 create mode 100644 m4/ltp-preadv2.m4
 create mode 100644 testcases/kernel/syscalls/preadv2/.gitignore
 create mode 100644 testcases/kernel/syscalls/preadv2/Makefile
 create mode 100644 testcases/kernel/syscalls/preadv2/preadv2.h
 create mode 100644 testcases/kernel/syscalls/preadv2/preadv201.c
configure.ac +1 -0
index e1ecb32..0f0d8c1 100644
@@ -218,6 +218,7 @@ LTP_CHECK_KCMP
 LTP_CHECK_KCMP_TYPE
 LTP_CHECK_PREADV
 LTP_CHECK_PWRITEV
+LTP_CHECK_PREADV2
 LTP_CHECK_EPOLL_PWAIT
 LTP_CHECK_KEYUTILS_SUPPORT
 LTP_CHECK_SYNC_ADD_AND_FETCH
m4/ltp-preadv2.m4 new file +9 -0
new file mode 100644
index 0000000..a1e5327
@@ -0,0 +1,9 @@
+dnl SPDX-License-Identifier: GPL-2.0-or-later
+dnl Copyright (c) 2018 FUJITSU LIMITED. All rights reserved.
+dnl Author: Xiao Yang <[email protected]>
+
+dnl LTP_CHECK_PREADV2
+dnl ----------------------------
+AC_DEFUN([LTP_CHECK_PREADV2],[
+AC_CHECK_FUNCS(preadv2,,)
+])
runtest/ltplite +2 -0
index 61ab275..6959536 100644
@@ -586,6 +586,8 @@ preadv01 preadv01
 preadv02 preadv02
 preadv03 preadv03
 
+preadv201 preadv201
+
 profil01 profil01
 
 pselect01 pselect01
runtest/stress.part3 +2 -0
index 332daa9..525d33b 100644
@@ -495,6 +495,8 @@ preadv01 preadv01
 preadv02 preadv02
 preadv03 preadv03
 
+preadv201 preadv201
+
 profil01 profil01
 
 pselect01 pselect01
runtest/syscalls +3 -0
index 0d0be77..02b02b8 100644
@@ -834,6 +834,9 @@ preadv02_64 preadv02_64
 preadv03 preadv03
 preadv03_64 preadv03_64
 
+preadv201 preadv201
+preadv201_64 preadv201_64
+
 profil01 profil01
 
 process_vm_readv01 process_vm01 -r
testcases/kernel/syscalls/preadv2/.gitignore new file +2 -0
new file mode 100644
index 0000000..0ed1a00
@@ -0,0 +1,2 @@
+/preadv201
+/preadv201_64
testcases/kernel/syscalls/preadv2/Makefile new file +14 -0
new file mode 100644
index 0000000..fc1fbf3
@@ -0,0 +1,14 @@
+# SPDX-License-Identifier: GPL-2.0-or-later
+# Copyright (c) 2018 FUJITSU LIMITED. All rights reserved.
+# Author: Xiao Yang <[email protected]>
+#
+
+top_srcdir		?= ../../../..
+
+include $(top_srcdir)/include/mk/testcases.mk
+
+include $(abs_srcdir)/../utils/newer_64.mk
+
+%_64: CPPFLAGS += -D_FILE_OFFSET_BITS=64
+
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
testcases/kernel/syscalls/preadv2/preadv2.h new file +26 -0
new file mode 100644
index 0000000..aacf96f
@@ -0,0 +1,26 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+/*
+ * Copyright (c) 2018 FUJITSU LIMITED. All rights reserved.
+ * Author: Xiao Yang <[email protected]>
+ */
+
+#ifndef PREADV2_H
+#define PREADV2_H
+
+#include "config.h"
+#include "lapi/syscalls.h"
+
+#if !defined(HAVE_PREADV2)
+
+/* LO_HI_LONG taken from glibc */
+# define LO_HI_LONG(val) (long) (val), (long) (((uint64_t) (val)) >> 32)
+
+ssize_t preadv2(int fd, const struct iovec *iov, int iovcnt, off_t offset,
+		int flags)
+{
+	return tst_syscall(__NR_preadv2, fd, iov, iovcnt,
+			   LO_HI_LONG(offset), flags);
+}
+#endif
+
+#endif /* PREADV2_H */
testcases/kernel/syscalls/preadv2/preadv201.c new file +119 -0

119 lines not on this page · raw message

Signature · 1 line
1.8.3.1
#2 lore raw

PATCH 2/3 syscalls/preadv201: Add new testcase

Hi!
Pushed with minor changes:

1. moved the preadv2.h into include/lapi

2. reformatted the struct testcase array so that it's easier to read

Thanks!

Signature · 2 lines
Cyril Hrubis
[email protected]
author
#3 lore raw

PATCH 3/3 syscalls/preadv202: Add new testcase

In reply to Xiao Yang

Check various errnos for the preadv2(2).

Note:
From preadv2(2) manpage, preadv2() with invalid flag should return EINVAL, but it actually returned EOPNOTSUPP in current upstream kernel, as below:
---------------------------------------------------------------
include/uapi/linux/fs.h:
define RWF_SUPPORTED (RWF_HIPRI | RWF_DSYNC | RWF_SYNC | RWF_NOWAIT |\
RWF_APPEND)
...

include/linux/fs.h:
static inline int kiocb_set_rw_flags(struct kiocb *ki, rwf_t flags)

{
        if (unlikely(flags & ~RWF_SUPPORTED)) {
                return -EOPNOTSUPP;
        }

...
---------------------------------------------------------------

We use EOPNOTSUPP as expected errno for the time being.

---
 runtest/ltplite                               |   1 +
 runtest/stress.part3                          |   1 +
 runtest/syscalls                              |   2 +
 testcases/kernel/syscalls/preadv2/.gitignore  |   2 +
 testcases/kernel/syscalls/preadv2/preadv202.c | 123 ++++++++++++++++++++++++++
 5 files changed, 129 insertions(+)
 create mode 100644 testcases/kernel/syscalls/preadv2/preadv202.c
runtest/ltplite +1 -0
index 6959536..c7bcbd2 100644
@@ -587,6 +587,7 @@ preadv02 preadv02
 preadv03 preadv03
 
 preadv201 preadv201
+preadv202 preadv202
 
 profil01 profil01
 
runtest/stress.part3 +1 -0
index 525d33b..79cbc4f 100644
@@ -496,6 +496,7 @@ preadv02 preadv02
 preadv03 preadv03
 
 preadv201 preadv201
+preadv202 preadv202
 
 profil01 profil01
 
runtest/syscalls +2 -0
index 02b02b8..844bf41 100644
@@ -836,6 +836,8 @@ preadv03_64 preadv03_64
 
 preadv201 preadv201
 preadv201_64 preadv201_64
+preadv202 preadv202
+preadv202_64 preadv202_64
 
 profil01 profil01
 
testcases/kernel/syscalls/preadv2/.gitignore +2 -0
index 0ed1a00..759d9ef 100644
@@ -1,2 +1,4 @@
 /preadv201
 /preadv201_64
+/preadv202
+/preadv202_64
testcases/kernel/syscalls/preadv2/preadv202.c new file +123 -0

123 lines not on this page · raw message

Signature · 1 line
1.8.3.1
#4 lore raw

PATCH 3/3 syscalls/preadv202: Add new testcase

Hi!

Quoted 12 lines

Note:
From preadv2(2) manpage, preadv2() with invalid flag should return EINVAL, but it actually returned EOPNOTSUPP in current upstream kernel, as below:
---------------------------------------------------------------
include/uapi/linux/fs.h:
define RWF_SUPPORTED (RWF_HIPRI | RWF_DSYNC | RWF_SYNC | RWF_NOWAIT |\
RWF_APPEND)
...

include/linux/fs.h:
static inline int kiocb_set_rw_flags(struct kiocb *ki, rwf_t flags)

Quoted 8 lines
{
        if (unlikely(flags & ~RWF_SUPPORTED)) {
                return -EOPNOTSUPP;
        }

...
---------------------------------------------------------------

We use EOPNOTSUPP as expected errno for the time being.

This is probably worth a patch for the man-pages project, will you take care of that?

Pushed with a minor change, I've changed the EFAULT test to get address from tst_get_bad_addr() instead of the hardcoded -1.

Thanks!

Signature · 2 lines
Cyril Hrubis
[email protected]
author
#5 lore raw

PATCH 3/3 syscalls/preadv202: Add new testcase

Hi Cyril,

Thank you to review the whole patch set.

Quoted 20 lines · Cyril Hrubis

Hi!

Quoted 19 lines

Note:
From preadv2(2) manpage, preadv2() with invalid flag should return
EINVAL, but it actually returned EOPNOTSUPP in current upstream kernel, as below:
---------------------------------------------------------------
include/uapi/linux/fs.h:
define RWF_SUPPORTED (RWF_HIPRI | RWF_DSYNC | RWF_SYNC | RWF_NOWAIT |\
RWF_APPEND)
...

include/linux/fs.h:
static inline int kiocb_set_rw_flags(struct kiocb *ki, rwf_t flags)

{
         if (unlikely(flags&  ~RWF_SUPPORTED)) {
                 return -EOPNOTSUPP;
         }

...
---------------------------------------------------------------

Quoted 3 lines
Quoted 1 line

We use EOPNOTSUPP as expected errno for the time being.

This is probably worth a patch for the man-pages project, will you take care of that?

I will try to send a fix patch to the man-pages project as you advised.

Thanks,
Xiao Yang

Quoted 5 lines

Pushed with a minor change, I've changed the EFAULT test to get address from tst_get_bad_addr() instead of the hardcoded -1.

Thanks!

author
#6 lore raw

PATCH 3/3 syscalls/preadv202: Add new testcase

In reply to Cyril Hrubis

Hi Jan,

preadv202 has used tst_get_bad_addr() instead of the hardcoded -1 to test EFAULT, so is it
necessary to test EFAULT on s390 by truncating file as commit 856383c does? Perhaps, we
can remove the truncation if it is unnecessary. Sorry, i don't have
s390 to confirm it.

Best Regards,
Xiao Yang

Quoted 29 lines · Cyril Hrubis

Hi!

Quoted 12 lines

Note:
From preadv2(2) manpage, preadv2() with invalid flag should return
EINVAL, but it actually returned EOPNOTSUPP in current upstream kernel, as below:
---------------------------------------------------------------
include/uapi/linux/fs.h:
define RWF_SUPPORTED (RWF_HIPRI | RWF_DSYNC | RWF_SYNC | RWF_NOWAIT |\
RWF_APPEND)
...

include/linux/fs.h:
static inline int kiocb_set_rw_flags(struct kiocb *ki, rwf_t flags)

Quoted 8 lines
{
         if (unlikely(flags&  ~RWF_SUPPORTED)) {
                 return -EOPNOTSUPP;
         }

...
---------------------------------------------------------------

We use EOPNOTSUPP as expected errno for the time being.

This is probably worth a patch for the man-pages project, will you take care of that?

Pushed with a minor change, I've changed the EFAULT test to get address from tst_get_bad_addr() instead of the hardcoded -1.

Thanks!

#7 lore raw

PATCH 3/3 syscalls/preadv202: Add new testcase

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

Quoted 6 lines

Hi Jan,

preadv202 has used tst_get_bad_addr() instead of the hardcoded -1 to test EFAULT, so is it
necessary to test EFAULT on s390 by truncating file as commit 856383c does?

If s390 doesn't immediately check iovec for validity, I don't see difference between -1 and other invalid address.

I missing some context for this email, what made you look into this again? Anyway, I tried dropping truncate and ran test on 5.0.0-rc8 s390x:

# ./preadv202
tst_test.c:1085: INFO: Timeout per run is 0h 05m 00s
preadv202.c:82: PASS: preadv2() failed as expected: EINVAL
preadv202.c:82: PASS: preadv2() failed as expected: EINVAL
preadv202.c:82: PASS: preadv2() failed as expected: EOPNOTSUPP
preadv202.c:77: FAIL: preadv2() succeeded unexpectedly
preadv202.c:82: PASS: preadv2() failed as expected: EBADF
preadv202.c:82: PASS: preadv2() failed as expected: EBADF
preadv202.c:82: PASS: preadv2() failed as expected: EISDIR
preadv202.c:82: PASS: preadv2() failed as expected: ESPIPE

Regards,
Jan

Quoted 40 lines

Perhaps, we
can remove the truncation if it is unnecessary. Sorry, i don't have
s390 to confirm it.

Best Regards,
Xiao Yang

Quoted 29 lines · Cyril Hrubis

Hi!

Quoted 12 lines

Note:
From preadv2(2) manpage, preadv2() with invalid flag should return
EINVAL, but it actually returned EOPNOTSUPP in current upstream kernel, as below:
---------------------------------------------------------------
include/uapi/linux/fs.h:
define RWF_SUPPORTED (RWF_HIPRI | RWF_DSYNC | RWF_SYNC | RWF_NOWAIT |\
RWF_APPEND)
...

include/linux/fs.h:
static inline int kiocb_set_rw_flags(struct kiocb *ki, rwf_t flags)

Quoted 8 lines
{
         if (unlikely(flags&  ~RWF_SUPPORTED)) {
                 return -EOPNOTSUPP;
         }

...
---------------------------------------------------------------

We use EOPNOTSUPP as expected errno for the time being.

This is probably worth a patch for the man-pages project, will you take care of that?

Pushed with a minor change, I've changed the EFAULT test to get address from tst_get_bad_addr() instead of the hardcoded -1.

Thanks!

author
#8 lore raw

PATCH 3/3 syscalls/preadv202: Add new testcase

Quoted 14 lines · Jan Stancek

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

Quoted 6 lines

Hi Jan,

preadv202 has used tst_get_bad_addr() instead of the hardcoded -1 to test EFAULT, so is it
necessary to test EFAULT on s390 by truncating file as commit 856383c does?

If s390 doesn't immediately check iovec for validity, I don't see difference between -1 and other invalid address.

I missing some context for this email, what made you look into this again? Anyway, I tried dropping truncate and ran test on 5.0.0-rc8 s390x:

Quoted 10 lines
# ./preadv202
tst_test.c:1085: INFO: Timeout per run is 0h 05m 00s
preadv202.c:82: PASS: preadv2() failed as expected: EINVAL
preadv202.c:82: PASS: preadv2() failed as expected: EINVAL
preadv202.c:82: PASS: preadv2() failed as expected: EOPNOTSUPP
preadv202.c:77: FAIL: preadv2() succeeded unexpectedly
preadv202.c:82: PASS: preadv2() failed as expected: EBADF
preadv202.c:82: PASS: preadv2() failed as expected: EBADF
preadv202.c:82: PASS: preadv2() failed as expected: EISDIR
preadv202.c:82: PASS: preadv2() failed as expected: ESPIPE

Hi Jan,

Thanks a lot for your reply and test. :-)

Recently, i am looking into pwritev202.c written by Jinhui Huang, and i just want to
know if it is necessary for both preadv2 and pwritev2 to test EFAULT by truncating.

Best Regards,
Xiao Yang

Quoted 45 lines

Regards,
Jan

Quoted 4 lines

Perhaps, we
can remove the truncation if it is unnecessary. Sorry, i don't have
s390 to confirm it.

Quoted 35 lines

Best Regards,
Xiao Yang

Quoted 29 lines · Cyril Hrubis

Hi!

Quoted 12 lines

Note:
From preadv2(2) manpage, preadv2() with invalid flag should return
EINVAL, but it actually returned EOPNOTSUPP in current upstream kernel, as below:
---------------------------------------------------------------
include/uapi/linux/fs.h:
define RWF_SUPPORTED (RWF_HIPRI | RWF_DSYNC | RWF_SYNC | RWF_NOWAIT |\
RWF_APPEND)
...

include/linux/fs.h:
static inline int kiocb_set_rw_flags(struct kiocb *ki, rwf_t flags)

Quoted 8 lines
{
          if (unlikely(flags&   ~RWF_SUPPORTED)) {
                  return -EOPNOTSUPP;
          }

...
---------------------------------------------------------------

We use EOPNOTSUPP as expected errno for the time being.

This is probably worth a patch for the man-pages project, will you take care of that?

Pushed with a minor change, I've changed the EFAULT test to get address from tst_get_bad_addr() instead of the hardcoded -1.

Thanks!

.