Skip to content

Commit f2a48dd

Browse files
isilenceaxboe
authored andcommitted
io_uring: refactor io_sq_offload_create()
Just a bit of code tossing in io_sq_offload_create(), so it looks a bit better. No functional changes. Signed-off-by: Pavel Begunkov <[email protected]> Link: https://lore.kernel.org/r/939776f90de8d2cdd0414e1baa29c8ec0926b561.1618916549.git.asml.silence@gmail.com Signed-off-by: Jens Axboe <[email protected]>
1 parent 07db298 commit f2a48dd

File tree

1 file changed

+6
-14
lines changed

1 file changed

+6
-14
lines changed

fs/io_uring.c

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -7879,11 +7879,9 @@ static int io_sq_offload_create(struct io_ring_ctx *ctx,
78797879
f = fdget(p->wq_fd);
78807880
if (!f.file)
78817881
return -ENXIO;
7882-
if (f.file->f_op != &io_uring_fops) {
7883-
fdput(f);
7884-
return -EINVAL;
7885-
}
78867882
fdput(f);
7883+
if (f.file->f_op != &io_uring_fops)
7884+
return -EINVAL;
78877885
}
78887886
if (ctx->flags & IORING_SETUP_SQPOLL) {
78897887
struct task_struct *tsk;
@@ -7902,13 +7900,11 @@ static int io_sq_offload_create(struct io_ring_ctx *ctx,
79027900
if (!ctx->sq_thread_idle)
79037901
ctx->sq_thread_idle = HZ;
79047902

7905-
ret = 0;
79067903
io_sq_thread_park(sqd);
79077904
list_add(&ctx->sqd_list, &sqd->ctx_list);
79087905
io_sqd_update_thread_idle(sqd);
79097906
/* don't attach to a dying SQPOLL thread, would be racy */
7910-
if (attached && !sqd->thread)
7911-
ret = -ENXIO;
7907+
ret = (attached && !sqd->thread) ? -ENXIO : 0;
79127908
io_sq_thread_unpark(sqd);
79137909

79147910
if (ret < 0)
@@ -7920,11 +7916,8 @@ static int io_sq_offload_create(struct io_ring_ctx *ctx,
79207916
int cpu = p->sq_thread_cpu;
79217917

79227918
ret = -EINVAL;
7923-
if (cpu >= nr_cpu_ids)
7924-
goto err_sqpoll;
7925-
if (!cpu_online(cpu))
7919+
if (cpu >= nr_cpu_ids || !cpu_online(cpu))
79267920
goto err_sqpoll;
7927-
79287921
sqd->sq_cpu = cpu;
79297922
} else {
79307923
sqd->sq_cpu = -1;
@@ -7950,12 +7943,11 @@ static int io_sq_offload_create(struct io_ring_ctx *ctx,
79507943
}
79517944

79527945
return 0;
7946+
err_sqpoll:
7947+
complete(&ctx->sq_data->exited);
79537948
err:
79547949
io_sq_thread_finish(ctx);
79557950
return ret;
7956-
err_sqpoll:
7957-
complete(&ctx->sq_data->exited);
7958-
goto err;
79597951
}
79607952

79617953
static inline void __io_unaccount_mem(struct user_struct *user,

0 commit comments

Comments
 (0)