Skip to content

Commit 18e70f3

Browse files
committed
Merge tag 'io_uring-5.7-2020-05-15' of git://git.kernel.dk/linux-block
Pull io_uring fixes from Jens Axboe: "Two small fixes that should go into this release: - Check and handle zero length splice (Pavel) - Fix a regression in this merge window for fixed files used with polled block IO" * tag 'io_uring-5.7-2020-05-15' of git://git.kernel.dk/linux-block: io_uring: polled fixed file must go through free iteration io_uring: fix zero len do_splice()
2 parents 12bf0b6 + 9d9e88a commit 18e70f3

File tree

1 file changed

+8
-9
lines changed

1 file changed

+8
-9
lines changed

fs/io_uring.c

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1394,10 +1394,6 @@ static void io_free_req_many(struct io_ring_ctx *ctx, struct req_batch *rb)
13941394
for (i = 0; i < rb->to_free; i++) {
13951395
struct io_kiocb *req = rb->reqs[i];
13961396

1397-
if (req->flags & REQ_F_FIXED_FILE) {
1398-
req->file = NULL;
1399-
percpu_ref_put(req->fixed_file_refs);
1400-
}
14011397
if (req->flags & REQ_F_INFLIGHT)
14021398
inflight++;
14031399
__io_req_aux_free(req);
@@ -1670,7 +1666,7 @@ static inline bool io_req_multi_free(struct req_batch *rb, struct io_kiocb *req)
16701666
if ((req->flags & REQ_F_LINK_HEAD) || io_is_fallback_req(req))
16711667
return false;
16721668

1673-
if (!(req->flags & REQ_F_FIXED_FILE) || req->io)
1669+
if (req->file || req->io)
16741670
rb->need_iter++;
16751671

16761672
rb->reqs[rb->to_free++] = req;
@@ -2767,16 +2763,19 @@ static int io_splice(struct io_kiocb *req, bool force_nonblock)
27672763
struct file *out = sp->file_out;
27682764
unsigned int flags = sp->flags & ~SPLICE_F_FD_IN_FIXED;
27692765
loff_t *poff_in, *poff_out;
2770-
long ret;
2766+
long ret = 0;
27712767

27722768
if (force_nonblock)
27732769
return -EAGAIN;
27742770

27752771
poff_in = (sp->off_in == -1) ? NULL : &sp->off_in;
27762772
poff_out = (sp->off_out == -1) ? NULL : &sp->off_out;
2777-
ret = do_splice(in, poff_in, out, poff_out, sp->len, flags);
2778-
if (force_nonblock && ret == -EAGAIN)
2779-
return -EAGAIN;
2773+
2774+
if (sp->len) {
2775+
ret = do_splice(in, poff_in, out, poff_out, sp->len, flags);
2776+
if (force_nonblock && ret == -EAGAIN)
2777+
return -EAGAIN;
2778+
}
27802779

27812780
io_put_file(req, in, (sp->flags & SPLICE_F_FD_IN_FIXED));
27822781
req->flags &= ~REQ_F_NEED_CLEANUP;

0 commit comments

Comments
 (0)