Skip to content

Commit 6784ad1

Browse files
committed
Merge branch 'io_uring-6.16' into for-next
* io_uring-6.16: io_uring/futex: mark wait requests as inflight io_uring/futex: get rid of struct io_futex addr union
2 parents a1dcac5 + 079afb0 commit 6784ad1

3 files changed

Lines changed: 13 additions & 6 deletions

File tree

io_uring/futex.c

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,7 @@
1414

1515
struct io_futex {
1616
struct file *file;
17-
union {
18-
u32 __user *uaddr;
19-
struct futex_waitv __user *uwaitv;
20-
};
17+
void __user *uaddr;
2118
unsigned long futex_val;
2219
unsigned long futex_mask;
2320
unsigned long futexv_owned;
@@ -148,6 +145,8 @@ int io_futex_prep(struct io_kiocb *req, const struct io_uring_sqe *sqe)
148145
!futex_validate_input(iof->futex_flags, iof->futex_mask))
149146
return -EINVAL;
150147

148+
/* Mark as inflight, so file exit cancelation will find it */
149+
io_req_track_inflight(req);
151150
return 0;
152151
}
153152

@@ -186,13 +185,15 @@ int io_futexv_prep(struct io_kiocb *req, const struct io_uring_sqe *sqe)
186185
if (!futexv)
187186
return -ENOMEM;
188187

189-
ret = futex_parse_waitv(futexv, iof->uwaitv, iof->futex_nr,
188+
ret = futex_parse_waitv(futexv, iof->uaddr, iof->futex_nr,
190189
io_futex_wakev_fn, req);
191190
if (ret) {
192191
kfree(futexv);
193192
return ret;
194193
}
195194

195+
/* Mark as inflight, so file exit cancelation will find it */
196+
io_req_track_inflight(req);
196197
iof->futexv_owned = 0;
197198
iof->futexv_unqueued = 0;
198199
req->flags |= REQ_F_ASYNC_DATA;

io_uring/io_uring.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -408,7 +408,12 @@ static void io_clean_op(struct io_kiocb *req)
408408
req->flags &= ~IO_REQ_CLEAN_FLAGS;
409409
}
410410

411-
static inline void io_req_track_inflight(struct io_kiocb *req)
411+
/*
412+
* Mark the request as inflight, so that file cancelation will find it.
413+
* Can be used if the file is an io_uring instance, or if the request itself
414+
* relies on ->mm being alive for the duration of the request.
415+
*/
416+
inline void io_req_track_inflight(struct io_kiocb *req)
412417
{
413418
if (!(req->flags & REQ_F_INFLIGHT)) {
414419
req->flags |= REQ_F_INFLIGHT;

io_uring/io_uring.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ void io_add_aux_cqe(struct io_ring_ctx *ctx, u64 user_data, s32 res, u32 cflags)
8383
bool io_req_post_cqe(struct io_kiocb *req, s32 res, u32 cflags);
8484
void __io_commit_cqring_flush(struct io_ring_ctx *ctx);
8585

86+
void io_req_track_inflight(struct io_kiocb *req);
8687
struct file *io_file_get_normal(struct io_kiocb *req, int fd);
8788
struct file *io_file_get_fixed(struct io_kiocb *req, int fd,
8889
unsigned issue_flags);

0 commit comments

Comments
 (0)