Skip to content

Commit e59cd88

Browse files
committed
Merge tag 'for-5.7/io_uring-2020-03-29' of git://git.kernel.dk/linux-block
Pull io_uring updates from Jens Axboe: "Here are the io_uring changes for this merge window. Light on new features this time around (just splice + buffer selection), lots of cleanups, fixes, and improvements to existing support. In particular, this contains: - Cleanup fixed file update handling for stack fallback (Hillf) - Re-work of how pollable async IO is handled, we no longer require thread offload to handle that. Instead we rely using poll to drive this, with task_work execution. - In conjunction with the above, allow expendable buffer selection, so that poll+recv (for example) no longer has to be a split operation. - Make sure we honor RLIMIT_FSIZE for buffered writes - Add support for splice (Pavel) - Linked work inheritance fixes and optimizations (Pavel) - Async work fixes and cleanups (Pavel) - Improve io-wq locking (Pavel) - Hashed link write improvements (Pavel) - SETUP_IOPOLL|SETUP_SQPOLL improvements (Xiaoguang)" * tag 'for-5.7/io_uring-2020-03-29' of git://git.kernel.dk/linux-block: (54 commits) io_uring: cleanup io_alloc_async_ctx() io_uring: fix missing 'return' in comment io-wq: handle hashed writes in chains io-uring: drop 'free_pfile' in struct io_file_put io-uring: drop completion when removing file io_uring: Fix ->data corruption on re-enqueue io-wq: close cancel gap for hashed linked work io_uring: make spdxcheck.py happy io_uring: honor original task RLIMIT_FSIZE io-wq: hash dependent work io-wq: split hashing and enqueueing io-wq: don't resched if there is no work io-wq: remove duplicated cancel code io_uring: fix truncated async read/readv and write/writev retry io_uring: dual license io_uring.h uapi header io_uring: io_uring_enter(2) don't poll while SETUP_IOPOLL|SETUP_SQPOLL enabled io_uring: Fix unused function warnings io_uring: add end-of-bits marker and build time verify it io_uring: provide means of removing buffers io_uring: add IOSQE_BUFFER_SELECT support for IORING_OP_RECVMSG ...
2 parents 1592614 + 3d9932a commit e59cd88

12 files changed

Lines changed: 1826 additions & 856 deletions

File tree

‎fs/io-wq.c‎

Lines changed: 162 additions & 206 deletions
Large diffs are not rendered by default.

‎fs/io-wq.h‎

Lines changed: 46 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,8 @@ struct io_wq;
55

66
enum {
77
IO_WQ_WORK_CANCEL = 1,
8-
IO_WQ_WORK_HAS_MM = 2,
98
IO_WQ_WORK_HASHED = 4,
109
IO_WQ_WORK_UNBOUND = 32,
11-
IO_WQ_WORK_CB = 128,
1210
IO_WQ_WORK_NO_CANCEL = 256,
1311
IO_WQ_WORK_CONCURRENT = 512,
1412

@@ -30,6 +28,18 @@ struct io_wq_work_list {
3028
struct io_wq_work_node *last;
3129
};
3230

31+
static inline void wq_list_add_after(struct io_wq_work_node *node,
32+
struct io_wq_work_node *pos,
33+
struct io_wq_work_list *list)
34+
{
35+
struct io_wq_work_node *next = pos->next;
36+
37+
pos->next = node;
38+
node->next = next;
39+
if (!next)
40+
list->last = node;
41+
}
42+
3343
static inline void wq_list_add_tail(struct io_wq_work_node *node,
3444
struct io_wq_work_list *list)
3545
{
@@ -42,17 +52,26 @@ static inline void wq_list_add_tail(struct io_wq_work_node *node,
4252
}
4353
}
4454

45-
static inline void wq_node_del(struct io_wq_work_list *list,
46-
struct io_wq_work_node *node,
55+
static inline void wq_list_cut(struct io_wq_work_list *list,
56+
struct io_wq_work_node *last,
4757
struct io_wq_work_node *prev)
4858
{
49-
if (node == list->first)
50-
WRITE_ONCE(list->first, node->next);
51-
if (node == list->last)
59+
/* first in the list, if prev==NULL */
60+
if (!prev)
61+
WRITE_ONCE(list->first, last->next);
62+
else
63+
prev->next = last->next;
64+
65+
if (last == list->last)
5266
list->last = prev;
53-
if (prev)
54-
prev->next = node->next;
55-
node->next = NULL;
67+
last->next = NULL;
68+
}
69+
70+
static inline void wq_list_del(struct io_wq_work_list *list,
71+
struct io_wq_work_node *node,
72+
struct io_wq_work_node *prev)
73+
{
74+
wq_list_cut(list, node, prev);
5675
}
5776

5877
#define wq_list_for_each(pos, prv, head) \
@@ -65,10 +84,7 @@ static inline void wq_node_del(struct io_wq_work_list *list,
6584
} while (0)
6685

6786
struct io_wq_work {
68-
union {
69-
struct io_wq_work_node list;
70-
void *data;
71-
};
87+
struct io_wq_work_node list;
7288
void (*func)(struct io_wq_work **);
7389
struct files_struct *files;
7490
struct mm_struct *mm;
@@ -83,22 +99,33 @@ struct io_wq_work {
8399
*(work) = (struct io_wq_work){ .func = _func }; \
84100
} while (0) \
85101

86-
typedef void (get_work_fn)(struct io_wq_work *);
87-
typedef void (put_work_fn)(struct io_wq_work *);
102+
static inline struct io_wq_work *wq_next_work(struct io_wq_work *work)
103+
{
104+
if (!work->list.next)
105+
return NULL;
106+
107+
return container_of(work->list.next, struct io_wq_work, list);
108+
}
109+
110+
typedef void (free_work_fn)(struct io_wq_work *);
88111

89112
struct io_wq_data {
90113
struct user_struct *user;
91114

92-
get_work_fn *get_work;
93-
put_work_fn *put_work;
115+
free_work_fn *free_work;
94116
};
95117

96118
struct io_wq *io_wq_create(unsigned bounded, struct io_wq_data *data);
97119
bool io_wq_get(struct io_wq *wq, struct io_wq_data *data);
98120
void io_wq_destroy(struct io_wq *wq);
99121

100122
void io_wq_enqueue(struct io_wq *wq, struct io_wq_work *work);
101-
void io_wq_enqueue_hashed(struct io_wq *wq, struct io_wq_work *work, void *val);
123+
void io_wq_hash_work(struct io_wq_work *work, void *val);
124+
125+
static inline bool io_wq_is_hashed(struct io_wq_work *work)
126+
{
127+
return work->flags & IO_WQ_WORK_HASHED;
128+
}
102129

103130
void io_wq_cancel_all(struct io_wq *wq);
104131
enum io_wq_cancel io_wq_cancel_work(struct io_wq *wq, struct io_wq_work *cwork);

0 commit comments

Comments
 (0)