* [PATCH v2 0/2] io_uring: add mkdirat support
@ 2021-02-02 8:23 Dmitry Kadashev
2021-02-02 8:23 ` [PATCH v2 1/2] fs: make do_mkdirat() take struct filename Dmitry Kadashev
` (3 more replies)
0 siblings, 4 replies; 7+ messages in thread
From: Dmitry Kadashev @ 2021-02-02 8:23 UTC (permalink / raw)
To: Jens Axboe, Alexander Viro
Cc: Pavel Begunkov, linux-fsdevel, io-uring, Dmitry Kadashev
This adds mkdirat support to io_uring and is heavily based on recently
added renameat() / unlinkat() support.
The first patch is preparation with no functional changes, makes
do_mkdirat accept struct filename pointer rather than the user string.
The second one leverages that to implement mkdirat in io_uring.
Based on for-5.11/io_uring.
Changes since v1:
- do not mess with struct filename's refcount in do_mkdirat, instead add
and use __filename_create() that does not drop the name on success;
Dmitry Kadashev (2):
fs: make do_mkdirat() take struct filename
io_uring: add support for IORING_OP_MKDIRAT
fs/internal.h | 1 +
fs/io_uring.c | 58 +++++++++++++++++++++++++++++++++++
fs/namei.c | 25 +++++++++++----
include/uapi/linux/io_uring.h | 1 +
4 files changed, 79 insertions(+), 6 deletions(-)
--
2.30.0
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH v2 1/2] fs: make do_mkdirat() take struct filename
2021-02-02 8:23 [PATCH v2 0/2] io_uring: add mkdirat support Dmitry Kadashev
@ 2021-02-02 8:23 ` Dmitry Kadashev
2021-02-12 9:42 ` Dmitry Kadashev
2021-02-02 8:23 ` [PATCH v2 2/2] io_uring: add support for IORING_OP_MKDIRAT Dmitry Kadashev
` (2 subsequent siblings)
3 siblings, 1 reply; 7+ messages in thread
From: Dmitry Kadashev @ 2021-02-02 8:23 UTC (permalink / raw)
To: Jens Axboe, Alexander Viro
Cc: Pavel Begunkov, linux-fsdevel, io-uring, Dmitry Kadashev
Pass in the struct filename pointers instead of the user string, and
update the three callers to do the same. This is heavily based on
commit dbea8d345177 ("fs: make do_renameat2() take struct filename").
This behaves like do_unlinkat() and do_renameat2().
Cc: Al Viro <[email protected]>
Signed-off-by: Dmitry Kadashev <[email protected]>
---
fs/internal.h | 1 +
fs/namei.c | 25 +++++++++++++++++++------
2 files changed, 20 insertions(+), 6 deletions(-)
diff --git a/fs/internal.h b/fs/internal.h
index c6c85f6ad598..b10005dfaa48 100644
--- a/fs/internal.h
+++ b/fs/internal.h
@@ -76,6 +76,7 @@ long do_unlinkat(int dfd, struct filename *name);
int may_linkat(struct path *link);
int do_renameat2(int olddfd, struct filename *oldname, int newdfd,
struct filename *newname, unsigned int flags);
+long do_mkdirat(int dfd, struct filename *name, umode_t mode);
/*
* namespace.c
diff --git a/fs/namei.c b/fs/namei.c
index 4cae88733a5c..3657bdf1aafc 100644
--- a/fs/namei.c
+++ b/fs/namei.c
@@ -3431,7 +3431,7 @@ struct file *do_file_open_root(struct dentry *dentry, struct vfsmount *mnt,
return file;
}
-static struct dentry *filename_create(int dfd, struct filename *name,
+static struct dentry *__filename_create(int dfd, struct filename *name,
struct path *path, unsigned int lookup_flags)
{
struct dentry *dentry = ERR_PTR(-EEXIST);
@@ -3487,7 +3487,6 @@ static struct dentry *filename_create(int dfd, struct filename *name,
error = err2;
goto fail;
}
- putname(name);
return dentry;
fail:
dput(dentry);
@@ -3502,6 +3501,16 @@ static struct dentry *filename_create(int dfd, struct filename *name,
return dentry;
}
+static inline struct dentry *filename_create(int dfd, struct filename *name,
+ struct path *path, unsigned int lookup_flags)
+{
+ struct dentry *res = __filename_create(dfd, name, path, lookup_flags);
+
+ if (!IS_ERR(res))
+ putname(name);
+ return res;
+}
+
struct dentry *kern_path_create(int dfd, const char *pathname,
struct path *path, unsigned int lookup_flags)
{
@@ -3654,15 +3663,18 @@ int vfs_mkdir(struct inode *dir, struct dentry *dentry, umode_t mode)
}
EXPORT_SYMBOL(vfs_mkdir);
-static long do_mkdirat(int dfd, const char __user *pathname, umode_t mode)
+long do_mkdirat(int dfd, struct filename *name, umode_t mode)
{
struct dentry *dentry;
struct path path;
int error;
unsigned int lookup_flags = LOOKUP_DIRECTORY;
+ if (IS_ERR(name))
+ return PTR_ERR(name);
+
retry:
- dentry = user_path_create(dfd, pathname, &path, lookup_flags);
+ dentry = __filename_create(dfd, name, &path, lookup_flags);
if (IS_ERR(dentry))
return PTR_ERR(dentry);
@@ -3676,17 +3688,18 @@ static long do_mkdirat(int dfd, const char __user *pathname, umode_t mode)
lookup_flags |= LOOKUP_REVAL;
goto retry;
}
+ putname(name);
return error;
}
SYSCALL_DEFINE3(mkdirat, int, dfd, const char __user *, pathname, umode_t, mode)
{
- return do_mkdirat(dfd, pathname, mode);
+ return do_mkdirat(dfd, getname(pathname), mode);
}
SYSCALL_DEFINE2(mkdir, const char __user *, pathname, umode_t, mode)
{
- return do_mkdirat(AT_FDCWD, pathname, mode);
+ return do_mkdirat(AT_FDCWD, getname(pathname), mode);
}
int vfs_rmdir(struct inode *dir, struct dentry *dentry)
--
2.30.0
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH v2 2/2] io_uring: add support for IORING_OP_MKDIRAT
2021-02-02 8:23 [PATCH v2 0/2] io_uring: add mkdirat support Dmitry Kadashev
2021-02-02 8:23 ` [PATCH v2 1/2] fs: make do_mkdirat() take struct filename Dmitry Kadashev
@ 2021-02-02 8:23 ` Dmitry Kadashev
2021-02-18 7:25 ` [PATCH v2 0/2] io_uring: add mkdirat support Dmitry Kadashev
2021-03-29 20:37 ` Jens Axboe
3 siblings, 0 replies; 7+ messages in thread
From: Dmitry Kadashev @ 2021-02-02 8:23 UTC (permalink / raw)
To: Jens Axboe, Alexander Viro
Cc: Pavel Begunkov, linux-fsdevel, io-uring, Dmitry Kadashev
IORING_OP_MKDIRAT behaves like mkdirat(2) and takes the same flags
and arguments.
Signed-off-by: Dmitry Kadashev <[email protected]>
---
fs/io_uring.c | 58 +++++++++++++++++++++++++++++++++++
include/uapi/linux/io_uring.h | 1 +
2 files changed, 59 insertions(+)
diff --git a/fs/io_uring.c b/fs/io_uring.c
index 24ad36d71289..000d7dce5902 100644
--- a/fs/io_uring.c
+++ b/fs/io_uring.c
@@ -582,6 +582,13 @@ struct io_unlink {
struct filename *filename;
};
+struct io_mkdir {
+ struct file *file;
+ int dfd;
+ umode_t mode;
+ struct filename *filename;
+};
+
struct io_completion {
struct file *file;
struct list_head list;
@@ -712,6 +719,7 @@ struct io_kiocb {
struct io_shutdown shutdown;
struct io_rename rename;
struct io_unlink unlink;
+ struct io_mkdir mkdir;
/* use only after cleaning per-op data, see io_clean_op() */
struct io_completion compl;
};
@@ -996,6 +1004,10 @@ static const struct io_op_def io_op_defs[] = {
.work_flags = IO_WQ_WORK_MM | IO_WQ_WORK_FILES |
IO_WQ_WORK_FS | IO_WQ_WORK_BLKCG,
},
+ [IORING_OP_MKDIRAT] = {
+ .work_flags = IO_WQ_WORK_MM | IO_WQ_WORK_FILES |
+ IO_WQ_WORK_FS | IO_WQ_WORK_BLKCG,
+ },
};
enum io_mem_account {
@@ -3805,6 +3817,44 @@ static int io_unlinkat(struct io_kiocb *req, bool force_nonblock)
return 0;
}
+static int io_mkdirat_prep(struct io_kiocb *req,
+ const struct io_uring_sqe *sqe)
+{
+ struct io_mkdir *mkd = &req->mkdir;
+ const char __user *fname;
+
+ if (unlikely(req->flags & REQ_F_FIXED_FILE))
+ return -EBADF;
+
+ mkd->dfd = READ_ONCE(sqe->fd);
+ mkd->mode = READ_ONCE(sqe->len);
+
+ fname = u64_to_user_ptr(READ_ONCE(sqe->addr));
+ mkd->filename = getname(fname);
+ if (IS_ERR(mkd->filename))
+ return PTR_ERR(mkd->filename);
+
+ req->flags |= REQ_F_NEED_CLEANUP;
+ return 0;
+}
+
+static int io_mkdirat(struct io_kiocb *req, bool force_nonblock)
+{
+ struct io_mkdir *mkd = &req->mkdir;
+ int ret;
+
+ if (force_nonblock)
+ return -EAGAIN;
+
+ ret = do_mkdirat(mkd->dfd, mkd->filename, mkd->mode);
+
+ req->flags &= ~REQ_F_NEED_CLEANUP;
+ if (ret < 0)
+ req_set_fail_links(req);
+ io_req_complete(req, ret);
+ return 0;
+}
+
static int io_shutdown_prep(struct io_kiocb *req,
const struct io_uring_sqe *sqe)
{
@@ -6101,6 +6151,8 @@ static int io_req_prep(struct io_kiocb *req, const struct io_uring_sqe *sqe)
return io_renameat_prep(req, sqe);
case IORING_OP_UNLINKAT:
return io_unlinkat_prep(req, sqe);
+ case IORING_OP_MKDIRAT:
+ return io_mkdirat_prep(req, sqe);
}
printk_once(KERN_WARNING "io_uring: unhandled opcode %d\n",
@@ -6228,6 +6280,9 @@ static void __io_clean_op(struct io_kiocb *req)
case IORING_OP_UNLINKAT:
putname(req->unlink.filename);
break;
+ case IORING_OP_MKDIRAT:
+ putname(req->mkdir.filename);
+ break;
}
req->flags &= ~REQ_F_NEED_CLEANUP;
}
@@ -6340,6 +6395,9 @@ static int io_issue_sqe(struct io_kiocb *req, bool force_nonblock,
case IORING_OP_UNLINKAT:
ret = io_unlinkat(req, force_nonblock);
break;
+ case IORING_OP_MKDIRAT:
+ ret = io_mkdirat(req, force_nonblock);
+ break;
default:
ret = -EINVAL;
break;
diff --git a/include/uapi/linux/io_uring.h b/include/uapi/linux/io_uring.h
index ac4e1738a9af..890edd850a9e 100644
--- a/include/uapi/linux/io_uring.h
+++ b/include/uapi/linux/io_uring.h
@@ -137,6 +137,7 @@ enum {
IORING_OP_SHUTDOWN,
IORING_OP_RENAMEAT,
IORING_OP_UNLINKAT,
+ IORING_OP_MKDIRAT,
/* this goes last, obviously */
IORING_OP_LAST,
--
2.30.0
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH v2 1/2] fs: make do_mkdirat() take struct filename
2021-02-02 8:23 ` [PATCH v2 1/2] fs: make do_mkdirat() take struct filename Dmitry Kadashev
@ 2021-02-12 9:42 ` Dmitry Kadashev
0 siblings, 0 replies; 7+ messages in thread
From: Dmitry Kadashev @ 2021-02-12 9:42 UTC (permalink / raw)
To: Jens Axboe, Alexander Viro; +Cc: Pavel Begunkov, linux-fsdevel, io-uring
On Tue, Feb 2, 2021 at 3:25 PM Dmitry Kadashev <[email protected]> wrote:
>
> Pass in the struct filename pointers instead of the user string, and
> update the three callers to do the same. This is heavily based on
> commit dbea8d345177 ("fs: make do_renameat2() take struct filename").
>
> This behaves like do_unlinkat() and do_renameat2().
>
> Cc: Al Viro <[email protected]>
> Signed-off-by: Dmitry Kadashev <[email protected]>
> ---
> fs/internal.h | 1 +
> fs/namei.c | 25 +++++++++++++++++++------
> 2 files changed, 20 insertions(+), 6 deletions(-)
>
> diff --git a/fs/internal.h b/fs/internal.h
> index c6c85f6ad598..b10005dfaa48 100644
> --- a/fs/internal.h
> +++ b/fs/internal.h
> @@ -76,6 +76,7 @@ long do_unlinkat(int dfd, struct filename *name);
> int may_linkat(struct path *link);
> int do_renameat2(int olddfd, struct filename *oldname, int newdfd,
> struct filename *newname, unsigned int flags);
> +long do_mkdirat(int dfd, struct filename *name, umode_t mode);
>
> /*
> * namespace.c
> diff --git a/fs/namei.c b/fs/namei.c
> index 4cae88733a5c..3657bdf1aafc 100644
> --- a/fs/namei.c
> +++ b/fs/namei.c
> @@ -3431,7 +3431,7 @@ struct file *do_file_open_root(struct dentry *dentry, struct vfsmount *mnt,
> return file;
> }
>
> -static struct dentry *filename_create(int dfd, struct filename *name,
> +static struct dentry *__filename_create(int dfd, struct filename *name,
> struct path *path, unsigned int lookup_flags)
> {
> struct dentry *dentry = ERR_PTR(-EEXIST);
> @@ -3487,7 +3487,6 @@ static struct dentry *filename_create(int dfd, struct filename *name,
> error = err2;
> goto fail;
> }
> - putname(name);
> return dentry;
> fail:
> dput(dentry);
> @@ -3502,6 +3501,16 @@ static struct dentry *filename_create(int dfd, struct filename *name,
> return dentry;
> }
>
> +static inline struct dentry *filename_create(int dfd, struct filename *name,
> + struct path *path, unsigned int lookup_flags)
> +{
> + struct dentry *res = __filename_create(dfd, name, path, lookup_flags);
> +
> + if (!IS_ERR(res))
> + putname(name);
> + return res;
> +}
> +
> struct dentry *kern_path_create(int dfd, const char *pathname,
> struct path *path, unsigned int lookup_flags)
> {
> @@ -3654,15 +3663,18 @@ int vfs_mkdir(struct inode *dir, struct dentry *dentry, umode_t mode)
> }
> EXPORT_SYMBOL(vfs_mkdir);
>
> -static long do_mkdirat(int dfd, const char __user *pathname, umode_t mode)
> +long do_mkdirat(int dfd, struct filename *name, umode_t mode)
> {
> struct dentry *dentry;
> struct path path;
> int error;
> unsigned int lookup_flags = LOOKUP_DIRECTORY;
>
> + if (IS_ERR(name))
> + return PTR_ERR(name);
> +
> retry:
> - dentry = user_path_create(dfd, pathname, &path, lookup_flags);
> + dentry = __filename_create(dfd, name, &path, lookup_flags);
> if (IS_ERR(dentry))
> return PTR_ERR(dentry);
>
> @@ -3676,17 +3688,18 @@ static long do_mkdirat(int dfd, const char __user *pathname, umode_t mode)
> lookup_flags |= LOOKUP_REVAL;
> goto retry;
> }
> + putname(name);
> return error;
> }
>
> SYSCALL_DEFINE3(mkdirat, int, dfd, const char __user *, pathname, umode_t, mode)
> {
> - return do_mkdirat(dfd, pathname, mode);
> + return do_mkdirat(dfd, getname(pathname), mode);
> }
>
> SYSCALL_DEFINE2(mkdir, const char __user *, pathname, umode_t, mode)
> {
> - return do_mkdirat(AT_FDCWD, pathname, mode);
> + return do_mkdirat(AT_FDCWD, getname(pathname), mode);
> }
>
> int vfs_rmdir(struct inode *dir, struct dentry *dentry)
> --
> 2.30.0
Hi Al,
Are you OK with this version?
--
Dmitry Kadashev
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH v2 0/2] io_uring: add mkdirat support
2021-02-02 8:23 [PATCH v2 0/2] io_uring: add mkdirat support Dmitry Kadashev
2021-02-02 8:23 ` [PATCH v2 1/2] fs: make do_mkdirat() take struct filename Dmitry Kadashev
2021-02-02 8:23 ` [PATCH v2 2/2] io_uring: add support for IORING_OP_MKDIRAT Dmitry Kadashev
@ 2021-02-18 7:25 ` Dmitry Kadashev
2021-03-29 20:37 ` Jens Axboe
3 siblings, 0 replies; 7+ messages in thread
From: Dmitry Kadashev @ 2021-02-18 7:25 UTC (permalink / raw)
To: Jens Axboe, Alexander Viro; +Cc: Pavel Begunkov, linux-fsdevel, io-uring
On Tue, Feb 2, 2021 at 3:24 PM Dmitry Kadashev <[email protected]> wrote:
>
> This adds mkdirat support to io_uring and is heavily based on recently
> added renameat() / unlinkat() support.
>
> The first patch is preparation with no functional changes, makes
> do_mkdirat accept struct filename pointer rather than the user string.
>
> The second one leverages that to implement mkdirat in io_uring.
>
> Based on for-5.11/io_uring.
>
> Changes since v1:
> - do not mess with struct filename's refcount in do_mkdirat, instead add
> and use __filename_create() that does not drop the name on success;
>
> Dmitry Kadashev (2):
> fs: make do_mkdirat() take struct filename
> io_uring: add support for IORING_OP_MKDIRAT
>
> fs/internal.h | 1 +
> fs/io_uring.c | 58 +++++++++++++++++++++++++++++++++++
> fs/namei.c | 25 +++++++++++----
> include/uapi/linux/io_uring.h | 1 +
> 4 files changed, 79 insertions(+), 6 deletions(-)
Hi Jens,
Ping. I've tried reaching out to Al wrt the first patch, but that did not seem
to work. Is there a chance to get this into 5.12 at this point?
--
Dmitry Kadashev
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH v2 0/2] io_uring: add mkdirat support
2021-02-02 8:23 [PATCH v2 0/2] io_uring: add mkdirat support Dmitry Kadashev
` (2 preceding siblings ...)
2021-02-18 7:25 ` [PATCH v2 0/2] io_uring: add mkdirat support Dmitry Kadashev
@ 2021-03-29 20:37 ` Jens Axboe
2021-03-30 4:32 ` Dmitry Kadashev
3 siblings, 1 reply; 7+ messages in thread
From: Jens Axboe @ 2021-03-29 20:37 UTC (permalink / raw)
To: Dmitry Kadashev, Alexander Viro; +Cc: Pavel Begunkov, linux-fsdevel, io-uring
On 2/2/21 1:23 AM, Dmitry Kadashev wrote:
> This adds mkdirat support to io_uring and is heavily based on recently
> added renameat() / unlinkat() support.
>
> The first patch is preparation with no functional changes, makes
> do_mkdirat accept struct filename pointer rather than the user string.
>
> The second one leverages that to implement mkdirat in io_uring.
>
> Based on for-5.11/io_uring.
Can you check if it still applies against for-5.13/io_uring? Both the
vfs and io_uring bits.
It'd be nice to get this moving forward, there's no reason why this
should keep getting stalled.
--
Jens Axboe
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH v2 0/2] io_uring: add mkdirat support
2021-03-29 20:37 ` Jens Axboe
@ 2021-03-30 4:32 ` Dmitry Kadashev
0 siblings, 0 replies; 7+ messages in thread
From: Dmitry Kadashev @ 2021-03-30 4:32 UTC (permalink / raw)
To: Jens Axboe; +Cc: Alexander Viro, Pavel Begunkov, linux-fsdevel, io-uring
On Tue, Mar 30, 2021 at 3:37 AM Jens Axboe <[email protected]> wrote:
> On 2/2/21 1:23 AM, Dmitry Kadashev wrote:
> > Based on for-5.11/io_uring.
Actually this was a typo (copy-n-paste error), it was on top of
for-5.12/io_uring. Doesn't really matter though.
> Can you check if it still applies against for-5.13/io_uring? Both the
> vfs and io_uring bits.
It does not (the io_uring bits), I'll send v3 soon.
--
Dmitry Kadashev
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2021-03-30 4:33 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-02-02 8:23 [PATCH v2 0/2] io_uring: add mkdirat support Dmitry Kadashev
2021-02-02 8:23 ` [PATCH v2 1/2] fs: make do_mkdirat() take struct filename Dmitry Kadashev
2021-02-12 9:42 ` Dmitry Kadashev
2021-02-02 8:23 ` [PATCH v2 2/2] io_uring: add support for IORING_OP_MKDIRAT Dmitry Kadashev
2021-02-18 7:25 ` [PATCH v2 0/2] io_uring: add mkdirat support Dmitry Kadashev
2021-03-29 20:37 ` Jens Axboe
2021-03-30 4:32 ` Dmitry Kadashev
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox