Skip to content

Commit d530a40

Browse files
committed
io_uring: add prepped flag
We currently use the fact that if ->ki_filp is already set, then we've done the prep. In preparation for moving the file assignment earlier, use a separate flag to tell whether the request has been prepped for IO or not. Signed-off-by: Jens Axboe <axboe@kernel.dk>
1 parent e0c5c57 commit d530a40

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

fs/io_uring.c

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,7 @@ struct io_kiocb {
214214
#define REQ_F_IOPOLL_COMPLETED 2 /* polled IO has completed */
215215
#define REQ_F_FIXED_FILE 4 /* ctx owns file */
216216
#define REQ_F_SEQ_PREV 8 /* sequential with previous */
217+
#define REQ_F_PREPPED 16 /* prep already done */
217218
u64 user_data;
218219
u64 error;
219220

@@ -741,7 +742,7 @@ static int io_prep_rw(struct io_kiocb *req, const struct sqe_submit *s,
741742
int fd, ret;
742743

743744
/* For -EAGAIN retry, everything is already prepped */
744-
if (kiocb->ki_filp)
745+
if (req->flags & REQ_F_PREPPED)
745746
return 0;
746747

747748
flags = READ_ONCE(sqe->flags);
@@ -799,6 +800,7 @@ static int io_prep_rw(struct io_kiocb *req, const struct sqe_submit *s,
799800
}
800801
kiocb->ki_complete = io_complete_rw;
801802
}
803+
req->flags |= REQ_F_PREPPED;
802804
return 0;
803805
out_fput:
804806
if (!(flags & IOSQE_FIXED_FILE)) {
@@ -1099,8 +1101,8 @@ static int io_prep_fsync(struct io_kiocb *req, const struct io_uring_sqe *sqe)
10991101
unsigned flags;
11001102
int fd;
11011103

1102-
/* Prep already done */
1103-
if (req->rw.ki_filp)
1104+
/* Prep already done (EAGAIN retry) */
1105+
if (req->flags & REQ_F_PREPPED)
11041106
return 0;
11051107

11061108
if (unlikely(ctx->flags & IORING_SETUP_IOPOLL))
@@ -1122,6 +1124,7 @@ static int io_prep_fsync(struct io_kiocb *req, const struct io_uring_sqe *sqe)
11221124
return -EBADF;
11231125
}
11241126

1127+
req->flags |= REQ_F_PREPPED;
11251128
return 0;
11261129
}
11271130

@@ -1632,8 +1635,6 @@ static int io_submit_sqe(struct io_ring_ctx *ctx, struct sqe_submit *s,
16321635
if (unlikely(!req))
16331636
return -EAGAIN;
16341637

1635-
req->rw.ki_filp = NULL;
1636-
16371638
ret = __io_submit_sqe(ctx, req, s, true, state);
16381639
if (ret == -EAGAIN) {
16391640
struct io_uring_sqe *sqe_copy;

0 commit comments

Comments
 (0)