From: Greg Kroah-Hartman Date: Sat, 18 Sep 2021 12:49:45 +0000 (+0200) Subject: 5.14-stable patches X-Git-Tag: v4.4.284~61 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=2f370a845d534b62df103559438bf55a81957198;p=thirdparty%2Fkernel%2Fstable-queue.git 5.14-stable patches added patches: io_uring-allow-retry-for-o_nonblock-if-async-is-supported.patch --- diff --git a/queue-5.14/io_uring-allow-retry-for-o_nonblock-if-async-is-supported.patch b/queue-5.14/io_uring-allow-retry-for-o_nonblock-if-async-is-supported.patch new file mode 100644 index 00000000000..8d36e588400 --- /dev/null +++ b/queue-5.14/io_uring-allow-retry-for-o_nonblock-if-async-is-supported.patch @@ -0,0 +1,69 @@ +From foo@baz Sat Sep 18 02:46:52 PM CEST 2021 +From: Jens Axboe +Date: Tue, 14 Sep 2021 11:08:37 -0600 +Subject: io_uring: allow retry for O_NONBLOCK if async is supported + +From: Jens Axboe + +commit 5d329e1286b0a040264e239b80257c937f6e685f upstream. + +A common complaint is that using O_NONBLOCK files with io_uring can be a +bit of a pain. Be a bit nicer and allow normal retry IFF the file does +support async behavior. This makes it possible to use io_uring more +reliably with O_NONBLOCK files, for use cases where it either isn't +possible or feasible to modify the file flags. + +Cc: stable@vger.kernel.org +Reported-and-tested-by: Dan Melnic +Signed-off-by: Jens Axboe +Signed-off-by: Greg Kroah-Hartman +--- + fs/io_uring.c | 16 +++++++++++----- + 1 file changed, 11 insertions(+), 5 deletions(-) + +--- a/fs/io_uring.c ++++ b/fs/io_uring.c +@@ -2683,7 +2683,8 @@ static bool io_file_supports_async(struc + return __io_file_supports_async(req->file, rw); + } + +-static int io_prep_rw(struct io_kiocb *req, const struct io_uring_sqe *sqe) ++static int io_prep_rw(struct io_kiocb *req, const struct io_uring_sqe *sqe, ++ int rw) + { + struct io_ring_ctx *ctx = req->ctx; + struct kiocb *kiocb = &req->rw.kiocb; +@@ -2705,8 +2706,13 @@ static int io_prep_rw(struct io_kiocb *r + if (unlikely(ret)) + return ret; + +- /* don't allow async punt for O_NONBLOCK or RWF_NOWAIT */ +- if ((kiocb->ki_flags & IOCB_NOWAIT) || (file->f_flags & O_NONBLOCK)) ++ /* ++ * If the file is marked O_NONBLOCK, still allow retry for it if it ++ * supports async. Otherwise it's impossible to use O_NONBLOCK files ++ * reliably. If not, or it IOCB_NOWAIT is set, don't retry. ++ */ ++ if ((kiocb->ki_flags & IOCB_NOWAIT) || ++ ((file->f_flags & O_NONBLOCK) && !io_file_supports_nowait(req, rw))) + req->flags |= REQ_F_NOWAIT; + + ioprio = READ_ONCE(sqe->ioprio); +@@ -3193,7 +3199,7 @@ static int io_read_prep(struct io_kiocb + { + if (unlikely(!(req->file->f_mode & FMODE_READ))) + return -EBADF; +- return io_prep_rw(req, sqe); ++ return io_prep_rw(req, sqe, READ); + } + + /* +@@ -3382,7 +3388,7 @@ static int io_write_prep(struct io_kiocb + { + if (unlikely(!(req->file->f_mode & FMODE_WRITE))) + return -EBADF; +- return io_prep_rw(req, sqe); ++ return io_prep_rw(req, sqe, WRITE); + } + + static int io_write(struct io_kiocb *req, unsigned int issue_flags) diff --git a/queue-5.14/series b/queue-5.14/series index b55d0cb1215..abfb34aca70 100644 --- a/queue-5.14/series +++ b/queue-5.14/series @@ -19,3 +19,4 @@ drm-amdgpu-move-iommu_resume-before-ip-init-resume.patch drm-amd-pm-fix-the-issue-of-uploading-powerplay-table.patch drm-amdkfd-separate-kfd_iommu_resume-from-kfd_resume.patch drm-radeon-pass-drm-dev-radeon_agp_head_init-directly.patch +io_uring-allow-retry-for-o_nonblock-if-async-is-supported.patch