Skip to content

Commit b2568ee

Browse files
committed
Merge tag 'io_uring-5.13-2021-06-12' of git://git.kernel.dk/linux-block
Pull io_uring fixes from Jens Axboe: "Just an API change for the registration changes that went into this release. Better to get it sorted out now than before it's too late" * tag 'io_uring-5.13-2021-06-12' of git://git.kernel.dk/linux-block: io_uring: add feature flag for rsrc tags io_uring: change registration/upd/rsrc tagging ABI
2 parents 99f9259 + 9690557 commit b2568ee

File tree

2 files changed

+39
-22
lines changed

2 files changed

+39
-22
lines changed

fs/io_uring.c

Lines changed: 29 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -783,6 +783,11 @@ struct io_task_work {
783783
task_work_func_t func;
784784
};
785785

786+
enum {
787+
IORING_RSRC_FILE = 0,
788+
IORING_RSRC_BUFFER = 1,
789+
};
790+
786791
/*
787792
* NOTE! Each of the iocb union members has the file pointer
788793
* as the first entry in their struct definition. So you can
@@ -9671,7 +9676,8 @@ static int io_uring_create(unsigned entries, struct io_uring_params *p,
96719676
IORING_FEAT_SUBMIT_STABLE | IORING_FEAT_RW_CUR_POS |
96729677
IORING_FEAT_CUR_PERSONALITY | IORING_FEAT_FAST_POLL |
96739678
IORING_FEAT_POLL_32BITS | IORING_FEAT_SQPOLL_NONFIXED |
9674-
IORING_FEAT_EXT_ARG | IORING_FEAT_NATIVE_WORKERS;
9679+
IORING_FEAT_EXT_ARG | IORING_FEAT_NATIVE_WORKERS |
9680+
IORING_FEAT_RSRC_TAGS;
96759681

96769682
if (copy_to_user(params, p, sizeof(*p))) {
96779683
ret = -EFAULT;
@@ -9911,21 +9917,21 @@ static int io_register_files_update(struct io_ring_ctx *ctx, void __user *arg,
99119917
}
99129918

99139919
static int io_register_rsrc_update(struct io_ring_ctx *ctx, void __user *arg,
9914-
unsigned size)
9920+
unsigned size, unsigned type)
99159921
{
99169922
struct io_uring_rsrc_update2 up;
99179923

99189924
if (size != sizeof(up))
99199925
return -EINVAL;
99209926
if (copy_from_user(&up, arg, sizeof(up)))
99219927
return -EFAULT;
9922-
if (!up.nr)
9928+
if (!up.nr || up.resv)
99239929
return -EINVAL;
9924-
return __io_register_rsrc_update(ctx, up.type, &up, up.nr);
9930+
return __io_register_rsrc_update(ctx, type, &up, up.nr);
99259931
}
99269932

99279933
static int io_register_rsrc(struct io_ring_ctx *ctx, void __user *arg,
9928-
unsigned int size)
9934+
unsigned int size, unsigned int type)
99299935
{
99309936
struct io_uring_rsrc_register rr;
99319937

@@ -9936,10 +9942,10 @@ static int io_register_rsrc(struct io_ring_ctx *ctx, void __user *arg,
99369942
memset(&rr, 0, sizeof(rr));
99379943
if (copy_from_user(&rr, arg, size))
99389944
return -EFAULT;
9939-
if (!rr.nr)
9945+
if (!rr.nr || rr.resv || rr.resv2)
99409946
return -EINVAL;
99419947

9942-
switch (rr.type) {
9948+
switch (type) {
99439949
case IORING_RSRC_FILE:
99449950
return io_sqe_files_register(ctx, u64_to_user_ptr(rr.data),
99459951
rr.nr, u64_to_user_ptr(rr.tags));
@@ -9961,8 +9967,10 @@ static bool io_register_op_must_quiesce(int op)
99619967
case IORING_REGISTER_PROBE:
99629968
case IORING_REGISTER_PERSONALITY:
99639969
case IORING_UNREGISTER_PERSONALITY:
9964-
case IORING_REGISTER_RSRC:
9965-
case IORING_REGISTER_RSRC_UPDATE:
9970+
case IORING_REGISTER_FILES2:
9971+
case IORING_REGISTER_FILES_UPDATE2:
9972+
case IORING_REGISTER_BUFFERS2:
9973+
case IORING_REGISTER_BUFFERS_UPDATE:
99669974
return false;
99679975
default:
99689976
return true;
@@ -10088,11 +10096,19 @@ static int __io_uring_register(struct io_ring_ctx *ctx, unsigned opcode,
1008810096
case IORING_REGISTER_RESTRICTIONS:
1008910097
ret = io_register_restrictions(ctx, arg, nr_args);
1009010098
break;
10091-
case IORING_REGISTER_RSRC:
10092-
ret = io_register_rsrc(ctx, arg, nr_args);
10099+
case IORING_REGISTER_FILES2:
10100+
ret = io_register_rsrc(ctx, arg, nr_args, IORING_RSRC_FILE);
10101+
break;
10102+
case IORING_REGISTER_FILES_UPDATE2:
10103+
ret = io_register_rsrc_update(ctx, arg, nr_args,
10104+
IORING_RSRC_FILE);
10105+
break;
10106+
case IORING_REGISTER_BUFFERS2:
10107+
ret = io_register_rsrc(ctx, arg, nr_args, IORING_RSRC_BUFFER);
1009310108
break;
10094-
case IORING_REGISTER_RSRC_UPDATE:
10095-
ret = io_register_rsrc_update(ctx, arg, nr_args);
10109+
case IORING_REGISTER_BUFFERS_UPDATE:
10110+
ret = io_register_rsrc_update(ctx, arg, nr_args,
10111+
IORING_RSRC_BUFFER);
1009610112
break;
1009710113
default:
1009810114
ret = -EINVAL;

include/uapi/linux/io_uring.h

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -280,6 +280,7 @@ struct io_uring_params {
280280
#define IORING_FEAT_SQPOLL_NONFIXED (1U << 7)
281281
#define IORING_FEAT_EXT_ARG (1U << 8)
282282
#define IORING_FEAT_NATIVE_WORKERS (1U << 9)
283+
#define IORING_FEAT_RSRC_TAGS (1U << 10)
283284

284285
/*
285286
* io_uring_register(2) opcodes and arguments
@@ -298,8 +299,12 @@ enum {
298299
IORING_UNREGISTER_PERSONALITY = 10,
299300
IORING_REGISTER_RESTRICTIONS = 11,
300301
IORING_REGISTER_ENABLE_RINGS = 12,
301-
IORING_REGISTER_RSRC = 13,
302-
IORING_REGISTER_RSRC_UPDATE = 14,
302+
303+
/* extended with tagging */
304+
IORING_REGISTER_FILES2 = 13,
305+
IORING_REGISTER_FILES_UPDATE2 = 14,
306+
IORING_REGISTER_BUFFERS2 = 15,
307+
IORING_REGISTER_BUFFERS_UPDATE = 16,
303308

304309
/* this goes last */
305310
IORING_REGISTER_LAST
@@ -312,14 +317,10 @@ struct io_uring_files_update {
312317
__aligned_u64 /* __s32 * */ fds;
313318
};
314319

315-
enum {
316-
IORING_RSRC_FILE = 0,
317-
IORING_RSRC_BUFFER = 1,
318-
};
319-
320320
struct io_uring_rsrc_register {
321-
__u32 type;
322321
__u32 nr;
322+
__u32 resv;
323+
__u64 resv2;
323324
__aligned_u64 data;
324325
__aligned_u64 tags;
325326
};
@@ -335,8 +336,8 @@ struct io_uring_rsrc_update2 {
335336
__u32 resv;
336337
__aligned_u64 data;
337338
__aligned_u64 tags;
338-
__u32 type;
339339
__u32 nr;
340+
__u32 resv2;
340341
};
341342

342343
/* Skip updating fd indexes set to this value in the fd table */

0 commit comments

Comments
 (0)