@@ -70,6 +70,7 @@ const struct io_op_def io_op_defs[] = {
.prep_async = io_readv_prep_async,
.cleanup = io_readv_writev_cleanup,
.fail = io_rw_fail,
+ .can_retarget_rsrc = io_read_can_retarget_rsrc,
},
[IORING_OP_WRITEV] = {
.needs_file = 1,
@@ -284,6 +285,7 @@ const struct io_op_def io_op_defs[] = {
.prep = io_prep_rw,
.issue = io_read,
.fail = io_rw_fail,
+ .can_retarget_rsrc = io_read_can_retarget_rsrc,
},
[IORING_OP_WRITE] = {
.needs_file = 1,
@@ -1068,3 +1068,17 @@ int io_do_iopoll(struct io_ring_ctx *ctx, bool force_nonspin)
io_free_batch_list(ctx, pos);
return nr_events;
}
+
+bool io_read_can_retarget_rsrc(struct io_kiocb *req)
+{
+ struct file *f;
+
+ if (!(req->flags & REQ_F_FIXED_FILE))
+ return true;
+
+ f = io_file_peek_fixed(req, req->cqe.fd);
+ if (f != req->file)
+ return false;
+
+ return true;
+}
@@ -22,3 +22,4 @@ int io_write(struct io_kiocb *req, unsigned int issue_flags);
int io_writev_prep_async(struct io_kiocb *req);
void io_readv_writev_cleanup(struct io_kiocb *req);
void io_rw_fail(struct io_kiocb *req);
+bool io_read_can_retarget_rsrc(struct io_kiocb *req);
Add can_retarget_rsrc handler for read Signed-off-by: Dylan Yudaken <dylany@meta.com> --- io_uring/opdef.c | 2 ++ io_uring/rw.c | 14 ++++++++++++++ io_uring/rw.h | 1 + 3 files changed, 17 insertions(+)