public inbox for [email protected]
 help / color / mirror / Atom feed
* [PATCH 5.18 0/3] file assignment issues
@ 2022-04-13 15:10 Pavel Begunkov
  2022-04-13 15:10 ` [PATCH 1/3] io_uring: use right issue_flags for splice/tee Pavel Begunkov
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Pavel Begunkov @ 2022-04-13 15:10 UTC (permalink / raw)
  To: io-uring; +Cc: Jens Axboe, asml.silence

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(-)

-- 
2.35.1


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH 1/3] io_uring: use right issue_flags for splice/tee
  2022-04-13 15:10 [PATCH 5.18 0/3] file assignment issues Pavel Begunkov
@ 2022-04-13 15:10 ` Pavel Begunkov
  2022-04-13 15:10 ` [PATCH 2/3] io_uring: fix poll file assign deadlock Pavel Begunkov
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: Pavel Begunkov @ 2022-04-13 15:10 UTC (permalink / raw)
  To: io-uring; +Cc: Jens Axboe, asml.silence

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")
Signed-off-by: Pavel Begunkov <[email protected]>
---
 fs/io_uring.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/fs/io_uring.c b/fs/io_uring.c
index 6b1a98697dcf..3d6cbf77c89d 100644
--- a/fs/io_uring.c
+++ b/fs/io_uring.c
@@ -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) {
-- 
2.35.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH 2/3] io_uring: fix poll file assign deadlock
  2022-04-13 15:10 [PATCH 5.18 0/3] file assignment issues Pavel Begunkov
  2022-04-13 15:10 ` [PATCH 1/3] io_uring: use right issue_flags for splice/tee Pavel Begunkov
@ 2022-04-13 15:10 ` Pavel Begunkov
  2022-04-13 15:10 ` [PATCH 3/3] io_uring: fix poll error reporting Pavel Begunkov
  2022-04-13 16:26 ` [PATCH 5.18 0/3] file assignment issues Jens Axboe
  3 siblings, 0 replies; 5+ messages in thread
From: Pavel Begunkov @ 2022-04-13 15:10 UTC (permalink / raw)
  To: io-uring; +Cc: Jens Axboe, asml.silence

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")
Signed-off-by: Pavel Begunkov <[email protected]>
---
 fs/io_uring.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/fs/io_uring.c b/fs/io_uring.c
index 3d6cbf77c89d..d06f1952fdfa 100644
--- a/fs/io_uring.c
+++ b/fs/io_uring.c
@@ -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;
-- 
2.35.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH 3/3] io_uring: fix poll error reporting
  2022-04-13 15:10 [PATCH 5.18 0/3] file assignment issues Pavel Begunkov
  2022-04-13 15:10 ` [PATCH 1/3] io_uring: use right issue_flags for splice/tee Pavel Begunkov
  2022-04-13 15:10 ` [PATCH 2/3] io_uring: fix poll file assign deadlock Pavel Begunkov
@ 2022-04-13 15:10 ` Pavel Begunkov
  2022-04-13 16:26 ` [PATCH 5.18 0/3] file assignment issues Jens Axboe
  3 siblings, 0 replies; 5+ messages in thread
From: Pavel Begunkov @ 2022-04-13 15:10 UTC (permalink / raw)
  To: io-uring; +Cc: Jens Axboe, asml.silence

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")
Signed-off-by: Pavel Begunkov <[email protected]>
---
 fs/io_uring.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/fs/io_uring.c b/fs/io_uring.c
index d06f1952fdfa..ab674a0d269b 100644
--- a/fs/io_uring.c
+++ b/fs/io_uring.c
@@ -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 */
-- 
2.35.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH 5.18 0/3] file assignment issues
  2022-04-13 15:10 [PATCH 5.18 0/3] file assignment issues Pavel Begunkov
                   ` (2 preceding siblings ...)
  2022-04-13 15:10 ` [PATCH 3/3] io_uring: fix poll error reporting Pavel Begunkov
@ 2022-04-13 16:26 ` Jens Axboe
  3 siblings, 0 replies; 5+ messages in thread
From: Jens Axboe @ 2022-04-13 16:26 UTC (permalink / raw)
  To: io-uring, asml.silence

On Wed, 13 Apr 2022 16:10:32 +0100, Pavel Begunkov wrote:
> 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,
-- 
Jens Axboe



^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2022-04-13 16:26 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-04-13 15:10 [PATCH 5.18 0/3] file assignment issues Pavel Begunkov
2022-04-13 15:10 ` [PATCH 1/3] io_uring: use right issue_flags for splice/tee Pavel Begunkov
2022-04-13 15:10 ` [PATCH 2/3] io_uring: fix poll file assign deadlock Pavel Begunkov
2022-04-13 15:10 ` [PATCH 3/3] io_uring: fix poll error reporting Pavel Begunkov
2022-04-13 16:26 ` [PATCH 5.18 0/3] file assignment issues Jens Axboe

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox