Skip to contentSkip to conversation

file assignment issues

PATCH Applied Pavel Begunkov 2 participants 5 messages Apr 13, 2022

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

cover file assignment issues

small fixes for deferred file assignment

Pavel Begunkov (3):
io_uring: use right issue_flags for splice/tee
io_uring: fix poll file assign deadlock
io_uring: fix poll error reporting

 fs/io_uring.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)
Signature · 1 line
2.35.1
#1 lore raw

PATCH 1/3 io_uring: use right issue_flags for splice/tee

Pass right issue_flags into into io_file_get_fixed() instead of IO_URING_F_UNLOCKED. It's probably not a problem at the moment but let's do it safer.

Fixes 6bf9c47a3989 ("io_uring: defer file assignment")
---
 fs/io_uring.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
fs/io_uring.c +2 -2
index 6b1a98697dcf..3d6cbf77c89d 100644
@@ -4358,7 +4358,7 @@ static int io_tee(struct io_kiocb *req, unsigned int issue_flags)
 		return -EAGAIN;
 
 	if (sp->flags & SPLICE_F_FD_IN_FIXED)
-		in = io_file_get_fixed(req, sp->splice_fd_in, IO_URING_F_UNLOCKED);
+		in = io_file_get_fixed(req, sp->splice_fd_in, issue_flags);
 	else
 		in = io_file_get_normal(req, sp->splice_fd_in);
 	if (!in) {
@@ -4400,7 +4400,7 @@ static int io_splice(struct io_kiocb *req, unsigned int issue_flags)
 		return -EAGAIN;
 
 	if (sp->flags & SPLICE_F_FD_IN_FIXED)
-		in = io_file_get_fixed(req, sp->splice_fd_in, IO_URING_F_UNLOCKED);
+		in = io_file_get_fixed(req, sp->splice_fd_in, issue_flags);
 	else
 		in = io_file_get_normal(req, sp->splice_fd_in);
 	if (!in) {
Signature · 1 line
2.35.1
#2 lore raw

PATCH 2/3 io_uring: fix poll file assign deadlock

In reply to Pavel Begunkov

We pass "unlocked" into io_assign_file() in io_poll_check_events(), which can lead to double locking.

Fixes 6bf9c47a3989 ("io_uring: defer file assignment")
---
 fs/io_uring.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
fs/io_uring.c +2 -1
index 3d6cbf77c89d..d06f1952fdfa 100644
@@ -5858,8 +5858,9 @@ static int io_poll_check_events(struct io_kiocb *req, bool locked)
 
 		if (!req->result) {
 			struct poll_table_struct pt = { ._key = req->apoll_events };
+			unsigned flags = locked ? 0 : IO_URING_F_UNLOCKED;
 
-			if (unlikely(!io_assign_file(req, IO_URING_F_UNLOCKED)))
+			if (unlikely(!io_assign_file(req, flags)))
 				req->result = -EBADF;
 			else
 				req->result = vfs_poll(req->file, &pt) & req->apoll_events;
Signature · 1 line
2.35.1
#3 lore raw

PATCH 3/3 io_uring: fix poll error reporting

In reply to Pavel Begunkov

We should not return an error code in req->result in io_poll_check_events(), because it may get mangled and returned as success. Just return the error code directly, the callers will fail the request or proceed accordingly.

Fixes 6bf9c47a3989 ("io_uring: defer file assignment")
---
 fs/io_uring.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)
fs/io_uring.c +2 -3
index d06f1952fdfa..ab674a0d269b 100644
@@ -5861,9 +5861,8 @@ static int io_poll_check_events(struct io_kiocb *req, bool locked)
 			unsigned flags = locked ? 0 : IO_URING_F_UNLOCKED;
 
 			if (unlikely(!io_assign_file(req, flags)))
-				req->result = -EBADF;
-			else
-				req->result = vfs_poll(req->file, &pt) & req->apoll_events;
+				return -EBADF;
+			req->result = vfs_poll(req->file, &pt) & req->apoll_events;
 		}
 
 		/* multishot, just fill an CQE and proceed */
Signature · 1 line
2.35.1
maintainer Applied
#4 lore raw
In reply to Pavel Begunkov
Quoted 8 lines · Pavel Begunkov

small fixes for deferred file assignment

Pavel Begunkov (3):
io_uring: use right issue_flags for splice/tee
io_uring: fix poll file assign deadlock
io_uring: fix poll error reporting

[...]

Applied, thanks!

[1/3] io_uring: use right issue_flags for splice/tee

      commit: e941976659f1f6834077a1596bf53e6bdb10e90b
[2/3] io_uring: fix poll file assign deadlock
      commit: cce64ef01308b677a687d90927fc2b2e0e1cba67
[3/3] io_uring: fix poll error reporting
      commit: 7179c3ce3dbff646c55f7cd664a895f462f049e5

Best regards,

Signature · 1 line
Jens Axboe