Lines Matching refs:tctx

13 #include "tctx.h"
49 struct io_uring_task *tctx = tsk->io_uring;
51 WARN_ON_ONCE(!xa_empty(&tctx->xa));
52 WARN_ON_ONCE(tctx->io_wq);
53 WARN_ON_ONCE(tctx->cached_refs);
55 percpu_counter_destroy(&tctx->inflight);
56 kfree(tctx);
63 struct io_uring_task *tctx;
66 tctx = kzalloc(sizeof(*tctx), GFP_KERNEL);
67 if (unlikely(!tctx))
70 ret = percpu_counter_init(&tctx->inflight, 0, GFP_KERNEL);
72 kfree(tctx);
76 tctx->io_wq = io_init_wq_offload(ctx, task);
77 if (IS_ERR(tctx->io_wq)) {
78 ret = PTR_ERR(tctx->io_wq);
79 percpu_counter_destroy(&tctx->inflight);
80 kfree(tctx);
84 xa_init(&tctx->xa);
85 init_waitqueue_head(&tctx->wait);
86 atomic_set(&tctx->in_cancel, 0);
87 atomic_set(&tctx->inflight_tracked, 0);
88 task->io_uring = tctx;
89 init_llist_head(&tctx->task_list);
90 init_task_work(&tctx->task_work, tctx_task_work);
96 struct io_uring_task *tctx = current->io_uring;
100 if (unlikely(!tctx)) {
105 tctx = current->io_uring;
110 ret = io_wq_max_workers(tctx->io_wq, limits);
115 if (!xa_load(&tctx->xa, (unsigned long)ctx)) {
122 ret = xa_err(xa_store(&tctx->xa, (unsigned long)ctx,
157 struct io_uring_task *tctx = current->io_uring;
160 if (!tctx)
162 node = xa_erase(&tctx->xa, index);
173 if (tctx->last == node->ctx)
174 tctx->last = NULL;
178 __cold void io_uring_clean_tctx(struct io_uring_task *tctx)
180 struct io_wq *wq = tctx->io_wq;
184 xa_for_each(&tctx->xa, index, node) {
194 tctx->io_wq = NULL;
200 struct io_uring_task *tctx = current->io_uring;
204 if (tctx->registered_rings[i]) {
205 fput(tctx->registered_rings[i]);
206 tctx->registered_rings[i] = NULL;
211 int io_ring_add_registered_file(struct io_uring_task *tctx, struct file *file,
217 if (tctx->registered_rings[offset])
220 tctx->registered_rings[offset] = file;
226 static int io_ring_add_registered_fd(struct io_uring_task *tctx, int fd,
239 offset = io_ring_add_registered_file(tctx, file, start, end);
258 struct io_uring_task *tctx;
270 tctx = current->io_uring;
296 ret = io_ring_add_registered_fd(tctx, reg.data, start, end);
302 fput(tctx->registered_rings[reg.offset]);
303 tctx->registered_rings[reg.offset] = NULL;
316 struct io_uring_task *tctx = current->io_uring;
322 if (!tctx)
336 if (tctx->registered_rings[reg.offset]) {
337 fput(tctx->registered_rings[reg.offset]);
338 tctx->registered_rings[reg.offset] = NULL;