io_uring: clean all flags in io_clean_op() at once

Clean all flags in io_clean_op() in the end in one operation, will save
us a couple of operation and binary size.

Signed-off-by: Pavel Begunkov <asml.silence@gmail.com>
Link: https://lore.kernel.org/r/b8efe1f022a037f74e7fe497c69fb554d59bfeaf.1623949695.git.asml.silence@gmail.com
Signed-off-by: Jens Axboe <axboe@kernel.dk>
This commit is contained in:
Pavel Begunkov 2021-06-17 18:14:04 +01:00 committed by Jens Axboe
parent 1dacb4df4e
commit c854357bc1

View File

@ -109,6 +109,8 @@
#define SQE_VALID_FLAGS (IOSQE_FIXED_FILE|IOSQE_IO_DRAIN|IOSQE_IO_LINK| \ #define SQE_VALID_FLAGS (IOSQE_FIXED_FILE|IOSQE_IO_DRAIN|IOSQE_IO_LINK| \
IOSQE_IO_HARDLINK | IOSQE_ASYNC | \ IOSQE_IO_HARDLINK | IOSQE_ASYNC | \
IOSQE_BUFFER_SELECT) IOSQE_BUFFER_SELECT)
#define IO_REQ_CLEAN_FLAGS (REQ_F_BUFFER_SELECTED | REQ_F_NEED_CLEANUP | \
REQ_F_POLLED | REQ_F_INFLIGHT | REQ_F_CREDS)
#define IO_TCTX_REFS_CACHE_NR (1U << 10) #define IO_TCTX_REFS_CACHE_NR (1U << 10)
@ -1627,8 +1629,7 @@ static void io_req_complete_post(struct io_kiocb *req, long res,
static inline bool io_req_needs_clean(struct io_kiocb *req) static inline bool io_req_needs_clean(struct io_kiocb *req)
{ {
return req->flags & (REQ_F_BUFFER_SELECTED | REQ_F_NEED_CLEANUP | return req->flags & IO_REQ_CLEAN_FLAGS;
REQ_F_POLLED | REQ_F_INFLIGHT | REQ_F_CREDS);
} }
static void io_req_complete_state(struct io_kiocb *req, long res, static void io_req_complete_state(struct io_kiocb *req, long res,
@ -6080,7 +6081,6 @@ static void io_clean_op(struct io_kiocb *req)
kfree(req->sr_msg.kbuf); kfree(req->sr_msg.kbuf);
break; break;
} }
req->flags &= ~REQ_F_BUFFER_SELECTED;
} }
if (req->flags & REQ_F_NEED_CLEANUP) { if (req->flags & REQ_F_NEED_CLEANUP) {
@ -6121,7 +6121,6 @@ static void io_clean_op(struct io_kiocb *req)
putname(req->unlink.filename); putname(req->unlink.filename);
break; break;
} }
req->flags &= ~REQ_F_NEED_CLEANUP;
} }
if ((req->flags & REQ_F_POLLED) && req->apoll) { if ((req->flags & REQ_F_POLLED) && req->apoll) {
kfree(req->apoll->double_poll); kfree(req->apoll->double_poll);
@ -6132,12 +6131,11 @@ static void io_clean_op(struct io_kiocb *req)
struct io_uring_task *tctx = req->task->io_uring; struct io_uring_task *tctx = req->task->io_uring;
atomic_dec(&tctx->inflight_tracked); atomic_dec(&tctx->inflight_tracked);
req->flags &= ~REQ_F_INFLIGHT;
} }
if (req->flags & REQ_F_CREDS) { if (req->flags & REQ_F_CREDS)
put_cred(req->creds); put_cred(req->creds);
req->flags &= ~REQ_F_CREDS;
} req->flags &= ~IO_REQ_CLEAN_FLAGS;
} }
static int io_issue_sqe(struct io_kiocb *req, unsigned int issue_flags) static int io_issue_sqe(struct io_kiocb *req, unsigned int issue_flags)