Skip to content

Commit 7d8ca72

Browse files
committed
io_uring: add IORING_ASYNC_CANCEL_FD_FIXED cancel flag
In preparation for not having a request to pass in that carries this state, add a separate cancelation flag that allows the caller to ask for a fixed file for cancelation. Signed-off-by: Jens Axboe <[email protected]>
1 parent 88f52ea commit 7d8ca72

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

include/uapi/linux/io_uring.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -247,10 +247,12 @@ enum io_uring_op {
247247
* IORING_ASYNC_CANCEL_FD Key off 'fd' for cancelation rather than the
248248
* request 'user_data'
249249
* IORING_ASYNC_CANCEL_ANY Match any request
250+
* IORING_ASYNC_CANCEL_FD_FIXED 'fd' passed in is a fixed descriptor
250251
*/
251252
#define IORING_ASYNC_CANCEL_ALL (1U << 0)
252253
#define IORING_ASYNC_CANCEL_FD (1U << 1)
253254
#define IORING_ASYNC_CANCEL_ANY (1U << 2)
255+
#define IORING_ASYNC_CANCEL_FD_FIXED (1U << 3)
254256

255257
/*
256258
* send/sendmsg and recv/recvmsg flags (sqe->ioprio)

io_uring/cancel.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ struct io_cancel {
2424
};
2525

2626
#define CANCEL_FLAGS (IORING_ASYNC_CANCEL_ALL | IORING_ASYNC_CANCEL_FD | \
27-
IORING_ASYNC_CANCEL_ANY)
27+
IORING_ASYNC_CANCEL_ANY | IORING_ASYNC_CANCEL_FD_FIXED)
2828

2929
static bool io_cancel_cb(struct io_wq_work *work, void *data)
3030
{
@@ -174,11 +174,14 @@ int io_async_cancel(struct io_kiocb *req, unsigned int issue_flags)
174174
int ret;
175175

176176
if (cd.flags & IORING_ASYNC_CANCEL_FD) {
177-
if (req->flags & REQ_F_FIXED_FILE)
177+
if (req->flags & REQ_F_FIXED_FILE ||
178+
cd.flags & IORING_ASYNC_CANCEL_FD_FIXED) {
179+
req->flags |= REQ_F_FIXED_FILE;
178180
req->file = io_file_get_fixed(req, cancel->fd,
179181
issue_flags);
180-
else
182+
} else {
181183
req->file = io_file_get_normal(req, cancel->fd);
184+
}
182185
if (!req->file) {
183186
ret = -EBADF;
184187
goto done;

0 commit comments

Comments
 (0)