Skip to content

Commit fdecb66

Browse files
isilenceaxboe
authored andcommitted
io_uring: enumerate dynamic resources
As resources are getting more support and common parts, it'll be more convenient to index resources and use it for indexing. Signed-off-by: Pavel Begunkov <[email protected]> Link: https://lore.kernel.org/r/f0be63e9310212d5601d36277c2946ff7a040485.1619356238.git.asml.silence@gmail.com Signed-off-by: Jens Axboe <[email protected]>
1 parent 98f0b3b commit fdecb66

File tree

2 files changed

+12
-8
lines changed

2 files changed

+12
-8
lines changed

fs/io_uring.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1035,7 +1035,7 @@ static void io_dismantle_req(struct io_kiocb *req);
10351035
static void io_put_task(struct task_struct *task, int nr);
10361036
static struct io_kiocb *io_prep_linked_timeout(struct io_kiocb *req);
10371037
static void io_queue_linked_timeout(struct io_kiocb *req);
1038-
static int __io_register_rsrc_update(struct io_ring_ctx *ctx, unsigned opcode,
1038+
static int __io_register_rsrc_update(struct io_ring_ctx *ctx, unsigned type,
10391039
struct io_uring_rsrc_update *up,
10401040
unsigned nr_args);
10411041
static void io_clean_op(struct io_kiocb *req);
@@ -5824,7 +5824,7 @@ static int io_files_update(struct io_kiocb *req, unsigned int issue_flags)
58245824
up.data = req->rsrc_update.arg;
58255825

58265826
mutex_lock(&ctx->uring_lock);
5827-
ret = __io_register_rsrc_update(ctx, IORING_REGISTER_FILES_UPDATE,
5827+
ret = __io_register_rsrc_update(ctx, IORING_RSRC_FILE,
58285828
&up, req->rsrc_update.nr_args);
58295829
mutex_unlock(&ctx->uring_lock);
58305830

@@ -9709,7 +9709,7 @@ static int io_register_enable_rings(struct io_ring_ctx *ctx)
97099709
return 0;
97109710
}
97119711

9712-
static int __io_register_rsrc_update(struct io_ring_ctx *ctx, unsigned opcode,
9712+
static int __io_register_rsrc_update(struct io_ring_ctx *ctx, unsigned type,
97139713
struct io_uring_rsrc_update *up,
97149714
unsigned nr_args)
97159715
{
@@ -9722,14 +9722,14 @@ static int __io_register_rsrc_update(struct io_ring_ctx *ctx, unsigned opcode,
97229722
if (err)
97239723
return err;
97249724

9725-
switch (opcode) {
9726-
case IORING_REGISTER_FILES_UPDATE:
9725+
switch (type) {
9726+
case IORING_RSRC_FILE:
97279727
return __io_sqe_files_update(ctx, up, nr_args);
97289728
}
97299729
return -EINVAL;
97309730
}
97319731

9732-
static int io_register_rsrc_update(struct io_ring_ctx *ctx, unsigned opcode,
9732+
static int io_register_rsrc_update(struct io_ring_ctx *ctx, unsigned type,
97339733
void __user *arg, unsigned nr_args)
97349734
{
97359735
struct io_uring_rsrc_update up;
@@ -9740,7 +9740,7 @@ static int io_register_rsrc_update(struct io_ring_ctx *ctx, unsigned opcode,
97409740
return -EFAULT;
97419741
if (up.resv)
97429742
return -EINVAL;
9743-
return __io_register_rsrc_update(ctx, opcode, &up, nr_args);
9743+
return __io_register_rsrc_update(ctx, type, &up, nr_args);
97449744
}
97459745

97469746
static bool io_register_op_must_quiesce(int op)
@@ -9829,7 +9829,7 @@ static int __io_uring_register(struct io_ring_ctx *ctx, unsigned opcode,
98299829
ret = io_sqe_files_unregister(ctx);
98309830
break;
98319831
case IORING_REGISTER_FILES_UPDATE:
9832-
ret = io_register_rsrc_update(ctx, opcode, arg, nr_args);
9832+
ret = io_register_rsrc_update(ctx, IORING_RSRC_FILE, arg, nr_args);
98339833
break;
98349834
case IORING_REGISTER_EVENTFD:
98359835
case IORING_REGISTER_EVENTFD_ASYNC:

include/uapi/linux/io_uring.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -316,6 +316,10 @@ struct io_uring_rsrc_update {
316316
__aligned_u64 data;
317317
};
318318

319+
enum {
320+
IORING_RSRC_FILE = 0,
321+
};
322+
319323
/* Skip updating fd indexes set to this value in the fd table */
320324
#define IORING_REGISTER_FILES_SKIP (-2)
321325

0 commit comments

Comments
 (0)