Commit 38eddb2c authored by Pavel Begunkov's avatar Pavel Begunkov Committed by Jens Axboe

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: default avatarPavel Begunkov <asml.silence@gmail.com>
Link: https://lore.kernel.org/r/984226a1045adf42dc35d8bd7fb5a8bbfa472ce1.1665891182.git.asml.silence@gmail.comSigned-off-by: default avatarJens Axboe <axboe@kernel.dk>
parent 9abf2313
...@@ -5,22 +5,9 @@ ...@@ -5,22 +5,9 @@
#include <linux/file.h> #include <linux/file.h>
#include <linux/io_uring_types.h> #include <linux/io_uring_types.h>
/*
* FFS_SCM is only available on 64-bit archs, for 32-bit we just define it as 0
* and define IO_URING_SCM_ALL. For this case, we use SCM for all files as we
* can't safely always dereference the file when the task has exited and ring
* cleanup is done. If a file is tracked and part of SCM, then unix gc on
* process exit may reap it before __io_sqe_files_unregister() is run.
*/
#define FFS_NOWAIT 0x1UL #define FFS_NOWAIT 0x1UL
#define FFS_ISREG 0x2UL #define FFS_ISREG 0x2UL
#if defined(CONFIG_64BIT) #define FFS_MASK ~(FFS_NOWAIT|FFS_ISREG)
#define FFS_SCM 0x4UL
#else
#define IO_URING_SCM_ALL
#define FFS_SCM 0x0UL
#endif
#define FFS_MASK ~(FFS_NOWAIT|FFS_ISREG|FFS_SCM)
bool io_alloc_file_tables(struct io_file_table *table, unsigned nr_files); bool io_alloc_file_tables(struct io_file_table *table, unsigned nr_files);
void io_free_file_tables(struct io_file_table *table); void io_free_file_tables(struct io_file_table *table);
......
...@@ -1587,8 +1587,6 @@ unsigned int io_file_get_flags(struct file *file) ...@@ -1587,8 +1587,6 @@ unsigned int io_file_get_flags(struct file *file)
res |= FFS_ISREG; res |= FFS_ISREG;
if (__io_file_supports_nowait(file, mode)) if (__io_file_supports_nowait(file, mode))
res |= FFS_NOWAIT; res |= FFS_NOWAIT;
if (io_file_need_scm(file))
res |= FFS_SCM;
return res; return res;
} }
......
...@@ -757,20 +757,17 @@ int io_queue_rsrc_removal(struct io_rsrc_data *data, unsigned idx, ...@@ -757,20 +757,17 @@ int io_queue_rsrc_removal(struct io_rsrc_data *data, unsigned idx,
void __io_sqe_files_unregister(struct io_ring_ctx *ctx) void __io_sqe_files_unregister(struct io_ring_ctx *ctx)
{ {
#if !defined(IO_URING_SCM_ALL)
int i; int i;
for (i = 0; i < ctx->nr_user_files; i++) { for (i = 0; i < ctx->nr_user_files; i++) {
struct file *file = io_file_from_index(&ctx->file_table, i); struct file *file = io_file_from_index(&ctx->file_table, i);
if (!file) /* skip scm accounted files, they'll be freed by ->ring_sock */
continue; if (!file || io_file_need_scm(file))
if (io_fixed_file_slot(&ctx->file_table, i)->file_ptr & FFS_SCM)
continue; continue;
io_file_bitmap_clear(&ctx->file_table, i); io_file_bitmap_clear(&ctx->file_table, i);
fput(file); fput(file);
} }
#endif
#if defined(CONFIG_UNIX) #if defined(CONFIG_UNIX)
if (ctx->ring_sock) { if (ctx->ring_sock) {
......
...@@ -82,11 +82,7 @@ int __io_scm_file_account(struct io_ring_ctx *ctx, struct file *file); ...@@ -82,11 +82,7 @@ int __io_scm_file_account(struct io_ring_ctx *ctx, struct file *file);
#if defined(CONFIG_UNIX) #if defined(CONFIG_UNIX)
static inline bool io_file_need_scm(struct file *filp) static inline bool io_file_need_scm(struct file *filp)
{ {
#if defined(IO_URING_SCM_ALL)
return true;
#else
return !!unix_get_socket(filp); return !!unix_get_socket(filp);
#endif
} }
#else #else
static inline bool io_file_need_scm(struct file *filp) static inline bool io_file_need_scm(struct file *filp)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment