Skip to content

Commit 1d9e128

Browse files
Bijan Mottahedehaxboe
authored andcommitted
io_uring: add io_statx structure
Separate statx data from open in io_kiocb. No functional changes. Signed-off-by: Bijan Mottahedeh <[email protected]> Signed-off-by: Jens Axboe <[email protected]>
1 parent 0bf0eef commit 1d9e128

File tree

1 file changed

+22
-16
lines changed

1 file changed

+22
-16
lines changed

fs/io_uring.c

Lines changed: 22 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -425,11 +425,7 @@ struct io_sr_msg {
425425
struct io_open {
426426
struct file *file;
427427
int dfd;
428-
union {
429-
unsigned mask;
430-
};
431428
struct filename *filename;
432-
struct statx __user *buffer;
433429
struct open_how how;
434430
unsigned long nofile;
435431
};
@@ -481,6 +477,15 @@ struct io_provide_buf {
481477
__u16 bid;
482478
};
483479

480+
struct io_statx {
481+
struct file *file;
482+
int dfd;
483+
unsigned int mask;
484+
unsigned int flags;
485+
struct filename *filename;
486+
struct statx __user *buffer;
487+
};
488+
484489
struct io_async_connect {
485490
struct sockaddr_storage address;
486491
};
@@ -622,6 +627,7 @@ struct io_kiocb {
622627
struct io_epoll epoll;
623628
struct io_splice splice;
624629
struct io_provide_buf pbuf;
630+
struct io_statx statx;
625631
};
626632

627633
struct io_async_ctx *io;
@@ -3381,19 +3387,19 @@ static int io_statx_prep(struct io_kiocb *req, const struct io_uring_sqe *sqe)
33813387
if (req->flags & REQ_F_NEED_CLEANUP)
33823388
return 0;
33833389

3384-
req->open.dfd = READ_ONCE(sqe->fd);
3385-
req->open.mask = READ_ONCE(sqe->len);
3390+
req->statx.dfd = READ_ONCE(sqe->fd);
3391+
req->statx.mask = READ_ONCE(sqe->len);
33863392
fname = u64_to_user_ptr(READ_ONCE(sqe->addr));
3387-
req->open.buffer = u64_to_user_ptr(READ_ONCE(sqe->addr2));
3388-
req->open.how.flags = READ_ONCE(sqe->statx_flags);
3393+
req->statx.buffer = u64_to_user_ptr(READ_ONCE(sqe->addr2));
3394+
req->statx.flags = READ_ONCE(sqe->statx_flags);
33893395

3390-
if (vfs_stat_set_lookup_flags(&lookup_flags, req->open.how.flags))
3396+
if (vfs_stat_set_lookup_flags(&lookup_flags, req->statx.flags))
33913397
return -EINVAL;
33923398

3393-
req->open.filename = getname_flags(fname, lookup_flags, NULL);
3394-
if (IS_ERR(req->open.filename)) {
3395-
ret = PTR_ERR(req->open.filename);
3396-
req->open.filename = NULL;
3399+
req->statx.filename = getname_flags(fname, lookup_flags, NULL);
3400+
if (IS_ERR(req->statx.filename)) {
3401+
ret = PTR_ERR(req->statx.filename);
3402+
req->statx.filename = NULL;
33973403
return ret;
33983404
}
33993405

@@ -3403,7 +3409,7 @@ static int io_statx_prep(struct io_kiocb *req, const struct io_uring_sqe *sqe)
34033409

34043410
static int io_statx(struct io_kiocb *req, bool force_nonblock)
34053411
{
3406-
struct io_open *ctx = &req->open;
3412+
struct io_statx *ctx = &req->statx;
34073413
unsigned lookup_flags;
34083414
struct path path;
34093415
struct kstat stat;
@@ -3416,7 +3422,7 @@ static int io_statx(struct io_kiocb *req, bool force_nonblock)
34163422
return -EAGAIN;
34173423
}
34183424

3419-
if (vfs_stat_set_lookup_flags(&lookup_flags, ctx->how.flags))
3425+
if (vfs_stat_set_lookup_flags(&lookup_flags, ctx->flags))
34203426
return -EINVAL;
34213427

34223428
retry:
@@ -3428,7 +3434,7 @@ static int io_statx(struct io_kiocb *req, bool force_nonblock)
34283434
if (ret)
34293435
goto err;
34303436

3431-
ret = vfs_getattr(&path, &stat, ctx->mask, ctx->how.flags);
3437+
ret = vfs_getattr(&path, &stat, ctx->mask, ctx->flags);
34323438
path_put(&path);
34333439
if (retry_estale(ret, lookup_flags)) {
34343440
lookup_flags |= LOOKUP_REVAL;

0 commit comments

Comments
 (0)