add mkdir, [sym]linkat, mknodat support
v2 cover add mkdir, [sym]linkat, mknodat support
This started as an attempt to add mkdir support to io_uring, but in the end more ops were added. Heavily based on a series that added unlinkat support (commit: 44db0f437a2b ("io_uring.h: add renameat and unlinkat opcodes") and a couple of subsequent ones).
The kernel side of the change:
https://lore.kernel.org/io-uring/[email protected]/T/
1-2 adds mkdirat support (the opcode is already there) and test 3-5 adds symlinkat support and test
6-8 adds linkat support and test
9-11 adds mknodat support and test
v2:
- add symlinkat, linkat, mknodat
Dmitry Kadashev (11):
liburing.h: add mkdirat prep helper
Add mkdirat test case
io_uring.h: add symlinkat opcode
liburing.h: add symlinkat prep helper
Add symlinkat test case
io_uring.h: add linkat opcode
liburing.h: add linkat prep helper
Add linkat test case
io_uring.h: add mknodat opcode
liburing.h: add mknodat prep helper
Add mknod test case
.gitignore | 4 + src/include/liburing.h | 29 ++++++ src/include/liburing/io_uring.h | 5 ++ test/Makefile | 8 ++ test/hardlink.c | 133 +++++++++++++++++++++++++++ test/mkdir.c | 105 ++++++++++++++++++++++ test/mknod.c | 155 ++++++++++++++++++++++++++++++++ test/symlink.c | 113 +++++++++++++++++++++++ 8 files changed, 552 insertions(+) create mode 100644 test/hardlink.c create mode 100644 test/mkdir.c create mode 100644 test/mknod.c create mode 100644 test/symlink.c
Signature · 1 line
2.30.2
PATCH v2 1/11 liburing.h: add mkdirat prep helper
--- src/include/liburing.h | 6 ++++++ 1 file changed, 6 insertions(+)
src/include/liburing.h +6 -0
@@ -548,6 +548,12 @@ static inline void io_uring_prep_sync_file_range(struct io_uring_sqe *sqe, sqe->sync_range_flags = flags; } +static inline void io_uring_prep_mkdirat (struct io_uring_sqe *sqe,int dfd, +const char *path,mode_t mode) +{ +io_uring_prep_rw (IORING_OP_MKDIRAT , sqe, dfd, path, mode,0 ); +} +/* * Returns number of unconsumed (if SQPOLL) or unsubmitted entries exist in * the SQ ring
Signature · 1 line
2.30.2
PATCH v2 2/11 Add mkdirat test case
In reply to Dmitry KadashevThe test is relative basic: tests only success, EEXISTS, ENOENT (no parent dir).
--- .gitignore | 1 + test/Makefile | 2 + test/mkdir.c | 105 ++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 108 insertions(+) create mode 100644 test/mkdir.c
.gitignore +1 -0
@@ -68,6 +68,7 @@ /test/link-timeout /test/link_drain /test/madvise +/test/mkdir /test/nop /test/nop-all-sizes /test/open-close
test/Makefile +2 -0
@@ -65,6 +65,7 @@ test_targets += \ link-timeout \ link_drain \ madvise \ + mkdir \ multicqes_drain \ nop \ nop-all-sizes \
@@ -202,6 +203,7 @@ test_srcs := \ link.c \ link_drain.c \ madvise.c \ + mkdir.c \ multicqes_drain.c \ nop-all-sizes.c \ nop.c \
test/mkdir.c new file +105 -0
105 lines not on this page · raw message
Signature · 1 line
2.30.2
PATCH v2 3/11 io_uring.h: add symlinkat opcode
In reply to Dmitry Kadashev--- src/include/liburing/io_uring.h | 1 + 1 file changed, 1 insertion(+)
src/include/liburing/io_uring.h +1 -0
@@ -142,6 +142,7 @@ enum {IORING_OP_RENAMEAT ,IORING_OP_UNLINKAT ,IORING_OP_MKDIRAT , +IORING_OP_SYMLINKAT ,/* this goes last, obviously */ IORING_OP_LAST,
Signature · 1 line
2.30.2
PATCH v2 4/11 liburing.h: add symlinkat prep helper
In reply to Dmitry Kadashev--- src/include/liburing.h | 7 +++++++ 1 file changed, 7 insertions(+)
src/include/liburing.h +7 -0
@@ -554,6 +554,13 @@ static inline void io_uring_prep_mkdirat(struct io_uring_sqe *sqe, int dfd,io_uring_prep_rw (IORING_OP_MKDIRAT , sqe, dfd, path, mode,0 ); } +static inline void io_uring_prep_symlinkat (struct io_uring_sqe *sqe, +const char *target,int newdirfd,const char *linkpath) +{ +io_uring_prep_rw (IORING_OP_SYMLINKAT , sqe, newdirfd, target,0 , + (uint64_t ) (uintptr_t ) linkpath); +} +/* * Returns number of unconsumed (if SQPOLL) or unsubmitted entries exist in * the SQ ring
Signature · 1 line
2.30.2
PATCH v2 5/11 Add symlinkat test case
In reply to Dmitry KadashevTests successful creation (using readlink() to verify the contents), EEXIST, ENOENT cases.
--- .gitignore | 1 + test/Makefile | 2 + test/symlink.c | 113 +++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 116 insertions(+) create mode 100644 test/symlink.c
.gitignore +1 -0
@@ -112,6 +112,7 @@ /test/statx /test/stdout /test/submit-reuse +/test/symlink /test/teardowns /test/thread-exit /test/timeout
test/Makefile +2 -0
@@ -108,6 +108,7 @@ test_targets += \ sq-space_left \ stdout \ submit-reuse \ + symlink \ teardowns \ thread-exit \ timeout \
@@ -248,6 +249,7 @@ test_srcs := \ statx.c \ stdout.c \ submit-reuse.c \ + symlink.c \ teardowns.c \ thread-exit.c \ timeout-new.c \
test/symlink.c new file +113 -0
113 lines not on this page · raw message
Signature · 1 line
2.30.2
PATCH v2 6/11 io_uring.h: add linkat opcode
In reply to Dmitry Kadashev--- src/include/liburing/io_uring.h | 2 ++ 1 file changed, 2 insertions(+)
src/include/liburing/io_uring.h +2 -0
@@ -48,6 +48,7 @@ struct io_uring_sqe {__u32 splice_flags;__u32 rename_flags;__u32 unlink_flags; +__u32 hardlink_flags; };__u64 user_data;/* data to be passed back at completion time */ union {
@@ -143,6 +144,7 @@ enum {IORING_OP_UNLINKAT ,IORING_OP_MKDIRAT ,IORING_OP_SYMLINKAT , +IORING_OP_LINKAT ,/* this goes last, obviously */ IORING_OP_LAST,
Signature · 1 line
2.30.2
PATCH v2 7/11 liburing.h: add linkat prep helper
In reply to Dmitry Kadashev--- src/include/liburing.h | 9 +++++++++ 1 file changed, 9 insertions(+)
src/include/liburing.h +9 -0
@@ -561,6 +561,15 @@ static inline void io_uring_prep_symlinkat(struct io_uring_sqe *sqe, (uint64_t) (uintptr_t) linkpath); } +static inline void io_uring_prep_linkat (struct io_uring_sqe *sqe,int olddfd, +const char *oldpath,int newdfd, +const char *newpath,int flags) +{ +io_uring_prep_rw (IORING_OP_LINKAT , sqe, olddfd, oldpath, newdfd, + (uint64_t ) (uintptr_t ) newpath); + sqe->hardlink_flags = flags; +} +/* * Returns number of unconsumed (if SQPOLL) or unsubmitted entries exist in * the SQ ring
Signature · 1 line
2.30.2
PATCH v2 8/11 Add linkat test case
In reply to Dmitry KadashevTests success, EEXISTS, ENOENT (no parent dir).
--- .gitignore | 1 + test/Makefile | 2 + test/hardlink.c | 133 ++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 136 insertions(+) create mode 100644 test/hardlink.c
.gitignore +1 -0
@@ -57,6 +57,7 @@ /test/files-exit-hang-timeout /test/fixed-link /test/fsync +/test/hardlink /test/io-cancel /test/io_uring_enter /test/io_uring_register
test/Makefile +2 -0
@@ -54,6 +54,7 @@ test_targets += \ files-exit-hang-timeout \ fixed-link \ fsync \ + hardlink \ io-cancel \ io_uring_enter \ io_uring_register \
@@ -193,6 +194,7 @@ test_srcs := \ files-exit-hang-timeout.c \ fixed-link.c \ fsync.c \ + hardlink.c \ io-cancel.c \ io_uring_enter.c \ io_uring_register.c \
test/hardlink.c new file +133 -0
133 lines not on this page · raw message
Signature · 1 line
2.30.2
PATCH v2 9/11 io_uring.h: add mknodat opcode
In reply to Dmitry Kadashev--- src/include/liburing/io_uring.h | 2 ++ 1 file changed, 2 insertions(+)
src/include/liburing/io_uring.h +2 -0
@@ -49,6 +49,7 @@ struct io_uring_sqe {__u32 rename_flags;__u32 unlink_flags;__u32 hardlink_flags; +__u32 mknod_dev; };__u64 user_data;/* data to be passed back at completion time */ union {
@@ -145,6 +146,7 @@ enum {IORING_OP_MKDIRAT ,IORING_OP_SYMLINKAT ,IORING_OP_LINKAT , +IORING_OP_MKNODAT ,/* this goes last, obviously */ IORING_OP_LAST,
Signature · 1 line
2.30.2
PATCH v2 10/11 liburing.h: add mknodat prep helper
In reply to Dmitry Kadashev--- src/include/liburing.h | 7 +++++++ 1 file changed, 7 insertions(+)
src/include/liburing.h +7 -0
@@ -570,6 +570,13 @@ static inline void io_uring_prep_linkat(struct io_uring_sqe *sqe, int olddfd, sqe->hardlink_flags = flags; } +static inline void io_uring_prep_mknodat (struct io_uring_sqe *sqe,int dfd, +const char *pathname,mode_t mode,dev_t dev) +{ +io_uring_prep_rw (IORING_OP_MKNODAT , sqe, dfd, pathname, mode,0 ); + sqe->mknod_dev = dev; +} +/* * Returns number of unconsumed (if SQPOLL) or unsubmitted entries exist in * the SQ ring
Signature · 1 line
2.30.2
PATCH v2 11/11 Add mknod test case
In reply to Dmitry KadashevTests success (fifo, char dev), EEXISTS, ENOENT (no parent dir).
--- .gitignore | 1 + test/Makefile | 2 + test/mknod.c | 155 ++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 158 insertions(+) create mode 100644 test/mknod.c
.gitignore +1 -0
@@ -70,6 +70,7 @@ /test/link_drain /test/madvise /test/mkdir +/test/mknod /test/nop /test/nop-all-sizes /test/open-close
test/Makefile +2 -0
@@ -67,6 +67,7 @@ test_targets += \ link_drain \ madvise \ mkdir \ + mknod \ multicqes_drain \ nop \ nop-all-sizes \
@@ -207,6 +208,7 @@ test_srcs := \ link_drain.c \ madvise.c \ mkdir.c \ + mknod.c \ multicqes_drain.c \ nop-all-sizes.c \ nop.c \
test/mknod.c new file +155 -0
155 lines not on this page · raw message
Signature · 1 line
2.30.2