Skip to content

Commit 38eddb2

Browse files
isilenceaxboe
authored andcommitted
io_uring: remove FFS_SCM
THe lifetime of SCM'ed files is bound to ring_sock, which is destroyed strictly after we're done with registered file tables. This means there is no need for the FFS_SCM hack, which was not available on 32-bit builds anyway. Signed-off-by: Pavel Begunkov <[email protected]> Link: https://lore.kernel.org/r/984226a1045adf42dc35d8bd7fb5a8bbfa472ce1.1665891182.git.asml.silence@gmail.com Signed-off-by: Jens Axboe <[email protected]>
1 parent 9abf231 commit 38eddb2

File tree

4 files changed

+3
-25
lines changed

4 files changed

+3
-25
lines changed

io_uring/filetable.h

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -5,22 +5,9 @@
55
#include <linux/file.h>
66
#include <linux/io_uring_types.h>
77

8-
/*
9-
* FFS_SCM is only available on 64-bit archs, for 32-bit we just define it as 0
10-
* and define IO_URING_SCM_ALL. For this case, we use SCM for all files as we
11-
* can't safely always dereference the file when the task has exited and ring
12-
* cleanup is done. If a file is tracked and part of SCM, then unix gc on
13-
* process exit may reap it before __io_sqe_files_unregister() is run.
14-
*/
158
#define FFS_NOWAIT 0x1UL
169
#define FFS_ISREG 0x2UL
17-
#if defined(CONFIG_64BIT)
18-
#define FFS_SCM 0x4UL
19-
#else
20-
#define IO_URING_SCM_ALL
21-
#define FFS_SCM 0x0UL
22-
#endif
23-
#define FFS_MASK ~(FFS_NOWAIT|FFS_ISREG|FFS_SCM)
10+
#define FFS_MASK ~(FFS_NOWAIT|FFS_ISREG)
2411

2512
bool io_alloc_file_tables(struct io_file_table *table, unsigned nr_files);
2613
void io_free_file_tables(struct io_file_table *table);

io_uring/io_uring.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1587,8 +1587,6 @@ unsigned int io_file_get_flags(struct file *file)
15871587
res |= FFS_ISREG;
15881588
if (__io_file_supports_nowait(file, mode))
15891589
res |= FFS_NOWAIT;
1590-
if (io_file_need_scm(file))
1591-
res |= FFS_SCM;
15921590
return res;
15931591
}
15941592

io_uring/rsrc.c

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -757,20 +757,17 @@ int io_queue_rsrc_removal(struct io_rsrc_data *data, unsigned idx,
757757

758758
void __io_sqe_files_unregister(struct io_ring_ctx *ctx)
759759
{
760-
#if !defined(IO_URING_SCM_ALL)
761760
int i;
762761

763762
for (i = 0; i < ctx->nr_user_files; i++) {
764763
struct file *file = io_file_from_index(&ctx->file_table, i);
765764

766-
if (!file)
767-
continue;
768-
if (io_fixed_file_slot(&ctx->file_table, i)->file_ptr & FFS_SCM)
765+
/* skip scm accounted files, they'll be freed by ->ring_sock */
766+
if (!file || io_file_need_scm(file))
769767
continue;
770768
io_file_bitmap_clear(&ctx->file_table, i);
771769
fput(file);
772770
}
773-
#endif
774771

775772
#if defined(CONFIG_UNIX)
776773
if (ctx->ring_sock) {

io_uring/rsrc.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -82,11 +82,7 @@ int __io_scm_file_account(struct io_ring_ctx *ctx, struct file *file);
8282
#if defined(CONFIG_UNIX)
8383
static inline bool io_file_need_scm(struct file *filp)
8484
{
85-
#if defined(IO_URING_SCM_ALL)
86-
return true;
87-
#else
8885
return !!unix_get_socket(filp);
89-
#endif
9086
}
9187
#else
9288
static inline bool io_file_need_scm(struct file *filp)

0 commit comments

Comments
 (0)