Skip to content

Commit 33337d0

Browse files
Dylan Yudakenaxboe
authored andcommitted
io_uring: add io_uring_get_opcode
In some debug scenarios it is useful to have the text representation of the opcode. Add this function in preparation. Signed-off-by: Dylan Yudaken <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jens Axboe <[email protected]>
1 parent cc51eaa commit 33337d0

File tree

2 files changed

+106
-0
lines changed

2 files changed

+106
-0
lines changed

fs/io_uring.c

Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1285,6 +1285,107 @@ static struct kmem_cache *req_cachep;
12851285

12861286
static const struct file_operations io_uring_fops;
12871287

1288+
const char *io_uring_get_opcode(u8 opcode)
1289+
{
1290+
switch ((enum io_uring_op)opcode) {
1291+
case IORING_OP_NOP:
1292+
return "NOP";
1293+
case IORING_OP_READV:
1294+
return "READV";
1295+
case IORING_OP_WRITEV:
1296+
return "WRITEV";
1297+
case IORING_OP_FSYNC:
1298+
return "FSYNC";
1299+
case IORING_OP_READ_FIXED:
1300+
return "READ_FIXED";
1301+
case IORING_OP_WRITE_FIXED:
1302+
return "WRITE_FIXED";
1303+
case IORING_OP_POLL_ADD:
1304+
return "POLL_ADD";
1305+
case IORING_OP_POLL_REMOVE:
1306+
return "POLL_REMOVE";
1307+
case IORING_OP_SYNC_FILE_RANGE:
1308+
return "SYNC_FILE_RANGE";
1309+
case IORING_OP_SENDMSG:
1310+
return "SENDMSG";
1311+
case IORING_OP_RECVMSG:
1312+
return "RECVMSG";
1313+
case IORING_OP_TIMEOUT:
1314+
return "TIMEOUT";
1315+
case IORING_OP_TIMEOUT_REMOVE:
1316+
return "TIMEOUT_REMOVE";
1317+
case IORING_OP_ACCEPT:
1318+
return "ACCEPT";
1319+
case IORING_OP_ASYNC_CANCEL:
1320+
return "ASYNC_CANCEL";
1321+
case IORING_OP_LINK_TIMEOUT:
1322+
return "LINK_TIMEOUT";
1323+
case IORING_OP_CONNECT:
1324+
return "CONNECT";
1325+
case IORING_OP_FALLOCATE:
1326+
return "FALLOCATE";
1327+
case IORING_OP_OPENAT:
1328+
return "OPENAT";
1329+
case IORING_OP_CLOSE:
1330+
return "CLOSE";
1331+
case IORING_OP_FILES_UPDATE:
1332+
return "FILES_UPDATE";
1333+
case IORING_OP_STATX:
1334+
return "STATX";
1335+
case IORING_OP_READ:
1336+
return "READ";
1337+
case IORING_OP_WRITE:
1338+
return "WRITE";
1339+
case IORING_OP_FADVISE:
1340+
return "FADVISE";
1341+
case IORING_OP_MADVISE:
1342+
return "MADVISE";
1343+
case IORING_OP_SEND:
1344+
return "SEND";
1345+
case IORING_OP_RECV:
1346+
return "RECV";
1347+
case IORING_OP_OPENAT2:
1348+
return "OPENAT2";
1349+
case IORING_OP_EPOLL_CTL:
1350+
return "EPOLL_CTL";
1351+
case IORING_OP_SPLICE:
1352+
return "SPLICE";
1353+
case IORING_OP_PROVIDE_BUFFERS:
1354+
return "PROVIDE_BUFFERS";
1355+
case IORING_OP_REMOVE_BUFFERS:
1356+
return "REMOVE_BUFFERS";
1357+
case IORING_OP_TEE:
1358+
return "TEE";
1359+
case IORING_OP_SHUTDOWN:
1360+
return "SHUTDOWN";
1361+
case IORING_OP_RENAMEAT:
1362+
return "RENAMEAT";
1363+
case IORING_OP_UNLINKAT:
1364+
return "UNLINKAT";
1365+
case IORING_OP_MKDIRAT:
1366+
return "MKDIRAT";
1367+
case IORING_OP_SYMLINKAT:
1368+
return "SYMLINKAT";
1369+
case IORING_OP_LINKAT:
1370+
return "LINKAT";
1371+
case IORING_OP_MSG_RING:
1372+
return "MSG_RING";
1373+
case IORING_OP_FSETXATTR:
1374+
return "FSETXATTR";
1375+
case IORING_OP_SETXATTR:
1376+
return "SETXATTR";
1377+
case IORING_OP_FGETXATTR:
1378+
return "FGETXATTR";
1379+
case IORING_OP_GETXATTR:
1380+
return "GETXATTR";
1381+
case IORING_OP_SOCKET:
1382+
return "SOCKET";
1383+
case IORING_OP_LAST:
1384+
return "INVALID";
1385+
}
1386+
return "INVALID";
1387+
}
1388+
12881389
struct sock *io_uring_get_socket(struct file *file)
12891390
{
12901391
#if defined(CONFIG_UNIX)

include/linux/io_uring.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ struct sock *io_uring_get_socket(struct file *file);
1010
void __io_uring_cancel(bool cancel_all);
1111
void __io_uring_free(struct task_struct *tsk);
1212
void io_uring_unreg_ringfd(void);
13+
const char *io_uring_get_opcode(u8 opcode);
1314

1415
static inline void io_uring_files_cancel(void)
1516
{
@@ -42,6 +43,10 @@ static inline void io_uring_files_cancel(void)
4243
static inline void io_uring_free(struct task_struct *tsk)
4344
{
4445
}
46+
static inline const char *io_uring_get_opcode(u8 opcode)
47+
{
48+
return "";
49+
}
4550
#endif
4651

4752
#endif

0 commit comments

Comments
 (0)