Skip to content

Commit 81d82e4

Browse files
committed
Merge branch 'for-6.17/io_uring' into for-next
* for-6.17/io_uring: (39 commits) io_uring: fix breakage in EXPERT menu io_uring/cmd: remove struct io_uring_cmd_data btrfs/ioctl: store btrfs_uring_encoded_data in io_btrfs_cmd io_uring/cmd: introduce IORING_URING_CMD_REISSUE flag io_uring/zcrx: account area memory io_uring: export io_[un]account_mem io_uring/net: Support multishot receive len cap io_uring: deduplicate wakeup handling io_uring/net: cast min_not_zero() type io_uring/poll: cleanup apoll freeing io_uring/net: allow multishot receive per-invocation cap io_uring/net: move io_sr_msg->retry_flags to io_sr_msg->flags io_uring/net: use passed in 'len' in io_recv_buf_select() io_uring/zcrx: prepare fallback for larger pages io_uring/zcrx: assert area type in io_zcrx_iov_page io_uring/zcrx: allocate sgtable for umem areas io_uring/zcrx: introduce io_populate_area_dma io_uring/zcrx: return error from io_zcrx_map_area_* io_uring/zcrx: always pass page to io_zcrx_copy_chunk io_uring/rw: cast rw->flags assignment to rwf_t ...
2 parents edf312f + d1fbe1e commit 81d82e4

27 files changed

Lines changed: 1026 additions & 234 deletions

File tree

MAINTAINERS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12684,6 +12684,7 @@ F: include/linux/io_uring.h
1268412684
F: include/linux/io_uring_types.h
1268512685
F: include/trace/events/io_uring.h
1268612686
F: include/uapi/linux/io_uring.h
12687+
F: include/uapi/linux/io_uring/
1268712688
F: io_uring/
1268812689

1268912690
IPMI SUBSYSTEM

fs/btrfs/ioctl.c

Lines changed: 27 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4629,6 +4629,13 @@ static int btrfs_ioctl_encoded_write(struct file *file, void __user *argp, bool
46294629
return ret;
46304630
}
46314631

4632+
struct btrfs_uring_encoded_data {
4633+
struct btrfs_ioctl_encoded_io_args args;
4634+
struct iovec iovstack[UIO_FASTIOV];
4635+
struct iovec *iov;
4636+
struct iov_iter iter;
4637+
};
4638+
46324639
/*
46334640
* Context that's attached to an encoded read io_uring command, in cmd->pdu. It
46344641
* contains the fields in btrfs_uring_read_extent that are necessary to finish
@@ -4650,6 +4657,7 @@ struct btrfs_uring_priv {
46504657
};
46514658

46524659
struct io_btrfs_cmd {
4660+
struct btrfs_uring_encoded_data *data;
46534661
struct btrfs_uring_priv *priv;
46544662
};
46554663

@@ -4708,6 +4716,7 @@ static void btrfs_uring_read_finished(struct io_uring_cmd *cmd, unsigned int iss
47084716
kfree(priv->pages);
47094717
kfree(priv->iov);
47104718
kfree(priv);
4719+
kfree(bc->data);
47114720
}
47124721

47134722
void btrfs_uring_read_extent_endio(void *ctx, int err)
@@ -4791,13 +4800,6 @@ static int btrfs_uring_read_extent(struct kiocb *iocb, struct iov_iter *iter,
47914800
return ret;
47924801
}
47934802

4794-
struct btrfs_uring_encoded_data {
4795-
struct btrfs_ioctl_encoded_io_args args;
4796-
struct iovec iovstack[UIO_FASTIOV];
4797-
struct iovec *iov;
4798-
struct iov_iter iter;
4799-
};
4800-
48014803
static int btrfs_uring_encoded_read(struct io_uring_cmd *cmd, unsigned int issue_flags)
48024804
{
48034805
size_t copy_end_kernel = offsetofend(struct btrfs_ioctl_encoded_io_args, flags);
@@ -4813,7 +4815,11 @@ static int btrfs_uring_encoded_read(struct io_uring_cmd *cmd, unsigned int issue
48134815
struct extent_state *cached_state = NULL;
48144816
u64 start, lockend;
48154817
void __user *sqe_addr;
4816-
struct btrfs_uring_encoded_data *data = io_uring_cmd_get_async_data(cmd)->op_data;
4818+
struct io_btrfs_cmd *bc = io_uring_cmd_to_pdu(cmd, struct io_btrfs_cmd);
4819+
struct btrfs_uring_encoded_data *data = NULL;
4820+
4821+
if (cmd->flags & IORING_URING_CMD_REISSUE)
4822+
data = bc->data;
48174823

48184824
if (!capable(CAP_SYS_ADMIN)) {
48194825
ret = -EPERM;
@@ -4842,7 +4848,7 @@ static int btrfs_uring_encoded_read(struct io_uring_cmd *cmd, unsigned int issue
48424848
goto out_acct;
48434849
}
48444850

4845-
io_uring_cmd_get_async_data(cmd)->op_data = data;
4851+
bc->data = data;
48464852

48474853
if (issue_flags & IO_URING_F_COMPAT) {
48484854
#if defined(CONFIG_64BIT) && defined(CONFIG_COMPAT)
@@ -4940,6 +4946,9 @@ static int btrfs_uring_encoded_read(struct io_uring_cmd *cmd, unsigned int issue
49404946
add_rchar(current, ret);
49414947
inc_syscr(current);
49424948

4949+
if (ret != -EIOCBQUEUED && ret != -EAGAIN)
4950+
kfree(data);
4951+
49434952
return ret;
49444953
}
49454954

@@ -4950,7 +4959,11 @@ static int btrfs_uring_encoded_write(struct io_uring_cmd *cmd, unsigned int issu
49504959
struct file *file;
49514960
ssize_t ret;
49524961
void __user *sqe_addr;
4953-
struct btrfs_uring_encoded_data *data = io_uring_cmd_get_async_data(cmd)->op_data;
4962+
struct io_btrfs_cmd *bc = io_uring_cmd_to_pdu(cmd, struct io_btrfs_cmd);
4963+
struct btrfs_uring_encoded_data *data = NULL;
4964+
4965+
if (cmd->flags & IORING_URING_CMD_REISSUE)
4966+
data = bc->data;
49544967

49554968
if (!capable(CAP_SYS_ADMIN)) {
49564969
ret = -EPERM;
@@ -4972,7 +4985,7 @@ static int btrfs_uring_encoded_write(struct io_uring_cmd *cmd, unsigned int issu
49724985
goto out_acct;
49734986
}
49744987

4975-
io_uring_cmd_get_async_data(cmd)->op_data = data;
4988+
bc->data = data;
49764989

49774990
if (issue_flags & IO_URING_F_COMPAT) {
49784991
#if defined(CONFIG_64BIT) && defined(CONFIG_COMPAT)
@@ -5062,6 +5075,9 @@ static int btrfs_uring_encoded_write(struct io_uring_cmd *cmd, unsigned int issu
50625075
if (ret > 0)
50635076
add_wchar(current, ret);
50645077
inc_syscw(current);
5078+
5079+
if (ret != -EAGAIN)
5080+
kfree(data);
50655081
return ret;
50665082
}
50675083

include/linux/io_uring/cmd.h

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88

99
/* only top 8 bits of sqe->uring_cmd_flags for kernel internal use */
1010
#define IORING_URING_CMD_CANCELABLE (1U << 30)
11+
/* io_uring_cmd is being issued again */
12+
#define IORING_URING_CMD_REISSUE (1U << 31)
1113

1214
struct io_uring_cmd {
1315
struct file *file;
@@ -19,10 +21,6 @@ struct io_uring_cmd {
1921
u8 pdu[32]; /* available inline for free use */
2022
};
2123

22-
struct io_uring_cmd_data {
23-
void *op_data;
24-
};
25-
2624
static inline const void *io_uring_sqe_cmd(const struct io_uring_sqe *sqe)
2725
{
2826
return sqe->cmd;
@@ -135,11 +133,6 @@ static inline struct task_struct *io_uring_cmd_get_task(struct io_uring_cmd *cmd
135133
return cmd_to_io_kiocb(cmd)->tctx->task;
136134
}
137135

138-
static inline struct io_uring_cmd_data *io_uring_cmd_get_async_data(struct io_uring_cmd *cmd)
139-
{
140-
return cmd_to_io_kiocb(cmd)->async_data;
141-
}
142-
143136
/*
144137
* Return uring_cmd's context reference as its context handle for driver to
145138
* track per-context resource, such as registered kernel IO buffer

include/linux/io_uring_types.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ enum io_uring_cmd_flags {
2626
IO_URING_F_MULTISHOT = 4,
2727
/* executed by io-wq */
2828
IO_URING_F_IOWQ = 8,
29+
/* executed inline from syscall */
30+
IO_URING_F_INLINE = 16,
2931
/* int's last bit, sign checks are usually faster than a bit test */
3032
IO_URING_F_NONBLOCK = INT_MIN,
3133

@@ -502,6 +504,7 @@ enum {
502504
REQ_F_BUF_NODE_BIT,
503505
REQ_F_HAS_METADATA_BIT,
504506
REQ_F_IMPORT_BUFFER_BIT,
507+
REQ_F_SQE_COPIED_BIT,
505508

506509
/* not a real bit, just to check we're not overflowing the space */
507510
__REQ_F_LAST_BIT,
@@ -591,6 +594,8 @@ enum {
591594
* For SEND_ZC, whether to import buffers (i.e. the first issue).
592595
*/
593596
REQ_F_IMPORT_BUFFER = IO_REQ_FLAG(REQ_F_IMPORT_BUFFER_BIT),
597+
/* ->sqe_copy() has been called, if necessary */
598+
REQ_F_SQE_COPIED = IO_REQ_FLAG(REQ_F_SQE_COPIED_BIT),
594599
};
595600

596601
typedef void (*io_req_tw_func_t)(struct io_kiocb *req, io_tw_token_t tw);

include/net/sock.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2677,6 +2677,10 @@ void __sock_recv_timestamp(struct msghdr *msg, struct sock *sk,
26772677
void __sock_recv_wifi_status(struct msghdr *msg, struct sock *sk,
26782678
struct sk_buff *skb);
26792679

2680+
bool skb_has_tx_timestamp(struct sk_buff *skb, const struct sock *sk);
2681+
int skb_get_tx_timestamp(struct sk_buff *skb, struct sock *sk,
2682+
struct timespec64 *ts);
2683+
26802684
static inline void
26812685
sock_recv_timestamp(struct msghdr *msg, struct sock *sk, struct sk_buff *skb)
26822686
{

include/uapi/linux/io_uring.h

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ struct io_uring_sqe {
5050
};
5151
__u32 len; /* buffer size or number of iovecs */
5252
union {
53-
__kernel_rwf_t rw_flags;
53+
__u32 rw_flags;
5454
__u32 fsync_flags;
5555
__u16 poll_events; /* compatibility */
5656
__u32 poll32_events; /* word-reversed for BE */
@@ -449,6 +449,7 @@ enum io_uring_msg_ring_flags {
449449
#define IORING_NOP_FILE (1U << 1)
450450
#define IORING_NOP_FIXED_FILE (1U << 2)
451451
#define IORING_NOP_FIXED_BUFFER (1U << 3)
452+
#define IORING_NOP_TW (1U << 4)
452453

453454
/*
454455
* IO completion data structure (Completion Queue Entry)
@@ -968,6 +969,22 @@ enum io_uring_socket_op {
968969
SOCKET_URING_OP_SIOCOUTQ,
969970
SOCKET_URING_OP_GETSOCKOPT,
970971
SOCKET_URING_OP_SETSOCKOPT,
972+
SOCKET_URING_OP_TX_TIMESTAMP,
973+
};
974+
975+
/*
976+
* SOCKET_URING_OP_TX_TIMESTAMP definitions
977+
*/
978+
979+
#define IORING_TIMESTAMP_HW_SHIFT 16
980+
/* The cqe->flags bit from which the timestamp type is stored */
981+
#define IORING_TIMESTAMP_TYPE_SHIFT (IORING_TIMESTAMP_HW_SHIFT + 1)
982+
/* The cqe->flags flag signifying whether it's a hardware timestamp */
983+
#define IORING_CQE_F_TSTAMP_HW ((__u32)1 << IORING_TIMESTAMP_HW_SHIFT)
984+
985+
struct io_timespec {
986+
__u64 tv_sec;
987+
__u64 tv_nsec;
971988
};
972989

973990
/* Zero copy receive refill queue entry */
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
#ifndef LINUX_IO_URING_MOCK_FILE_H
2+
#define LINUX_IO_URING_MOCK_FILE_H
3+
4+
#include <linux/types.h>
5+
6+
enum {
7+
IORING_MOCK_FEAT_CMD_COPY,
8+
IORING_MOCK_FEAT_RW_ZERO,
9+
IORING_MOCK_FEAT_RW_NOWAIT,
10+
IORING_MOCK_FEAT_RW_ASYNC,
11+
IORING_MOCK_FEAT_POLL,
12+
13+
IORING_MOCK_FEAT_END,
14+
};
15+
16+
struct io_uring_mock_probe {
17+
__u64 features;
18+
__u64 __resv[9];
19+
};
20+
21+
enum {
22+
IORING_MOCK_CREATE_F_SUPPORT_NOWAIT = 1,
23+
IORING_MOCK_CREATE_F_POLL = 2,
24+
};
25+
26+
struct io_uring_mock_create {
27+
__u32 out_fd;
28+
__u32 flags;
29+
__u64 file_size;
30+
__u64 rw_delay_ns;
31+
__u64 __resv[13];
32+
};
33+
34+
enum {
35+
IORING_MOCK_MGR_CMD_PROBE,
36+
IORING_MOCK_MGR_CMD_CREATE,
37+
};
38+
39+
enum {
40+
IORING_MOCK_CMD_COPY_REGBUF,
41+
};
42+
43+
enum {
44+
IORING_MOCK_COPY_FROM = 1,
45+
};
46+
47+
#endif

init/Kconfig

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1794,7 +1794,7 @@ config IO_URING
17941794

17951795
config GCOV_PROFILE_URING
17961796
bool "Enable GCOV profiling on the io_uring subsystem"
1797-
depends on GCOV_KERNEL
1797+
depends on IO_URING && GCOV_KERNEL
17981798
help
17991799
Enable GCOV profiling on the io_uring subsystem, to facilitate
18001800
code coverage testing.
@@ -1805,6 +1805,17 @@ config GCOV_PROFILE_URING
18051805
the io_uring subsystem, hence this should only be enabled for
18061806
specific test purposes.
18071807

1808+
config IO_URING_MOCK_FILE
1809+
tristate "Enable io_uring mock files (Experimental)" if EXPERT
1810+
default n
1811+
depends on IO_URING
1812+
help
1813+
Enable mock files for io_uring subststem testing. The ABI might
1814+
still change, so it's still experimental and should only be enabled
1815+
for specific test purposes.
1816+
1817+
If unsure, say N.
1818+
18081819
config ADVISE_SYSCALLS
18091820
bool "Enable madvise/fadvise syscalls" if EXPERT
18101821
default y

io_uring/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,4 @@ obj-$(CONFIG_EPOLL) += epoll.o
2121
obj-$(CONFIG_NET_RX_BUSY_POLL) += napi.o
2222
obj-$(CONFIG_NET) += net.o cmd_net.o
2323
obj-$(CONFIG_PROC_FS) += fdinfo.o
24+
obj-$(CONFIG_IO_URING_MOCK_FILE) += mock_file.o

0 commit comments

Comments
 (0)