Skip to content

Commit d2b768c

Browse files
committed
Merge tag 'io_uring-6.0-2022-09-09' of git://git.kernel.dk/linux-block
Pull io_uring fixes from Jens Axboe: - Removed function that became unused after last week's merge (Jiapeng) - Two small fixes for kbuf recycling (Pavel) - Include address copy for zc send for POLLFIRST (Pavel) - Fix for short IO handling in the normal read/write path (Pavel) * tag 'io_uring-6.0-2022-09-09' of git://git.kernel.dk/linux-block: io_uring/rw: fix short rw error handling io_uring/net: copy addr for zc on POLL_FIRST io_uring: recycle kbuf recycle on tw requeue io_uring/kbuf: fix not advancing READV kbuf ring io_uring/notif: Remove the unused function io_notif_complete()
2 parents 0099baa + 4d9cb92 commit d2b768c

File tree

5 files changed

+29
-25
lines changed

5 files changed

+29
-25
lines changed

io_uring/io_uring.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1728,6 +1728,7 @@ static void io_queue_async(struct io_kiocb *req, int ret)
17281728

17291729
switch (io_arm_poll_handler(req, 0)) {
17301730
case IO_APOLL_READY:
1731+
io_kbuf_recycle(req, 0);
17311732
io_req_task_queue(req);
17321733
break;
17331734
case IO_APOLL_ABORTED:

io_uring/kbuf.h

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,9 +91,13 @@ static inline void io_kbuf_recycle(struct io_kiocb *req, unsigned issue_flags)
9191
* buffer data. However if that buffer is recycled the original request
9292
* data stored in addr is lost. Therefore forbid recycling for now.
9393
*/
94-
if (req->opcode == IORING_OP_READV)
94+
if (req->opcode == IORING_OP_READV) {
95+
if ((req->flags & REQ_F_BUFFER_RING) && req->buf_list) {
96+
req->buf_list->head++;
97+
req->buf_list = NULL;
98+
}
9599
return;
96-
100+
}
97101
if (req->flags & REQ_F_BUFFER_SELECTED)
98102
io_kbuf_recycle_legacy(req, issue_flags);
99103
if (req->flags & REQ_F_BUFFER_RING)

io_uring/net.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1003,9 +1003,6 @@ int io_sendzc(struct io_kiocb *req, unsigned int issue_flags)
10031003
unsigned msg_flags, cflags;
10041004
int ret, min_ret = 0;
10051005

1006-
if (!(req->flags & REQ_F_POLLED) &&
1007-
(zc->flags & IORING_RECVSEND_POLL_FIRST))
1008-
return -EAGAIN;
10091006
sock = sock_from_file(req->file);
10101007
if (unlikely(!sock))
10111008
return -ENOTSOCK;
@@ -1030,6 +1027,10 @@ int io_sendzc(struct io_kiocb *req, unsigned int issue_flags)
10301027
msg.msg_namelen = zc->addr_len;
10311028
}
10321029

1030+
if (!(req->flags & REQ_F_POLLED) &&
1031+
(zc->flags & IORING_RECVSEND_POLL_FIRST))
1032+
return io_setup_async_addr(req, addr, issue_flags);
1033+
10331034
if (zc->flags & IORING_RECVSEND_FIXED_BUF) {
10341035
ret = io_import_fixed(WRITE, &msg.msg_iter, req->imu,
10351036
(u64)(uintptr_t)zc->buf, zc->len);

io_uring/notif.c

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,6 @@ static void __io_notif_complete_tw(struct io_kiocb *notif, bool *locked)
2121
io_req_task_complete(notif, locked);
2222
}
2323

24-
static inline void io_notif_complete(struct io_kiocb *notif)
25-
__must_hold(&notif->ctx->uring_lock)
26-
{
27-
bool locked = true;
28-
29-
__io_notif_complete_tw(notif, &locked);
30-
}
31-
3224
static void io_uring_tx_zerocopy_callback(struct sk_buff *skb,
3325
struct ubuf_info *uarg,
3426
bool success)

io_uring/rw.c

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -206,14 +206,28 @@ static bool __io_complete_rw_common(struct io_kiocb *req, long res)
206206
return false;
207207
}
208208

209+
static inline unsigned io_fixup_rw_res(struct io_kiocb *req, unsigned res)
210+
{
211+
struct io_async_rw *io = req->async_data;
212+
213+
/* add previously done IO, if any */
214+
if (req_has_async_data(req) && io->bytes_done > 0) {
215+
if (res < 0)
216+
res = io->bytes_done;
217+
else
218+
res += io->bytes_done;
219+
}
220+
return res;
221+
}
222+
209223
static void io_complete_rw(struct kiocb *kiocb, long res)
210224
{
211225
struct io_rw *rw = container_of(kiocb, struct io_rw, kiocb);
212226
struct io_kiocb *req = cmd_to_io_kiocb(rw);
213227

214228
if (__io_complete_rw_common(req, res))
215229
return;
216-
io_req_set_res(req, res, 0);
230+
io_req_set_res(req, io_fixup_rw_res(req, res), 0);
217231
req->io_task_work.func = io_req_task_complete;
218232
io_req_task_work_add(req);
219233
}
@@ -240,22 +254,14 @@ static void io_complete_rw_iopoll(struct kiocb *kiocb, long res)
240254
static int kiocb_done(struct io_kiocb *req, ssize_t ret,
241255
unsigned int issue_flags)
242256
{
243-
struct io_async_rw *io = req->async_data;
244257
struct io_rw *rw = io_kiocb_to_cmd(req, struct io_rw);
245-
246-
/* add previously done IO, if any */
247-
if (req_has_async_data(req) && io->bytes_done > 0) {
248-
if (ret < 0)
249-
ret = io->bytes_done;
250-
else
251-
ret += io->bytes_done;
252-
}
258+
unsigned final_ret = io_fixup_rw_res(req, ret);
253259

254260
if (req->flags & REQ_F_CUR_POS)
255261
req->file->f_pos = rw->kiocb.ki_pos;
256262
if (ret >= 0 && (rw->kiocb.ki_complete == io_complete_rw)) {
257263
if (!__io_complete_rw_common(req, ret)) {
258-
io_req_set_res(req, req->cqe.res,
264+
io_req_set_res(req, final_ret,
259265
io_put_kbuf(req, issue_flags));
260266
return IOU_OK;
261267
}
@@ -268,7 +274,7 @@ static int kiocb_done(struct io_kiocb *req, ssize_t ret,
268274
if (io_resubmit_prep(req))
269275
io_req_task_queue_reissue(req);
270276
else
271-
io_req_task_queue_fail(req, ret);
277+
io_req_task_queue_fail(req, final_ret);
272278
}
273279
return IOU_ISSUE_SKIP_COMPLETE;
274280
}

0 commit comments

Comments
 (0)