diff mbox series

5.8 io_uring stable

Message ID 49361215-3d71-71e8-7cd2-1f7009323a30@kernel.dk
State New
Headers show
Series 5.8 io_uring stable | expand

Commit Message

Jens Axboe Sept. 4, 2020, 9:06 p.m. UTC
Hi,

Linus just pulled 3 fixes from me - 1+2 should apply directly, here's
the 3rd one which will need some love for 5.8-stable. I'm including it
below to preempt the failed to apply message :-)


commit fb8d4046d50f77a26570101e5b8a7a026320a610
Author: Jens Axboe <axboe@kernel.dk>
Date:   Wed Sep 2 10:19:04 2020 -0600

    io_uring: no read/write-retry on -EAGAIN error and O_NONBLOCK marked file
    
    Actually two things that need fixing up here:
    
    - The io_rw_reissue() -EAGAIN retry is explicit to block devices and
      regular files, so don't ever attempt to do that on other types of
      files.
    
    - If we hit -EAGAIN on a nonblock marked file, don't arm poll handler for
      it. It should just complete with -EAGAIN.
    
    Cc: stable@vger.kernel.org
    Reported-by: Norman Maurer <norman.maurer@googlemail.com>
    Signed-off-by: Jens Axboe <axboe@kernel.dk>

Comments

Jens Axboe Sept. 8, 2020, 1:11 p.m. UTC | #1
On 9/8/20 6:31 AM, Greg KH wrote:
> On Fri, Sep 04, 2020 at 03:06:28PM -0600, Jens Axboe wrote:
>> Hi,
>>
>> Linus just pulled 3 fixes from me - 1+2 should apply directly, here's
>> the 3rd one which will need some love for 5.8-stable. I'm including it
>> below to preempt the failed to apply message :-)
>>
>>
>> commit fb8d4046d50f77a26570101e5b8a7a026320a610
>> Author: Jens Axboe <axboe@kernel.dk>
>> Date:   Wed Sep 2 10:19:04 2020 -0600
>>
>>     io_uring: no read/write-retry on -EAGAIN error and O_NONBLOCK marked file
>>     
>>     Actually two things that need fixing up here:
>>     
>>     - The io_rw_reissue() -EAGAIN retry is explicit to block devices and
>>       regular files, so don't ever attempt to do that on other types of
>>       files.
>>     
>>     - If we hit -EAGAIN on a nonblock marked file, don't arm poll handler for
>>       it. It should just complete with -EAGAIN.
>>     
>>     Cc: stable@vger.kernel.org
>>     Reported-by: Norman Maurer <norman.maurer@googlemail.com>
>>     Signed-off-by: Jens Axboe <axboe@kernel.dk>
>>
>> diff --git a/fs/io_uring.c b/fs/io_uring.c
>> index 82e15020d9a8..96be21ace79a 100644
>> --- a/fs/io_uring.c
>> +++ b/fs/io_uring.c
>> @@ -2726,6 +2726,12 @@ static int io_read(struct io_kiocb *req, bool force_nonblock)
>>  				ret = ret2;
>>  				goto done;
>>  			}
>> +			/* no retry on NONBLOCK marked file */
>> +			if (req->file->f_flags & O_NONBLOCK) {
>> +				ret = ret2;
>> +				goto done;
>> +			}
>> +
>>  			/* some cases will consume bytes even on error returns */
>>  			iov_iter_revert(iter, iov_count - iov_iter_count(iter));
>>  			ret2 = 0;
>> @@ -2869,9 +2875,15 @@ static int io_write(struct io_kiocb *req, bool force_nonblock)
>>  		 */
>>  		if (ret2 == -EOPNOTSUPP && (kiocb->ki_flags & IOCB_NOWAIT))
>>  			ret2 = -EAGAIN;
>> +		/* no retry on NONBLOCK marked file */
>> +		if (ret2 == -EAGAIN && (req->file->f_flags & O_NONBLOCK)) {
>> +			ret = 0;
>> +			goto done;
>> +		}
>>  		if (!force_nonblock || ret2 != -EAGAIN) {
>>  			if ((req->ctx->flags & IORING_SETUP_IOPOLL) && ret2 == -EAGAIN)
>>  				goto copy_iov;
>> +done:
>>  			kiocb_done(kiocb, ret2);
>>  		} else {
>>  copy_iov:
>>
>> -- 
>> Jens Axboe
> 
> 
> Thanks for the backport, but this didn't apply at all to the 5.8.y tree.
> What one did you make it against?

Oh, might have been because I have a pile of pending 5.8 stable patches...
Let me apply to pristine stable, test, and then I'll send it to you.
Greg KH Sept. 8, 2020, 2:25 p.m. UTC | #2
On Tue, Sep 08, 2020 at 07:29:05AM -0600, Jens Axboe wrote:
> On 9/8/20 7:11 AM, Jens Axboe wrote:
> > On 9/8/20 6:31 AM, Greg KH wrote:
> >> On Fri, Sep 04, 2020 at 03:06:28PM -0600, Jens Axboe wrote:
> >>> Hi,
> >>>
> >>> Linus just pulled 3 fixes from me - 1+2 should apply directly, here's
> >>> the 3rd one which will need some love for 5.8-stable. I'm including it
> >>> below to preempt the failed to apply message :-)
> >>>
> >>>
> >>> commit fb8d4046d50f77a26570101e5b8a7a026320a610
> >>> Author: Jens Axboe <axboe@kernel.dk>
> >>> Date:   Wed Sep 2 10:19:04 2020 -0600
> >>>
> >>>     io_uring: no read/write-retry on -EAGAIN error and O_NONBLOCK marked file
> >>>     
> >>>     Actually two things that need fixing up here:
> >>>     
> >>>     - The io_rw_reissue() -EAGAIN retry is explicit to block devices and
> >>>       regular files, so don't ever attempt to do that on other types of
> >>>       files.
> >>>     
> >>>     - If we hit -EAGAIN on a nonblock marked file, don't arm poll handler for
> >>>       it. It should just complete with -EAGAIN.
> >>>     
> >>>     Cc: stable@vger.kernel.org
> >>>     Reported-by: Norman Maurer <norman.maurer@googlemail.com>
> >>>     Signed-off-by: Jens Axboe <axboe@kernel.dk>
> >>>
> >>> diff --git a/fs/io_uring.c b/fs/io_uring.c
> >>> index 82e15020d9a8..96be21ace79a 100644
> >>> --- a/fs/io_uring.c
> >>> +++ b/fs/io_uring.c
> >>> @@ -2726,6 +2726,12 @@ static int io_read(struct io_kiocb *req, bool force_nonblock)
> >>>  				ret = ret2;
> >>>  				goto done;
> >>>  			}
> >>> +			/* no retry on NONBLOCK marked file */
> >>> +			if (req->file->f_flags & O_NONBLOCK) {
> >>> +				ret = ret2;
> >>> +				goto done;
> >>> +			}
> >>> +
> >>>  			/* some cases will consume bytes even on error returns */
> >>>  			iov_iter_revert(iter, iov_count - iov_iter_count(iter));
> >>>  			ret2 = 0;
> >>> @@ -2869,9 +2875,15 @@ static int io_write(struct io_kiocb *req, bool force_nonblock)
> >>>  		 */
> >>>  		if (ret2 == -EOPNOTSUPP && (kiocb->ki_flags & IOCB_NOWAIT))
> >>>  			ret2 = -EAGAIN;
> >>> +		/* no retry on NONBLOCK marked file */
> >>> +		if (ret2 == -EAGAIN && (req->file->f_flags & O_NONBLOCK)) {
> >>> +			ret = 0;
> >>> +			goto done;
> >>> +		}
> >>>  		if (!force_nonblock || ret2 != -EAGAIN) {
> >>>  			if ((req->ctx->flags & IORING_SETUP_IOPOLL) && ret2 == -EAGAIN)
> >>>  				goto copy_iov;
> >>> +done:
> >>>  			kiocb_done(kiocb, ret2);
> >>>  		} else {
> >>>  copy_iov:
> >>>
> >>> -- 
> >>> Jens Axboe
> >>
> >>
> >> Thanks for the backport, but this didn't apply at all to the 5.8.y tree.
> >> What one did you make it against?
> > 
> > Oh, might have been because I have a pile of pending 5.8 stable patches...
> > Let me apply to pristine stable, test, and then I'll send it to you.
> 
> Here it is:
> 
> 
> commit d0ea3f3d17cf891244f17f8ceb43d4988c170471
> Author: Jens Axboe <axboe@kernel.dk>
> Date:   Tue Sep 8 07:16:12 2020 -0600
> 
>     io_uring: no read/write-retry on -EAGAIN error and O_NONBLOCK marked file
>     
>     Actually two things that need fixing up here:
>     
>     - The io_rw_reissue() -EAGAIN retry is explicit to block devices and
>       regular files, so don't ever attempt to do that on other types of
>       files.
>     
>     - If we hit -EAGAIN on a nonblock marked file, don't arm poll handler for
>       it. It should just complete with -EAGAIN.
>     
>     Cc: stable@vger.kernel.org
>     Reported-by: Norman Maurer <norman.maurer@googlemail.com>
>     Signed-off-by: Jens Axboe <axboe@kernel.dk>

Much nicer, that worked, thanks!

greg k-h
diff mbox series

Patch

diff --git a/fs/io_uring.c b/fs/io_uring.c
index 82e15020d9a8..96be21ace79a 100644
--- a/fs/io_uring.c
+++ b/fs/io_uring.c
@@ -2726,6 +2726,12 @@  static int io_read(struct io_kiocb *req, bool force_nonblock)
 				ret = ret2;
 				goto done;
 			}
+			/* no retry on NONBLOCK marked file */
+			if (req->file->f_flags & O_NONBLOCK) {
+				ret = ret2;
+				goto done;
+			}
+
 			/* some cases will consume bytes even on error returns */
 			iov_iter_revert(iter, iov_count - iov_iter_count(iter));
 			ret2 = 0;
@@ -2869,9 +2875,15 @@  static int io_write(struct io_kiocb *req, bool force_nonblock)
 		 */
 		if (ret2 == -EOPNOTSUPP && (kiocb->ki_flags & IOCB_NOWAIT))
 			ret2 = -EAGAIN;
+		/* no retry on NONBLOCK marked file */
+		if (ret2 == -EAGAIN && (req->file->f_flags & O_NONBLOCK)) {
+			ret = 0;
+			goto done;
+		}
 		if (!force_nonblock || ret2 != -EAGAIN) {
 			if ((req->ctx->flags & IORING_SETUP_IOPOLL) && ret2 == -EAGAIN)
 				goto copy_iov;
+done:
 			kiocb_done(kiocb, ret2);
 		} else {
 copy_iov: