* io_uring statx fails with AT_EMPTY_PATH @ 2020-04-27 15:29 Clay Harris 2020-04-27 16:40 ` Jens Axboe 0 siblings, 1 reply; 4+ messages in thread From: Clay Harris @ 2020-04-27 15:29 UTC (permalink / raw) To: io-uring Jens Axboe recommended that I post io_uring stuff to this list. So, here goes. https://bugzilla.kernel.org/show_bug.cgi?id=207453 ^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: io_uring statx fails with AT_EMPTY_PATH 2020-04-27 15:29 io_uring statx fails with AT_EMPTY_PATH Clay Harris @ 2020-04-27 16:40 ` Jens Axboe 2020-04-27 16:52 ` Jens Axboe 0 siblings, 1 reply; 4+ messages in thread From: Jens Axboe @ 2020-04-27 16:40 UTC (permalink / raw) To: Clay Harris, io-uring On 4/27/20 9:29 AM, Clay Harris wrote: > Jens Axboe recommended that I post io_uring stuff to this list. > So, here goes. > > https://bugzilla.kernel.org/show_bug.cgi?id=207453 The below should fix it. diff --git a/fs/io_uring.c b/fs/io_uring.c index c687f57fb651..084dfade5cda 100644 --- a/fs/io_uring.c +++ b/fs/io_uring.c @@ -524,6 +524,7 @@ enum { REQ_F_OVERFLOW_BIT, REQ_F_POLLED_BIT, REQ_F_BUFFER_SELECTED_BIT, + REQ_F_NO_FILE_TABLE_BIT, /* not a real bit, just to check we're not overflowing the space */ __REQ_F_LAST_BIT, @@ -577,6 +578,8 @@ enum { REQ_F_POLLED = BIT(REQ_F_POLLED_BIT), /* buffer already selected */ REQ_F_BUFFER_SELECTED = BIT(REQ_F_BUFFER_SELECTED_BIT), + /* doesn't need file table for this request */ + REQ_F_NO_FILE_TABLE = BIT(REQ_F_NO_FILE_TABLE_BIT), }; struct async_poll { @@ -799,6 +802,7 @@ static const struct io_op_def io_op_defs[] = { .needs_file = 1, .fd_non_neg = 1, .needs_fs = 1, + .file_table = 1, }, [IORING_OP_READ] = { .needs_mm = 1, @@ -3355,8 +3359,12 @@ static int io_statx(struct io_kiocb *req, bool force_nonblock) struct kstat stat; int ret; - if (force_nonblock) + if (force_nonblock) { + /* only need file table for an actual valid fd */ + if (ctx->dfd == -1 || ctx->dfd == AT_FDCWD) + req->flags |= REQ_F_NO_FILE_TABLE; return -EAGAIN; + } if (vfs_stat_set_lookup_flags(&lookup_flags, ctx->how.flags)) return -EINVAL; @@ -5429,7 +5437,7 @@ static int io_grab_files(struct io_kiocb *req) int ret = -EBADF; struct io_ring_ctx *ctx = req->ctx; - if (req->work.files) + if (req->work.files || (req->flags & REQ_F_NO_FILE_TABLE)) return 0; if (!ctx->ring_file) return -EBADF; -- Jens Axboe ^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: io_uring statx fails with AT_EMPTY_PATH 2020-04-27 16:40 ` Jens Axboe @ 2020-04-27 16:52 ` Jens Axboe 2020-05-12 8:47 ` Clay Harris 0 siblings, 1 reply; 4+ messages in thread From: Jens Axboe @ 2020-04-27 16:52 UTC (permalink / raw) To: Clay Harris, io-uring On 4/27/20 10:40 AM, Jens Axboe wrote: > On 4/27/20 9:29 AM, Clay Harris wrote: >> Jens Axboe recommended that I post io_uring stuff to this list. >> So, here goes. >> >> https://bugzilla.kernel.org/show_bug.cgi?id=207453 > > The below should fix it. Added a test case for this to the liburing regression suite as well. -- Jens Axboe ^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: io_uring statx fails with AT_EMPTY_PATH 2020-04-27 16:52 ` Jens Axboe @ 2020-05-12 8:47 ` Clay Harris 0 siblings, 0 replies; 4+ messages in thread From: Clay Harris @ 2020-05-12 8:47 UTC (permalink / raw) To: Jens Axboe; +Cc: io-uring On Mon, Apr 27 2020 at 10:52:22 -0600, Jens Axboe quoth thus: > On 4/27/20 10:40 AM, Jens Axboe wrote: > > On 4/27/20 9:29 AM, Clay Harris wrote: > >> Jens Axboe recommended that I post io_uring stuff to this list. > >> So, here goes. > >> > >> https://bugzilla.kernel.org/show_bug.cgi?id=207453 > > > > The below should fix it. > > Added a test case for this to the liburing regression suite as well. > I have verified that the original bug is fixed as of kernel 5.6.11. -- Test 0: statx:fd 3: SUCCEED, file mode 100664 -- Test 1: statx:path uring_statx.c: SUCCEED, file mode 100664 -- Test 2: io_uring_statx:fd 3: SUCCEED, file mode 100664 -- Test 3: io_uring_statx:path uring_statx.c: SUCCEED, file mode 100664 ---- fd 3 set O_NONBLOCK -- Test 4: statx:fd 3 O_NONBLOCK: SUCCEED, file mode 100664 -- Test 5: io_uring_statx:fd 3 O_NONBLOCK: SUCCEED, file mode 100664 ======== I want to note that there are two other issues with io_uring statx with AT_EMPTY_PATH: 1) Tests 2 and 5 fail (EBADF) if the fd is opened with O_PATH, while all of the other tests continue to work fine. 2) io_uring statx returns EBADF when IOSQE_FIXED_FILE is specified, but IOSQE_FIXED_FILE + AT_EMPTY_PATH should be a valid combination. > -- > Jens Axboe ^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2020-05-12 8:47 UTC | newest] Thread overview: 4+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2020-04-27 15:29 io_uring statx fails with AT_EMPTY_PATH Clay Harris 2020-04-27 16:40 ` Jens Axboe 2020-04-27 16:52 ` Jens Axboe 2020-05-12 8:47 ` Clay Harris
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox