struct hlist_node hash_node;
struct async_poll *apoll;
struct io_wq_work work;
- struct io_identity identity;
};
struct io_defer_entry {
memset(&req->work, 0, sizeof(req->work));
req->flags |= REQ_F_WORK_INITIALIZED;
- io_init_identity(&req->identity);
- req->work.identity = &req->identity;
+ req->work.identity = ¤t->io_uring->identity;
}
static inline bool io_async_submit(struct io_ring_ctx *ctx)
}
}
-static void io_put_identity(struct io_kiocb *req)
+static void io_put_identity(struct io_uring_task *tctx, struct io_kiocb *req)
{
- if (req->work.identity == &req->identity)
+ if (req->work.identity == &tctx->identity)
return;
if (refcount_dec_and_test(&req->work.identity->count))
kfree(req->work.identity);
req->work.flags &= ~IO_WQ_WORK_FS;
}
- io_put_identity(req);
+ io_put_identity(req->task->io_uring, req);
}
/*
*/
static bool io_identity_cow(struct io_kiocb *req)
{
+ struct io_uring_task *tctx = current->io_uring;
const struct cred *creds = NULL;
struct io_identity *id;
refcount_inc(&id->count);
/* drop old identity, assign new one. one ref for req, one for tctx */
- if (req->work.identity != &req->identity &&
+ if (req->work.identity != &tctx->identity &&
refcount_sub_and_test(2, &req->work.identity->count))
kfree(req->work.identity);
static bool io_grab_identity(struct io_kiocb *req)
{
const struct io_op_def *def = &io_op_defs[req->opcode];
- struct io_identity *id = &req->identity;
+ struct io_identity *id = req->work.identity;
struct io_ring_ctx *ctx = req->ctx;
if (def->needs_fsize && id->fsize != rlimit(RLIMIT_FSIZE))
static void io_prep_async_work(struct io_kiocb *req)
{
const struct io_op_def *def = &io_op_defs[req->opcode];
- struct io_identity *id = &req->identity;
struct io_ring_ctx *ctx = req->ctx;
+ struct io_identity *id;
io_req_init_async(req);
+ id = req->work.identity;
if (req->flags & REQ_F_ISREG) {
if (def->hash_reg_file || (ctx->flags & IORING_SETUP_IOPOLL))
if (unlikely(!iod))
return -EINVAL;
refcount_inc(&iod->count);
- io_put_identity(req);
+ io_put_identity(current->io_uring, req);
get_cred(iod->creds);
req->work.identity = iod;
req->work.flags |= IO_WQ_WORK_CREDS;
tctx->in_idle = 0;
atomic_long_set(&tctx->req_issue, 0);
atomic_long_set(&tctx->req_complete, 0);
+ io_init_identity(&tctx->identity);
task->io_uring = tctx;
return 0;
}