mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2026-04-03 12:05:13 +02:00
[ Upstream commit22dbb0987b] By having them share the same space in struct io_cancel_data, it ends up disallowing IORING_ASYNC_CANCEL_FD|IORING_ASYNC_CANCEL_USERDATA from working. Eg you cannot match on both a file and user_data for cancelation purposes. This obviously isn't a common use case as nobody has reported this, but it does result in -ENOENT potentially being returned when trying to match on both, rather than actually doing what the API says it would. Fixes:4bf94615b8("io_uring: allow IORING_OP_ASYNC_CANCEL with 'fd' key") Signed-off-by: Jens Axboe <axboe@kernel.dk> Signed-off-by: Sasha Levin <sashal@kernel.org>
37 lines
947 B
C
37 lines
947 B
C
// SPDX-License-Identifier: GPL-2.0
|
|
#ifndef IORING_CANCEL_H
|
|
#define IORING_CANCEL_H
|
|
|
|
#include <linux/io_uring_types.h>
|
|
|
|
struct io_cancel_data {
|
|
struct io_ring_ctx *ctx;
|
|
u64 data;
|
|
struct file *file;
|
|
u8 opcode;
|
|
u32 flags;
|
|
int seq;
|
|
};
|
|
|
|
int io_async_cancel_prep(struct io_kiocb *req, const struct io_uring_sqe *sqe);
|
|
int io_async_cancel(struct io_kiocb *req, unsigned int issue_flags);
|
|
|
|
int io_try_cancel(struct io_uring_task *tctx, struct io_cancel_data *cd,
|
|
unsigned int issue_flags);
|
|
void init_hash_table(struct io_hash_table *table, unsigned size);
|
|
|
|
int io_sync_cancel(struct io_ring_ctx *ctx, void __user *arg);
|
|
bool io_cancel_req_match(struct io_kiocb *req, struct io_cancel_data *cd);
|
|
|
|
static inline bool io_cancel_match_sequence(struct io_kiocb *req, int sequence)
|
|
{
|
|
if (req->cancel_seq_set && sequence == req->work.cancel_seq)
|
|
return true;
|
|
|
|
req->cancel_seq_set = true;
|
|
req->work.cancel_seq = sequence;
|
|
return false;
|
|
}
|
|
|
|
#endif
|