23
23
#include "poll.h"
24
24
#include "rw.h"
25
25
26
+ static void io_complete_rw (struct kiocb * kiocb , long res );
27
+ static void io_complete_rw_iopoll (struct kiocb * kiocb , long res );
28
+
26
29
struct io_rw {
27
30
/* NOTE: kiocb has the file as the first member, so don't do it here */
28
31
struct kiocb kiocb ;
@@ -289,6 +292,11 @@ static int io_prep_rw(struct io_kiocb *req, const struct io_uring_sqe *sqe,
289
292
rw -> kiocb .dio_complete = NULL ;
290
293
rw -> kiocb .ki_flags = 0 ;
291
294
295
+ if (req -> ctx -> flags & IORING_SETUP_IOPOLL )
296
+ rw -> kiocb .ki_complete = io_complete_rw_iopoll ;
297
+ else
298
+ rw -> kiocb .ki_complete = io_complete_rw ;
299
+
292
300
rw -> addr = READ_ONCE (sqe -> addr );
293
301
rw -> len = READ_ONCE (sqe -> len );
294
302
rw -> flags = READ_ONCE (sqe -> rw_flags );
@@ -817,10 +825,8 @@ static int io_rw_init_file(struct io_kiocb *req, fmode_t mode, int rw_type)
817
825
if (ctx -> flags & IORING_SETUP_IOPOLL ) {
818
826
if (!(kiocb -> ki_flags & IOCB_DIRECT ) || !file -> f_op -> iopoll )
819
827
return - EOPNOTSUPP ;
820
-
821
828
kiocb -> private = NULL ;
822
829
kiocb -> ki_flags |= IOCB_HIPRI ;
823
- kiocb -> ki_complete = io_complete_rw_iopoll ;
824
830
req -> iopoll_completed = 0 ;
825
831
if (ctx -> flags & IORING_SETUP_HYBRID_IOPOLL ) {
826
832
/* make sure every req only blocks once*/
@@ -830,7 +836,6 @@ static int io_rw_init_file(struct io_kiocb *req, fmode_t mode, int rw_type)
830
836
} else {
831
837
if (kiocb -> ki_flags & IOCB_HIPRI )
832
838
return - EINVAL ;
833
- kiocb -> ki_complete = io_complete_rw ;
834
839
}
835
840
836
841
if (req -> flags & REQ_F_HAS_METADATA ) {
0 commit comments