@@ -92,36 +92,25 @@ static struct file *io_msg_grab_file(struct io_kiocb *req, unsigned int issue_fl
92
92
return file ;
93
93
}
94
94
95
- static int io_msg_send_fd (struct io_kiocb * req , unsigned int issue_flags )
95
+ static int io_msg_install_complete (struct io_kiocb * req , unsigned int issue_flags )
96
96
{
97
97
struct io_ring_ctx * target_ctx = req -> file -> private_data ;
98
98
struct io_msg * msg = io_kiocb_to_cmd (req , struct io_msg );
99
- struct io_ring_ctx * ctx = req -> ctx ;
100
99
struct file * src_file = msg -> src_file ;
101
100
int ret ;
102
101
103
- if (target_ctx == ctx )
104
- return - EINVAL ;
105
- if (!src_file ) {
106
- src_file = io_msg_grab_file (req , issue_flags );
107
- if (!src_file )
108
- return - EBADF ;
109
- msg -> src_file = src_file ;
110
- req -> flags |= REQ_F_NEED_CLEANUP ;
111
- }
112
-
113
102
if (unlikely (io_double_lock_ctx (target_ctx , issue_flags )))
114
103
return - EAGAIN ;
115
104
116
105
ret = __io_fixed_fd_install (target_ctx , src_file , msg -> dst_fd );
117
106
if (ret < 0 )
118
107
goto out_unlock ;
108
+
119
109
msg -> src_file = NULL ;
120
110
req -> flags &= ~REQ_F_NEED_CLEANUP ;
121
111
122
112
if (msg -> flags & IORING_MSG_RING_CQE_SKIP )
123
113
goto out_unlock ;
124
-
125
114
/*
126
115
* If this fails, the target still received the file descriptor but
127
116
* wasn't notified of the fact. This means that if this request
@@ -135,6 +124,25 @@ static int io_msg_send_fd(struct io_kiocb *req, unsigned int issue_flags)
135
124
return ret ;
136
125
}
137
126
127
+ static int io_msg_send_fd (struct io_kiocb * req , unsigned int issue_flags )
128
+ {
129
+ struct io_ring_ctx * target_ctx = req -> file -> private_data ;
130
+ struct io_msg * msg = io_kiocb_to_cmd (req , struct io_msg );
131
+ struct io_ring_ctx * ctx = req -> ctx ;
132
+ struct file * src_file = msg -> src_file ;
133
+
134
+ if (target_ctx == ctx )
135
+ return - EINVAL ;
136
+ if (!src_file ) {
137
+ src_file = io_msg_grab_file (req , issue_flags );
138
+ if (!src_file )
139
+ return - EBADF ;
140
+ msg -> src_file = src_file ;
141
+ req -> flags |= REQ_F_NEED_CLEANUP ;
142
+ }
143
+ return io_msg_install_complete (req , issue_flags );
144
+ }
145
+
138
146
int io_msg_ring_prep (struct io_kiocb * req , const struct io_uring_sqe * sqe )
139
147
{
140
148
struct io_msg * msg = io_kiocb_to_cmd (req , struct io_msg );
0 commit comments