Skip to contentSkip to conversation

lapi/io_uring.h: Add declaration of __kernel_rwf_t

PATCH New Yang Xu 4 participants 8 messages Jul 17, 2020 – Jul 19, 2020

lore
Share & tools
lore

Yang Xu

author
#0 lore raw

PATCH 1/1 lapi/io_uring.h: Add declaration of __kernel_rwf_t

Since kernel commit ddef7ed2b5cb ("annotate RWF_... flags"), fs.h introduced
__kernel_rwf_t data type in 4.14-rc1.

Fix build error on old kernel.
In file included from io_uring01.c:20:
../../../../include/lapi/io_uring.h:38: error: expected specifier-qualifier-list before ?__kernel_rwf_t? io_uring01.c:266: warning: missing initializer
io_uring01.c:266: warning: (near initialization for ?(anonymous)[1].ptr?) io_uring01.c:268: warning: missing initializer
io_uring01.c:268: warning: (near initialization for ?test.caps?)
make: *** [io_uring01] Error 1

---
 include/lapi/io_uring.h | 5 +++++
 1 file changed, 5 insertions(+)
include/lapi/io_uring.h +5 -0
index 8e47501a5..4a8978e87 100644
@@ -12,6 +12,7 @@
 #include <unistd.h>
 #include <fcntl.h>
 #include <sys/types.h>
+#include <linux/types.h>
 #include <sys/uio.h>
 #include <stdlib.h>
 #include <linux/fs.h>
@@ -20,6 +21,10 @@
 
 #ifndef IOSQE_FIXED_FILE
 
+#ifndef __kernel_rwf_t
+typedef int __bitwise __kernel_rwf_t;
+#endif
+
 /*
  * IO submission data structure (Submission Queue Entry)
  */
Signature · 1 line
2.23.0
#1 lore raw

PATCH 1/1 lapi/io_uring.h: Add declaration of __kernel_rwf_t

Hi Xu,

Quoted 2 lines

Since kernel commit ddef7ed2b5cb ("annotate RWF_... flags"), fs.h introduced
__kernel_rwf_t data type in 4.14-rc1.

Thanks for the fix.
Going to merge it, just wait for travis verification.

Kind regards,
Petr

#2 lore raw

PATCH 1/1 lapi/io_uring.h: Add declaration of __kernel_rwf_t

Quoted 8 lines
Quoted 4 lines

Since kernel commit ddef7ed2b5cb ("annotate RWF_... flags"), fs.h introduced
__kernel_rwf_t data type in 4.14-rc1.

Fix build error on old kernel.

Thanks for the fix.
Going to merge it, just wait for travis verification.

BTW the regression was caused by my changes to the lapi header in 95399bc87 ("lapi/io_uring: Preparation for io_uring tests") - I updated the header.

We might consider not including <linux/types.h>, it's needed just for __kernel_rwf_t. I'm against these optimisations (as the definition can change), but I remember Jan asked me to avoid including kernel header just for single use [1], but maybe this is a different case.

Kind regards,
Petr

[1] https://patchwork.ozlabs.org/project/ltp/patch/[email protected]/#2281586

author
#3 lore raw

PATCH 1/1 lapi/io_uring.h: Add declaration of __kernel_rwf_t

Hi Petr

Quoted 8 lines
Quoted 8 lines
Quoted 4 lines

Since kernel commit ddef7ed2b5cb ("annotate RWF_... flags"), fs.h introduced
__kernel_rwf_t data type in 4.14-rc1.

Fix build error on old kernel.

Thanks for the fix.
Going to merge it, just wait for travis verification.

Quoted 7 lines

BTW the regression was caused by my changes to the lapi header in 95399bc87 ("lapi/io_uring: Preparation for io_uring tests") - I updated the header.

We might consider not including <linux/types.h>, it's needed just for __kernel_rwf_t. I'm against these optimisations (as the definition can change), but I remember Jan asked me to avoid including kernel header just for single use [1], but maybe this is a different case.

I still remember the similar case when clean up quotactl code(commit c4bf6f66 lapi/quotactl.h: Use libc headers instead kernel uapi) last year.

how about the follwing change

+#ifdef __CHECKER__
+#define __bitwise__ __attribute__((bitwise))
+#else
+#define __bitwise__
+#endif
+#define __bitwise __bitwise__
+
+#ifndef __kernel_rwf_t
+typedef int __bitwise __kernel_rwf_t;
+#endif

Also, I think we should replace _u32 with uint32 in lapi/loop.h if we don't want to include linux kernel header for single use.

Quoted 7 lines

Kind regards,
Petr

[1] https://patchwork.ozlabs.org/project/ltp/patch/[email protected]/#2281586

#4 lore raw

PATCH 1/1 lapi/io_uring.h: Add declaration of __kernel_rwf_t

Hi!

Quoted 13 lines

how about the follwing change

(quoted diff) +10 -0
+#ifdef __CHECKER__
+#define __bitwise__ __attribute__((bitwise))
+#else
+#define __bitwise__
+#endif
+#define __bitwise __bitwise__
+
+#ifndef __kernel_rwf_t
+typedef int __bitwise __kernel_rwf_t;
+#endif
Quoted 2 lines

Also, I think we should replace _u32 with uint32 in lapi/loop.h if we don't want to include linux kernel header for single use.

The whole __bitwise is used only by a sparse checker, there is no point to include it in LTP. So we can just typedef the __kernel_rwf_t to int.

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

PATCH 1/1 lapi/io_uring.h: Add declaration of __kernel_rwf_t

Hi,

Quoted 13 lines
Quoted 12 lines

how about the follwing change

(quoted diff) +10 -0
+#ifdef __CHECKER__
+#define __bitwise__ __attribute__((bitwise))
+#else
+#define __bitwise__
+#endif
+#define __bitwise __bitwise__
+
+#ifndef __kernel_rwf_t
+typedef int __bitwise __kernel_rwf_t;
+#endif
Quoted 5 lines
Quoted 2 lines

Also, I think we should replace _u32 with uint32 in lapi/loop.h if we don't want to include linux kernel header for single use.

The whole __bitwise is used only by a sparse checker, there is no point to include it in LTP. So we can just typedef the __kernel_rwf_t to int.

Make sense, going to push this variant.

Kind regards,
Petr

#6 lore raw

PATCH 1/1 lapi/io_uring.h: Add declaration of __kernel_rwf_t

In reply to Cyril Hrubis

Hi,

Quoted 5 lines
Quoted 2 lines

Also, I think we should replace _u32 with uint32 in lapi/loop.h if we don't want to include linux kernel header for single use.

The whole __bitwise is used only by a sparse checker, there is no point to include it in LTP. So we can just typedef the __kernel_rwf_t to int.

Merged. Thanks both of you for your comments.

Kind regards,
Petr

#7 lore raw

PATCH 1/1 lapi/io_uring.h: Add declaration of __kernel_rwf_t

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

Quoted 7 lines

Hi,

Quoted 5 lines
Quoted 2 lines

Also, I think we should replace _u32 with uint32 in lapi/loop.h if we don't want to include linux kernel header for single use.

The whole __bitwise is used only by a sparse checker, there is no point to include it in LTP. So we can just typedef the __kernel_rwf_t to int.

+1

Quoted 1 line

Merged. Thanks both of you for your comments.

Thanks. Sorry for late/no response, I have some time off with limited access to email.