io_uring: ensure reads re-import for selected buffers
authorJens Axboe <axboe@kernel.dk>
Thu, 10 Mar 2022 16:54:25 +0000 (09:54 -0700)
committerJens Axboe <axboe@kernel.dk>
Thu, 10 Mar 2022 16:55:01 +0000 (09:55 -0700)
If we drop buffers between scheduling a retry, then we need to re-import
when we start the request again.

Signed-off-by: Jens Axboe <axboe@kernel.dk>
fs/io_uring.c

index 4d8366b..584b36d 100644 (file)
@@ -3737,6 +3737,16 @@ static int io_read(struct io_kiocb *req, unsigned int issue_flags)
                if (unlikely(ret < 0))
                        return ret;
        } else {
+               /*
+                * Safe and required to re-import if we're using provided
+                * buffers, as we dropped the selected one before retry.
+                */
+               if (req->flags & REQ_F_BUFFER_SELECT) {
+                       ret = io_import_iovec(READ, req, &iovec, s, issue_flags);
+                       if (unlikely(ret < 0))
+                               return ret;
+               }
+
                rw = req->async_data;
                s = &rw->s;
                /*