[RFC PATCH for-next] io_uring: assign ctx->ring_file and ctx->ring_fd early in io_uring_create()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



While testing the feature which supports multiple rings to share same poll
thread by specifying same cpu, fio often hangs in fio_ioring_getevents()
infinitely. After some investigations, I find it's because ctx->ring_file
is NULL, so io_sq_thread doest not submit this ctx's requests.

While ring initialization completes, IORING_SQ_NEED_WAKEUP will be not
set initially, app may already submit some reqs and the corresponding
io_sq_thread may already see these reqs, but will not submit them because
ring_file is NULL. Some apps just check IORING_SQ_NEED_WAKEUP beforce
submitting reqs, for example, fio just checks it in fio_ioring_commit()
and will not check it in fio_ioring_getevents(), then fio will hang
forever. To fix this issue, we assign ctx->ring_file and ctx->ring_fd
early in io_uring_create().

Signed-off-by: Xiaoguang Wang <xiaoguang.wang@xxxxxxxxxxxxxxxxx>
---
 fs/io_uring.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/fs/io_uring.c b/fs/io_uring.c
index 321a430ff3f7..5ddb2cddc695 100644
--- a/fs/io_uring.c
+++ b/fs/io_uring.c
@@ -9034,6 +9034,11 @@ static int io_uring_create(unsigned entries, struct io_uring_params *p,
 		goto err;
 	}
 
+	if (p->flags & IORING_SETUP_SQPOLL) {
+		ctx->ring_fd = fd;
+		ctx->ring_file = file;
+	}
+
 	ret = io_sq_offload_create(ctx, p);
 	if (ret)
 		goto err;
-- 
2.17.2




[Index of Archives]     [Linux Samsung SoC]     [Linux Rockchip SoC]     [Linux Actions SoC]     [Linux for Synopsys ARC Processors]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]


  Powered by Linux