* [PATCH 1/5] io_uring: add rename opcode for current working directory
2022-05-31 18:41 [PATCH 0/5] io_uring: add opcodes for current working directory Usama Arif
@ 2022-05-31 18:41 ` Usama Arif
2022-05-31 18:41 ` [PATCH 2/5] io_uring: add unlink " Usama Arif
` (4 subsequent siblings)
5 siblings, 0 replies; 11+ messages in thread
From: Usama Arif @ 2022-05-31 18:41 UTC (permalink / raw)
To: io-uring, axboe, linux-kernel; +Cc: fam.zheng, Usama Arif
This provides consistency between io_uring and the respective I/O syscall
and avoids having the user of liburing specify the cwd in sqe for
IORING_OP_RENAMEAT.
Signed-off-by: Usama Arif <[email protected]>
---
fs/io_uring.c | 25 ++++++++++++++++++-------
include/uapi/linux/io_uring.h | 1 +
2 files changed, 19 insertions(+), 7 deletions(-)
diff --git a/fs/io_uring.c b/fs/io_uring.c
index 9f1c682d7caf..8bf56523ff7f 100644
--- a/fs/io_uring.c
+++ b/fs/io_uring.c
@@ -1306,6 +1306,7 @@ static const struct io_op_def io_op_defs[] = {
[IORING_OP_SHUTDOWN] = {
.needs_file = 1,
},
+ [IORING_OP_RENAME] = {},
[IORING_OP_RENAMEAT] = {},
[IORING_OP_UNLINKAT] = {},
[IORING_OP_MKDIRAT] = {},
@@ -1449,6 +1450,8 @@ const char *io_uring_get_opcode(u8 opcode)
return "TEE";
case IORING_OP_SHUTDOWN:
return "SHUTDOWN";
+ case IORING_OP_RENAME:
+ return "RENAME";
case IORING_OP_RENAMEAT:
return "RENAMEAT";
case IORING_OP_UNLINKAT:
@@ -4553,8 +4556,8 @@ static int io_write(struct io_kiocb *req, unsigned int issue_flags)
return ret;
}
-static int io_renameat_prep(struct io_kiocb *req,
- const struct io_uring_sqe *sqe)
+static int io_rename_prep(struct io_kiocb *req,
+ const struct io_uring_sqe *sqe, bool is_cwd)
{
struct io_rename *ren = &req->rename;
const char __user *oldf, *newf;
@@ -4564,10 +4567,14 @@ static int io_renameat_prep(struct io_kiocb *req,
if (unlikely(req->flags & REQ_F_FIXED_FILE))
return -EBADF;
- ren->old_dfd = READ_ONCE(sqe->fd);
+ if (is_cwd) {
+ ren->old_dfd = ren->new_dfd = AT_FDCWD;
+ } else {
+ ren->old_dfd = READ_ONCE(sqe->fd);
+ ren->new_dfd = READ_ONCE(sqe->len);
+ }
oldf = u64_to_user_ptr(READ_ONCE(sqe->addr));
newf = u64_to_user_ptr(READ_ONCE(sqe->addr2));
- ren->new_dfd = READ_ONCE(sqe->len);
ren->flags = READ_ONCE(sqe->rename_flags);
ren->oldpath = getname(oldf);
@@ -4584,7 +4591,7 @@ static int io_renameat_prep(struct io_kiocb *req,
return 0;
}
-static int io_renameat(struct io_kiocb *req, unsigned int issue_flags)
+static int io_rename(struct io_kiocb *req, unsigned int issue_flags)
{
struct io_rename *ren = &req->rename;
int ret;
@@ -8076,8 +8083,10 @@ static int io_req_prep(struct io_kiocb *req, const struct io_uring_sqe *sqe)
return io_tee_prep(req, sqe);
case IORING_OP_SHUTDOWN:
return io_shutdown_prep(req, sqe);
+ case IORING_OP_RENAME:
+ return io_rename_prep(req, sqe, 1);
case IORING_OP_RENAMEAT:
- return io_renameat_prep(req, sqe);
+ return io_rename_prep(req, sqe, 0);
case IORING_OP_UNLINKAT:
return io_unlinkat_prep(req, sqe);
case IORING_OP_MKDIRAT:
@@ -8229,6 +8238,7 @@ static void io_clean_op(struct io_kiocb *req)
if (req->open.filename)
putname(req->open.filename);
break;
+ case IORING_OP_RENAME:
case IORING_OP_RENAMEAT:
putname(req->rename.oldpath);
putname(req->rename.newpath);
@@ -8395,8 +8405,9 @@ static int io_issue_sqe(struct io_kiocb *req, unsigned int issue_flags)
case IORING_OP_SHUTDOWN:
ret = io_shutdown(req, issue_flags);
break;
+ case IORING_OP_RENAME:
case IORING_OP_RENAMEAT:
- ret = io_renameat(req, issue_flags);
+ ret = io_rename(req, issue_flags);
break;
case IORING_OP_UNLINKAT:
ret = io_unlinkat(req, issue_flags);
diff --git a/include/uapi/linux/io_uring.h b/include/uapi/linux/io_uring.h
index 53e7dae92e42..73f4e1c4133d 100644
--- a/include/uapi/linux/io_uring.h
+++ b/include/uapi/linux/io_uring.h
@@ -189,6 +189,7 @@ enum io_uring_op {
IORING_OP_GETXATTR,
IORING_OP_SOCKET,
IORING_OP_URING_CMD,
+ IORING_OP_RENAME,
/* this goes last, obviously */
IORING_OP_LAST,
--
2.25.1
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [PATCH 2/5] io_uring: add unlink opcode for current working directory
2022-05-31 18:41 [PATCH 0/5] io_uring: add opcodes for current working directory Usama Arif
2022-05-31 18:41 ` [PATCH 1/5] io_uring: add rename opcode " Usama Arif
@ 2022-05-31 18:41 ` Usama Arif
2022-05-31 18:41 ` [PATCH 3/5] io_uring: add mkdir " Usama Arif
` (3 subsequent siblings)
5 siblings, 0 replies; 11+ messages in thread
From: Usama Arif @ 2022-05-31 18:41 UTC (permalink / raw)
To: io-uring, axboe, linux-kernel; +Cc: fam.zheng, Usama Arif
This provides consistency between io_uring and the respective I/O syscall
and avoids having the user of liburing specify the cwd in sqe for
IORING_OP_UNLINKAT.
Signed-off-by: Usama Arif <[email protected]>
---
fs/io_uring.c | 22 ++++++++++++++++------
include/uapi/linux/io_uring.h | 1 +
2 files changed, 17 insertions(+), 6 deletions(-)
diff --git a/fs/io_uring.c b/fs/io_uring.c
index 8bf56523ff7f..d38c5f54f6a4 100644
--- a/fs/io_uring.c
+++ b/fs/io_uring.c
@@ -1308,6 +1308,7 @@ static const struct io_op_def io_op_defs[] = {
},
[IORING_OP_RENAME] = {},
[IORING_OP_RENAMEAT] = {},
+ [IORING_OP_UNLINK] = {},
[IORING_OP_UNLINKAT] = {},
[IORING_OP_MKDIRAT] = {},
[IORING_OP_SYMLINKAT] = {},
@@ -1454,6 +1455,8 @@ const char *io_uring_get_opcode(u8 opcode)
return "RENAME";
case IORING_OP_RENAMEAT:
return "RENAMEAT";
+ case IORING_OP_UNLINK:
+ return "UNLINK";
case IORING_OP_UNLINKAT:
return "UNLINKAT";
case IORING_OP_MKDIRAT:
@@ -4847,8 +4850,8 @@ static int io_setxattr(struct io_kiocb *req, unsigned int issue_flags)
return 0;
}
-static int io_unlinkat_prep(struct io_kiocb *req,
- const struct io_uring_sqe *sqe)
+static int io_unlink_prep(struct io_kiocb *req,
+ const struct io_uring_sqe *sqe, bool is_cwd)
{
struct io_unlink *un = &req->unlink;
const char __user *fname;
@@ -4858,7 +4861,10 @@ static int io_unlinkat_prep(struct io_kiocb *req,
if (unlikely(req->flags & REQ_F_FIXED_FILE))
return -EBADF;
- un->dfd = READ_ONCE(sqe->fd);
+ if (is_cwd)
+ un->dfd = AT_FDCWD;
+ else
+ un->dfd = READ_ONCE(sqe->fd);
un->flags = READ_ONCE(sqe->unlink_flags);
if (un->flags & ~AT_REMOVEDIR)
@@ -4873,7 +4879,7 @@ static int io_unlinkat_prep(struct io_kiocb *req,
return 0;
}
-static int io_unlinkat(struct io_kiocb *req, unsigned int issue_flags)
+static int io_unlink(struct io_kiocb *req, unsigned int issue_flags)
{
struct io_unlink *un = &req->unlink;
int ret;
@@ -8087,8 +8093,10 @@ static int io_req_prep(struct io_kiocb *req, const struct io_uring_sqe *sqe)
return io_rename_prep(req, sqe, 1);
case IORING_OP_RENAMEAT:
return io_rename_prep(req, sqe, 0);
+ case IORING_OP_UNLINK:
+ return io_unlink_prep(req, sqe, 1);
case IORING_OP_UNLINKAT:
- return io_unlinkat_prep(req, sqe);
+ return io_unlink_prep(req, sqe, 0);
case IORING_OP_MKDIRAT:
return io_mkdirat_prep(req, sqe);
case IORING_OP_SYMLINKAT:
@@ -8243,6 +8251,7 @@ static void io_clean_op(struct io_kiocb *req)
putname(req->rename.oldpath);
putname(req->rename.newpath);
break;
+ case IORING_OP_UNLINK:
case IORING_OP_UNLINKAT:
putname(req->unlink.filename);
break;
@@ -8409,8 +8418,9 @@ static int io_issue_sqe(struct io_kiocb *req, unsigned int issue_flags)
case IORING_OP_RENAMEAT:
ret = io_rename(req, issue_flags);
break;
+ case IORING_OP_UNLINK:
case IORING_OP_UNLINKAT:
- ret = io_unlinkat(req, issue_flags);
+ ret = io_unlink(req, issue_flags);
break;
case IORING_OP_MKDIRAT:
ret = io_mkdirat(req, issue_flags);
diff --git a/include/uapi/linux/io_uring.h b/include/uapi/linux/io_uring.h
index 73f4e1c4133d..7828b7183d01 100644
--- a/include/uapi/linux/io_uring.h
+++ b/include/uapi/linux/io_uring.h
@@ -190,6 +190,7 @@ enum io_uring_op {
IORING_OP_SOCKET,
IORING_OP_URING_CMD,
IORING_OP_RENAME,
+ IORING_OP_UNLINK,
/* this goes last, obviously */
IORING_OP_LAST,
--
2.25.1
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [PATCH 3/5] io_uring: add mkdir opcode for current working directory
2022-05-31 18:41 [PATCH 0/5] io_uring: add opcodes for current working directory Usama Arif
2022-05-31 18:41 ` [PATCH 1/5] io_uring: add rename opcode " Usama Arif
2022-05-31 18:41 ` [PATCH 2/5] io_uring: add unlink " Usama Arif
@ 2022-05-31 18:41 ` Usama Arif
2022-05-31 18:41 ` [PATCH 4/5] io_uring: add symlink " Usama Arif
` (2 subsequent siblings)
5 siblings, 0 replies; 11+ messages in thread
From: Usama Arif @ 2022-05-31 18:41 UTC (permalink / raw)
To: io-uring, axboe, linux-kernel; +Cc: fam.zheng, Usama Arif
This provides consistency between io_uring and the respective I/O syscall
and avoids having the user of liburing specify the cwd in sqe for
IORING_OP_MKDIRAT.
Signed-off-by: Usama Arif <[email protected]>
---
fs/io_uring.c | 20 +++++++++++++++-----
include/uapi/linux/io_uring.h | 1 +
2 files changed, 16 insertions(+), 5 deletions(-)
diff --git a/fs/io_uring.c b/fs/io_uring.c
index d38c5f54f6a4..9c9fa0b3938d 100644
--- a/fs/io_uring.c
+++ b/fs/io_uring.c
@@ -1310,6 +1310,7 @@ static const struct io_op_def io_op_defs[] = {
[IORING_OP_RENAMEAT] = {},
[IORING_OP_UNLINK] = {},
[IORING_OP_UNLINKAT] = {},
+ [IORING_OP_MKDIR] = {},
[IORING_OP_MKDIRAT] = {},
[IORING_OP_SYMLINKAT] = {},
[IORING_OP_LINKAT] = {},
@@ -1459,6 +1460,8 @@ const char *io_uring_get_opcode(u8 opcode)
return "UNLINK";
case IORING_OP_UNLINKAT:
return "UNLINKAT";
+ case IORING_OP_MKDIR:
+ return "MKDIR";
case IORING_OP_MKDIRAT:
return "MKDIRAT";
case IORING_OP_SYMLINKAT:
@@ -4897,8 +4900,8 @@ static int io_unlink(struct io_kiocb *req, unsigned int issue_flags)
return 0;
}
-static int io_mkdirat_prep(struct io_kiocb *req,
- const struct io_uring_sqe *sqe)
+static int io_mkdir_prep(struct io_kiocb *req,
+ const struct io_uring_sqe *sqe, bool is_cwd)
{
struct io_mkdir *mkd = &req->mkdir;
const char __user *fname;
@@ -4908,7 +4911,10 @@ static int io_mkdirat_prep(struct io_kiocb *req,
if (unlikely(req->flags & REQ_F_FIXED_FILE))
return -EBADF;
- mkd->dfd = READ_ONCE(sqe->fd);
+ if (is_cwd)
+ mkd->dfd = AT_FDCWD;
+ else
+ mkd->dfd = READ_ONCE(sqe->fd);
mkd->mode = READ_ONCE(sqe->len);
fname = u64_to_user_ptr(READ_ONCE(sqe->addr));
@@ -4920,7 +4926,7 @@ static int io_mkdirat_prep(struct io_kiocb *req,
return 0;
}
-static int io_mkdirat(struct io_kiocb *req, unsigned int issue_flags)
+static int io_mkdir(struct io_kiocb *req, unsigned int issue_flags)
{
struct io_mkdir *mkd = &req->mkdir;
int ret;
@@ -8097,8 +8103,10 @@ static int io_req_prep(struct io_kiocb *req, const struct io_uring_sqe *sqe)
return io_unlink_prep(req, sqe, 1);
case IORING_OP_UNLINKAT:
return io_unlink_prep(req, sqe, 0);
+ case IORING_OP_MKDIR:
+ return io_mkdir_prep(req, sqe, 1);
case IORING_OP_MKDIRAT:
- return io_mkdirat_prep(req, sqe);
+ return io_mkdir_prep(req, sqe, 0);
case IORING_OP_SYMLINKAT:
return io_symlinkat_prep(req, sqe);
case IORING_OP_LINKAT:
@@ -8255,6 +8263,7 @@ static void io_clean_op(struct io_kiocb *req)
case IORING_OP_UNLINKAT:
putname(req->unlink.filename);
break;
+ case IORING_OP_MKDIR:
case IORING_OP_MKDIRAT:
putname(req->mkdir.filename);
break;
@@ -8422,6 +8431,7 @@ static int io_issue_sqe(struct io_kiocb *req, unsigned int issue_flags)
case IORING_OP_UNLINKAT:
ret = io_unlink(req, issue_flags);
break;
+ case IORING_OP_MKDIR:
case IORING_OP_MKDIRAT:
ret = io_mkdirat(req, issue_flags);
break;
diff --git a/include/uapi/linux/io_uring.h b/include/uapi/linux/io_uring.h
index 7828b7183d01..58f2e0611152 100644
--- a/include/uapi/linux/io_uring.h
+++ b/include/uapi/linux/io_uring.h
@@ -191,6 +191,7 @@ enum io_uring_op {
IORING_OP_URING_CMD,
IORING_OP_RENAME,
IORING_OP_UNLINK,
+ IORING_OP_MKDIR,
/* this goes last, obviously */
IORING_OP_LAST,
--
2.25.1
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [PATCH 4/5] io_uring: add symlink opcode for current working directory
2022-05-31 18:41 [PATCH 0/5] io_uring: add opcodes for current working directory Usama Arif
` (2 preceding siblings ...)
2022-05-31 18:41 ` [PATCH 3/5] io_uring: add mkdir " Usama Arif
@ 2022-05-31 18:41 ` Usama Arif
2022-05-31 18:41 ` [PATCH 5/5] io_uring: add link " Usama Arif
2022-05-31 18:58 ` [PATCH 0/5] io_uring: add opcodes " Jens Axboe
5 siblings, 0 replies; 11+ messages in thread
From: Usama Arif @ 2022-05-31 18:41 UTC (permalink / raw)
To: io-uring, axboe, linux-kernel; +Cc: fam.zheng, Usama Arif
This provides consistency between io_uring and the respective I/O syscall
and avoids having the user of liburing specify the cwd in sqe for
IORING_OP_SYMLINKAT.
Signed-off-by: Usama Arif <[email protected]>
---
fs/io_uring.c | 20 +++++++++++++++-----
include/uapi/linux/io_uring.h | 1 +
2 files changed, 16 insertions(+), 5 deletions(-)
diff --git a/fs/io_uring.c b/fs/io_uring.c
index 9c9fa0b3938d..4050377619d3 100644
--- a/fs/io_uring.c
+++ b/fs/io_uring.c
@@ -1312,6 +1312,7 @@ static const struct io_op_def io_op_defs[] = {
[IORING_OP_UNLINKAT] = {},
[IORING_OP_MKDIR] = {},
[IORING_OP_MKDIRAT] = {},
+ [IORING_OP_SYMLINK] = {},
[IORING_OP_SYMLINKAT] = {},
[IORING_OP_LINKAT] = {},
[IORING_OP_MSG_RING] = {
@@ -1464,6 +1465,8 @@ const char *io_uring_get_opcode(u8 opcode)
return "MKDIR";
case IORING_OP_MKDIRAT:
return "MKDIRAT";
+ case IORING_OP_SYMLINK:
+ return "SYMLINK";
case IORING_OP_SYMLINKAT:
return "SYMLINKAT";
case IORING_OP_LINKAT:
@@ -4941,8 +4944,8 @@ static int io_mkdir(struct io_kiocb *req, unsigned int issue_flags)
return 0;
}
-static int io_symlinkat_prep(struct io_kiocb *req,
- const struct io_uring_sqe *sqe)
+static int io_symlink_prep(struct io_kiocb *req,
+ const struct io_uring_sqe *sqe, bool is_cwd)
{
struct io_symlink *sl = &req->symlink;
const char __user *oldpath, *newpath;
@@ -4952,7 +4955,10 @@ static int io_symlinkat_prep(struct io_kiocb *req,
if (unlikely(req->flags & REQ_F_FIXED_FILE))
return -EBADF;
- sl->new_dfd = READ_ONCE(sqe->fd);
+ if (is_cwd)
+ sl->new_dfd = AT_FDCWD;
+ else
+ sl->new_dfd = READ_ONCE(sqe->fd);
oldpath = u64_to_user_ptr(READ_ONCE(sqe->addr));
newpath = u64_to_user_ptr(READ_ONCE(sqe->addr2));
@@ -4970,7 +4976,7 @@ static int io_symlinkat_prep(struct io_kiocb *req,
return 0;
}
-static int io_symlinkat(struct io_kiocb *req, unsigned int issue_flags)
+static int io_symlink(struct io_kiocb *req, unsigned int issue_flags)
{
struct io_symlink *sl = &req->symlink;
int ret;
@@ -8107,8 +8113,10 @@ static int io_req_prep(struct io_kiocb *req, const struct io_uring_sqe *sqe)
return io_mkdir_prep(req, sqe, 1);
case IORING_OP_MKDIRAT:
return io_mkdir_prep(req, sqe, 0);
+ case IORING_OP_SYMLINK:
+ return io_symlink_prep(req, sqe, 1);
case IORING_OP_SYMLINKAT:
- return io_symlinkat_prep(req, sqe);
+ return io_symlink_prep(req, sqe, 0);
case IORING_OP_LINKAT:
return io_linkat_prep(req, sqe);
case IORING_OP_MSG_RING:
@@ -8267,6 +8275,7 @@ static void io_clean_op(struct io_kiocb *req)
case IORING_OP_MKDIRAT:
putname(req->mkdir.filename);
break;
+ case IORING_OP_SYMLINK:
case IORING_OP_SYMLINKAT:
putname(req->symlink.oldpath);
putname(req->symlink.newpath);
@@ -8435,6 +8444,7 @@ static int io_issue_sqe(struct io_kiocb *req, unsigned int issue_flags)
case IORING_OP_MKDIRAT:
ret = io_mkdirat(req, issue_flags);
break;
+ case IORING_OP_SYMLINK:
case IORING_OP_SYMLINKAT:
ret = io_symlinkat(req, issue_flags);
break;
diff --git a/include/uapi/linux/io_uring.h b/include/uapi/linux/io_uring.h
index 58f2e0611152..74e6b70638ee 100644
--- a/include/uapi/linux/io_uring.h
+++ b/include/uapi/linux/io_uring.h
@@ -192,6 +192,7 @@ enum io_uring_op {
IORING_OP_RENAME,
IORING_OP_UNLINK,
IORING_OP_MKDIR,
+ IORING_OP_SYMLINK,
/* this goes last, obviously */
IORING_OP_LAST,
--
2.25.1
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [PATCH 5/5] io_uring: add link opcode for current working directory
2022-05-31 18:41 [PATCH 0/5] io_uring: add opcodes for current working directory Usama Arif
` (3 preceding siblings ...)
2022-05-31 18:41 ` [PATCH 4/5] io_uring: add symlink " Usama Arif
@ 2022-05-31 18:41 ` Usama Arif
2022-05-31 18:58 ` [PATCH 0/5] io_uring: add opcodes " Jens Axboe
5 siblings, 0 replies; 11+ messages in thread
From: Usama Arif @ 2022-05-31 18:41 UTC (permalink / raw)
To: io-uring, axboe, linux-kernel; +Cc: fam.zheng, Usama Arif
This provides consistency between io_uring and the respective I/O syscall
and avoids having the user of liburing specify the cwd in sqe for
IORING_OP_LINKAT.
Signed-off-by: Usama Arif <[email protected]>
---
fs/io_uring.c | 29 ++++++++++++++++++++---------
include/uapi/linux/io_uring.h | 1 +
2 files changed, 21 insertions(+), 9 deletions(-)
diff --git a/fs/io_uring.c b/fs/io_uring.c
index 4050377619d3..31dfad3a7312 100644
--- a/fs/io_uring.c
+++ b/fs/io_uring.c
@@ -1314,6 +1314,7 @@ static const struct io_op_def io_op_defs[] = {
[IORING_OP_MKDIRAT] = {},
[IORING_OP_SYMLINK] = {},
[IORING_OP_SYMLINKAT] = {},
+ [IORING_OP_LINK] = {},
[IORING_OP_LINKAT] = {},
[IORING_OP_MSG_RING] = {
.needs_file = 1,
@@ -1469,6 +1470,8 @@ const char *io_uring_get_opcode(u8 opcode)
return "SYMLINK";
case IORING_OP_SYMLINKAT:
return "SYMLINKAT";
+ case IORING_OP_LINK:
+ return "LINK";
case IORING_OP_LINKAT:
return "LINKAT";
case IORING_OP_MSG_RING:
@@ -4991,8 +4994,8 @@ static int io_symlink(struct io_kiocb *req, unsigned int issue_flags)
return 0;
}
-static int io_linkat_prep(struct io_kiocb *req,
- const struct io_uring_sqe *sqe)
+static int io_link_prep(struct io_kiocb *req,
+ const struct io_uring_sqe *sqe, bool is_cwd)
{
struct io_hardlink *lnk = &req->hardlink;
const char __user *oldf, *newf;
@@ -5002,8 +5005,12 @@ static int io_linkat_prep(struct io_kiocb *req,
if (unlikely(req->flags & REQ_F_FIXED_FILE))
return -EBADF;
- lnk->old_dfd = READ_ONCE(sqe->fd);
- lnk->new_dfd = READ_ONCE(sqe->len);
+ if (is_cwd) {
+ lnk->old_dfd = lnk->new_dfd = AT_FDCWD;
+ } else {
+ lnk->old_dfd = READ_ONCE(sqe->fd);
+ lnk->new_dfd = READ_ONCE(sqe->len);
+ }
oldf = u64_to_user_ptr(READ_ONCE(sqe->addr));
newf = u64_to_user_ptr(READ_ONCE(sqe->addr2));
lnk->flags = READ_ONCE(sqe->hardlink_flags);
@@ -5022,7 +5029,7 @@ static int io_linkat_prep(struct io_kiocb *req,
return 0;
}
-static int io_linkat(struct io_kiocb *req, unsigned int issue_flags)
+static int io_link(struct io_kiocb *req, unsigned int issue_flags)
{
struct io_hardlink *lnk = &req->hardlink;
int ret;
@@ -8117,8 +8124,10 @@ static int io_req_prep(struct io_kiocb *req, const struct io_uring_sqe *sqe)
return io_symlink_prep(req, sqe, 1);
case IORING_OP_SYMLINKAT:
return io_symlink_prep(req, sqe, 0);
+ case IORING_OP_LINK:
+ return io_link_prep(req, sqe, 1);
case IORING_OP_LINKAT:
- return io_linkat_prep(req, sqe);
+ return io_link_prep(req, sqe, 0);
case IORING_OP_MSG_RING:
return io_msg_ring_prep(req, sqe);
case IORING_OP_FSETXATTR:
@@ -8280,6 +8289,7 @@ static void io_clean_op(struct io_kiocb *req)
putname(req->symlink.oldpath);
putname(req->symlink.newpath);
break;
+ case IORING_OP_LINK:
case IORING_OP_LINKAT:
putname(req->hardlink.oldpath);
putname(req->hardlink.newpath);
@@ -8442,14 +8452,15 @@ static int io_issue_sqe(struct io_kiocb *req, unsigned int issue_flags)
break;
case IORING_OP_MKDIR:
case IORING_OP_MKDIRAT:
- ret = io_mkdirat(req, issue_flags);
+ ret = io_mkdir(req, issue_flags);
break;
case IORING_OP_SYMLINK:
case IORING_OP_SYMLINKAT:
- ret = io_symlinkat(req, issue_flags);
+ ret = io_symlink(req, issue_flags);
break;
+ case IORING_OP_LINK:
case IORING_OP_LINKAT:
- ret = io_linkat(req, issue_flags);
+ ret = io_link(req, issue_flags);
break;
case IORING_OP_MSG_RING:
ret = io_msg_ring(req, issue_flags);
diff --git a/include/uapi/linux/io_uring.h b/include/uapi/linux/io_uring.h
index 74e6b70638ee..41391a762ad1 100644
--- a/include/uapi/linux/io_uring.h
+++ b/include/uapi/linux/io_uring.h
@@ -193,6 +193,7 @@ enum io_uring_op {
IORING_OP_UNLINK,
IORING_OP_MKDIR,
IORING_OP_SYMLINK,
+ IORING_OP_LINK,
/* this goes last, obviously */
IORING_OP_LAST,
--
2.25.1
^ permalink raw reply related [flat|nested] 11+ messages in thread
* Re: [PATCH 0/5] io_uring: add opcodes for current working directory
2022-05-31 18:41 [PATCH 0/5] io_uring: add opcodes for current working directory Usama Arif
` (4 preceding siblings ...)
2022-05-31 18:41 ` [PATCH 5/5] io_uring: add link " Usama Arif
@ 2022-05-31 18:58 ` Jens Axboe
2022-05-31 19:18 ` [External] " Usama Arif
5 siblings, 1 reply; 11+ messages in thread
From: Jens Axboe @ 2022-05-31 18:58 UTC (permalink / raw)
To: Usama Arif, io-uring, linux-kernel; +Cc: fam.zheng
On 5/31/22 12:41 PM, Usama Arif wrote:
> This provides consistency between io_uring and the respective I/O syscall
> and avoids having the user of liburing specify the cwd in sqe when working
> with current working directory, for e.g. the user can directly call with
> IORING_OP_RENAME instead of IORING_OP_RENAMEAT and providing AT_FDCWD in
> sqe->fd and sqe->len, similar to syscall interface.
>
> This is done for rename, unlink, mkdir, symlink and link in this
> patch-series.
>
> The tests for these opcodes in liburing are present at
> https://github.com/uarif1/liburing/tree/cwd_opcodes. If the patches are
> acceptable, I am happy to create a PR in above for the tests.
Can't we just provide prep helpers for them in liburing?
--
Jens Axboe
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [External] Re: [PATCH 0/5] io_uring: add opcodes for current working directory
2022-05-31 18:58 ` [PATCH 0/5] io_uring: add opcodes " Jens Axboe
@ 2022-05-31 19:18 ` Usama Arif
2022-05-31 19:22 ` Jens Axboe
0 siblings, 1 reply; 11+ messages in thread
From: Usama Arif @ 2022-05-31 19:18 UTC (permalink / raw)
To: Jens Axboe, io-uring, linux-kernel; +Cc: fam.zheng
On 31/05/2022 19:58, Jens Axboe wrote:
> On 5/31/22 12:41 PM, Usama Arif wrote:
>> This provides consistency between io_uring and the respective I/O syscall
>> and avoids having the user of liburing specify the cwd in sqe when working
>> with current working directory, for e.g. the user can directly call with
>> IORING_OP_RENAME instead of IORING_OP_RENAMEAT and providing AT_FDCWD in
>> sqe->fd and sqe->len, similar to syscall interface.
>>
>> This is done for rename, unlink, mkdir, symlink and link in this
>> patch-series.
>>
>> The tests for these opcodes in liburing are present at
>> https://github.com/uarif1/liburing/tree/cwd_opcodes. If the patches are
>> acceptable, I am happy to create a PR in above for the tests.
>
> Can't we just provide prep helpers for them in liburing?
>
We could add a io_uring_prep_unlink with IORING_OP_UNLINKAT and AT_FDCWD
in liburing. But i guess adding in kernel adds a more consistent
interface? and allows to make calls bypassing liburing (although i guess
people probably don't bypass liburing that much :))
Making the changes in both kernel and liburing provides more of a
standard interface in my opinion so maybe it looks better. But happy to
just create a PR in liburing only with prep helpers as you suggested if
you think that is better?
Thanks!
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [External] Re: [PATCH 0/5] io_uring: add opcodes for current working directory
2022-05-31 19:18 ` [External] " Usama Arif
@ 2022-05-31 19:22 ` Jens Axboe
2022-05-31 21:35 ` Usama Arif
0 siblings, 1 reply; 11+ messages in thread
From: Jens Axboe @ 2022-05-31 19:22 UTC (permalink / raw)
To: Usama Arif, io-uring, linux-kernel; +Cc: fam.zheng
On 5/31/22 1:18 PM, Usama Arif wrote:
>
>
> On 31/05/2022 19:58, Jens Axboe wrote:
>> On 5/31/22 12:41 PM, Usama Arif wrote:
>>> This provides consistency between io_uring and the respective I/O syscall
>>> and avoids having the user of liburing specify the cwd in sqe when working
>>> with current working directory, for e.g. the user can directly call with
>>> IORING_OP_RENAME instead of IORING_OP_RENAMEAT and providing AT_FDCWD in
>>> sqe->fd and sqe->len, similar to syscall interface.
>>>
>>> This is done for rename, unlink, mkdir, symlink and link in this
>>> patch-series.
>>>
>>> The tests for these opcodes in liburing are present at
>>> https://github.com/uarif1/liburing/tree/cwd_opcodes. If the patches are
>>> acceptable, I am happy to create a PR in above for the tests.
>>
>> Can't we just provide prep helpers for them in liburing?
>>
>
> We could add a io_uring_prep_unlink with IORING_OP_UNLINKAT and
> AT_FDCWD in liburing. But i guess adding in kernel adds a more
> consistent interface? and allows to make calls bypassing liburing
> (although i guess people probably don't bypass liburing that much :))
I'm not really aware of much that doesn't use the library, and even
those would most likely use the liburing man pages as that's all we
have. The kernel API is raw. If you use that, I would expect you to know
that you can just use AT_FDCWD!
> Making the changes in both kernel and liburing provides more of a
> standard interface in my opinion so maybe it looks better. But happy
> to just create a PR in liburing only with prep helpers as you
> suggested if you think that is better?
I don't disagree with that, but it seems silly to waste 5 opcodes on
something that is a strict subset of something that is already there.
Hence my suggestion would be to just add io_uring_prep_link() etc
helpers to make it simpler to use, without having to add 5 extra
opcodes.
--
Jens Axboe
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH 0/5] io_uring: add opcodes for current working directory
2022-05-31 19:22 ` Jens Axboe
@ 2022-05-31 21:35 ` Usama Arif
2022-06-01 2:57 ` Jens Axboe
0 siblings, 1 reply; 11+ messages in thread
From: Usama Arif @ 2022-05-31 21:35 UTC (permalink / raw)
To: Jens Axboe, io-uring, linux-kernel; +Cc: fam.zheng
On 31/05/2022 20:22, Jens Axboe wrote:
> On 5/31/22 1:18 PM, Usama Arif wrote:
>>
>>
>> On 31/05/2022 19:58, Jens Axboe wrote:
>>> On 5/31/22 12:41 PM, Usama Arif wrote:
>>>> This provides consistency between io_uring and the respective I/O syscall
>>>> and avoids having the user of liburing specify the cwd in sqe when working
>>>> with current working directory, for e.g. the user can directly call with
>>>> IORING_OP_RENAME instead of IORING_OP_RENAMEAT and providing AT_FDCWD in
>>>> sqe->fd and sqe->len, similar to syscall interface.
>>>>
>>>> This is done for rename, unlink, mkdir, symlink and link in this
>>>> patch-series.
>>>>
>>>> The tests for these opcodes in liburing are present at
>>>> https://github.com/uarif1/liburing/tree/cwd_opcodes. If the patches are
>>>> acceptable, I am happy to create a PR in above for the tests.
>>>
>>> Can't we just provide prep helpers for them in liburing?
>>>
>>
>> We could add a io_uring_prep_unlink with IORING_OP_UNLINKAT and
>> AT_FDCWD in liburing. But i guess adding in kernel adds a more
>> consistent interface? and allows to make calls bypassing liburing
>> (although i guess people probably don't bypass liburing that much :))
>
> I'm not really aware of much that doesn't use the library, and even
> those would most likely use the liburing man pages as that's all we
> have. The kernel API is raw. If you use that, I would expect you to know
> that you can just use AT_FDCWD!
>
>> Making the changes in both kernel and liburing provides more of a
>> standard interface in my opinion so maybe it looks better. But happy
>> to just create a PR in liburing only with prep helpers as you
>> suggested if you think that is better?
>
> I don't disagree with that, but it seems silly to waste 5 opcodes on
> something that is a strict subset of something that is already there.
> Hence my suggestion would be to just add io_uring_prep_link() etc
> helpers to make it simpler to use, without having to add 5 extra
> opcodes.
>
Thanks, I have created a PR for it on
https://github.com/axboe/liburing/pull/588. We can review it there if it
makes sense!
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH 0/5] io_uring: add opcodes for current working directory
2022-05-31 21:35 ` Usama Arif
@ 2022-06-01 2:57 ` Jens Axboe
0 siblings, 0 replies; 11+ messages in thread
From: Jens Axboe @ 2022-06-01 2:57 UTC (permalink / raw)
To: Usama Arif, io-uring, linux-kernel; +Cc: fam.zheng
On 5/31/22 3:35 PM, Usama Arif wrote:
>
>
> On 31/05/2022 20:22, Jens Axboe wrote:
>> On 5/31/22 1:18 PM, Usama Arif wrote:
>>>
>>>
>>> On 31/05/2022 19:58, Jens Axboe wrote:
>>>> On 5/31/22 12:41 PM, Usama Arif wrote:
>>>>> This provides consistency between io_uring and the respective I/O syscall
>>>>> and avoids having the user of liburing specify the cwd in sqe when working
>>>>> with current working directory, for e.g. the user can directly call with
>>>>> IORING_OP_RENAME instead of IORING_OP_RENAMEAT and providing AT_FDCWD in
>>>>> sqe->fd and sqe->len, similar to syscall interface.
>>>>>
>>>>> This is done for rename, unlink, mkdir, symlink and link in this
>>>>> patch-series.
>>>>>
>>>>> The tests for these opcodes in liburing are present at
>>>>> https://github.com/uarif1/liburing/tree/cwd_opcodes. If the patches are
>>>>> acceptable, I am happy to create a PR in above for the tests.
>>>>
>>>> Can't we just provide prep helpers for them in liburing?
>>>>
>>>
>>> We could add a io_uring_prep_unlink with IORING_OP_UNLINKAT and
>>> AT_FDCWD in liburing. But i guess adding in kernel adds a more
>>> consistent interface? and allows to make calls bypassing liburing
>>> (although i guess people probably don't bypass liburing that much :))
>>
>> I'm not really aware of much that doesn't use the library, and even
>> those would most likely use the liburing man pages as that's all we
>> have. The kernel API is raw. If you use that, I would expect you to know
>> that you can just use AT_FDCWD!
>>
>>> Making the changes in both kernel and liburing provides more of a
>>> standard interface in my opinion so maybe it looks better. But happy
>>> to just create a PR in liburing only with prep helpers as you
>>> suggested if you think that is better?
>>
>> I don't disagree with that, but it seems silly to waste 5 opcodes on
>> something that is a strict subset of something that is already there.
>> Hence my suggestion would be to just add io_uring_prep_link() etc
>> helpers to make it simpler to use, without having to add 5 extra
>> opcodes.
>>
>
> Thanks, I have created a PR for it on
> https://github.com/axboe/liburing/pull/588. We can review it there if
> it makes sense!
Sounds good, we'll move it there.
--
Jens Axboe
^ permalink raw reply [flat|nested] 11+ messages in thread