Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Merge tag 'io_uring-6.12-20241011' of git://git.kernel.dk/linux

Pull io_uring fixes from Jens Axboe:

- Explicitly have a mshot_finished condition for IORING_OP_RECV in
multishot mode, similarly to what IORING_OP_RECVMSG has. This doesn't
fix a bug right now, but it makes it harder to actually have a bug
here if a request takes multiple iterations to finish.

- Fix handling of retry of read/write of !FMODE_NOWAIT files. If they
are pollable, that's all we need.

* tag 'io_uring-6.12-20241011' of git://git.kernel.dk/linux:
io_uring/rw: allow pollable non-blocking attempts for !FMODE_NOWAIT
io_uring/rw: fix cflags posting for single issue multishot read

+24 -20
+24 -20
io_uring/rw.c
··· 31 31 rwf_t flags; 32 32 }; 33 33 34 - static inline bool io_file_supports_nowait(struct io_kiocb *req) 34 + static bool io_file_supports_nowait(struct io_kiocb *req, __poll_t mask) 35 35 { 36 - return req->flags & REQ_F_SUPPORT_NOWAIT; 36 + /* If FMODE_NOWAIT is set for a file, we're golden */ 37 + if (req->flags & REQ_F_SUPPORT_NOWAIT) 38 + return true; 39 + /* No FMODE_NOWAIT, if we can poll, check the status */ 40 + if (io_file_can_poll(req)) { 41 + struct poll_table_struct pt = { ._key = mask }; 42 + 43 + return vfs_poll(req->file, &pt) & mask; 44 + } 45 + /* No FMODE_NOWAIT support, and file isn't pollable. Tough luck. */ 46 + return false; 37 47 } 38 48 39 49 #ifdef CONFIG_COMPAT ··· 806 796 * supports async. Otherwise it's impossible to use O_NONBLOCK files 807 797 * reliably. If not, or it IOCB_NOWAIT is set, don't retry. 808 798 */ 809 - if ((kiocb->ki_flags & IOCB_NOWAIT) || 810 - ((file->f_flags & O_NONBLOCK) && !io_file_supports_nowait(req))) 799 + if (kiocb->ki_flags & IOCB_NOWAIT || 800 + ((file->f_flags & O_NONBLOCK && (req->flags & REQ_F_SUPPORT_NOWAIT)))) 811 801 req->flags |= REQ_F_NOWAIT; 812 802 813 803 if (ctx->flags & IORING_SETUP_IOPOLL) { ··· 848 838 849 839 if (force_nonblock) { 850 840 /* If the file doesn't support async, just async punt */ 851 - if (unlikely(!io_file_supports_nowait(req))) 841 + if (unlikely(!io_file_supports_nowait(req, EPOLLIN))) 852 842 return -EAGAIN; 853 843 kiocb->ki_flags |= IOCB_NOWAIT; 854 844 } else { ··· 962 952 ret = __io_read(req, issue_flags); 963 953 964 954 /* 965 - * If the file doesn't support proper NOWAIT, then disable multishot 966 - * and stay in single shot mode. 967 - */ 968 - if (!io_file_supports_nowait(req)) 969 - req->flags &= ~REQ_F_APOLL_MULTISHOT; 970 - 971 - /* 972 955 * If we get -EAGAIN, recycle our buffer and just let normal poll 973 956 * handling arm it. 974 957 */ ··· 975 972 if (issue_flags & IO_URING_F_MULTISHOT) 976 973 return IOU_ISSUE_SKIP_COMPLETE; 977 974 return -EAGAIN; 978 - } 979 - 980 - /* 981 - * Any successful return value will keep the multishot read armed. 982 - */ 983 - if (ret > 0 && req->flags & REQ_F_APOLL_MULTISHOT) { 975 + } else if (ret <= 0) { 976 + io_kbuf_recycle(req, issue_flags); 977 + if (ret < 0) 978 + req_set_fail(req); 979 + } else { 984 980 /* 985 - * Put our buffer and post a CQE. If we fail to post a CQE, then 981 + * Any successful return value will keep the multishot read 982 + * armed, if it's still set. Put our buffer and post a CQE. If 983 + * we fail to post a CQE, or multishot is no longer set, then 986 984 * jump to the termination path. This request is then done. 987 985 */ 988 986 cflags = io_put_kbuf(req, ret, issue_flags); ··· 1030 1026 1031 1027 if (force_nonblock) { 1032 1028 /* If the file doesn't support async, just async punt */ 1033 - if (unlikely(!io_file_supports_nowait(req))) 1029 + if (unlikely(!io_file_supports_nowait(req, EPOLLOUT))) 1034 1030 goto ret_eagain; 1035 1031 1036 1032 /* Check if we can support NOWAIT. */