cancel.h 962 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. // SPDX-License-Identifier: GPL-2.0
  2. #ifndef IORING_CANCEL_H
  3. #define IORING_CANCEL_H
  4. #include <linux/io_uring_types.h>
  5. struct io_cancel_data {
  6. struct io_ring_ctx *ctx;
  7. union {
  8. u64 data;
  9. struct file *file;
  10. };
  11. u8 opcode;
  12. u32 flags;
  13. int seq;
  14. };
  15. int io_async_cancel_prep(struct io_kiocb *req, const struct io_uring_sqe *sqe);
  16. int io_async_cancel(struct io_kiocb *req, unsigned int issue_flags);
  17. int io_try_cancel(struct io_uring_task *tctx, struct io_cancel_data *cd,
  18. unsigned int issue_flags);
  19. void init_hash_table(struct io_hash_table *table, unsigned size);
  20. int io_sync_cancel(struct io_ring_ctx *ctx, void __user *arg);
  21. bool io_cancel_req_match(struct io_kiocb *req, struct io_cancel_data *cd);
  22. static inline bool io_cancel_match_sequence(struct io_kiocb *req, int sequence)
  23. {
  24. if (req->cancel_seq_set && sequence == req->work.cancel_seq)
  25. return true;
  26. req->cancel_seq_set = true;
  27. req->work.cancel_seq = sequence;
  28. return false;
  29. }
  30. #endif