diff options
author | Bijan Mottahedeh <bijan.mottahedeh@oracle.com> | 2021-01-15 17:37:50 +0000 |
---|---|---|
committer | Jens Axboe <axboe@kernel.dk> | 2021-02-01 10:02:42 -0700 |
commit | d7954b2ba94639b7f5b08760d36e54c28544730f (patch) | |
tree | 17a5a65f2757caa226d9bc3df72795cbe807a64f /fs/io_uring.c | |
parent | bc9744cd162b2f6c38d75dc49c310677dc13afa8 (diff) | |
download | lwn-d7954b2ba94639b7f5b08760d36e54c28544730f.tar.gz lwn-d7954b2ba94639b7f5b08760d36e54c28544730f.zip |
io_uring: create common fixed_rsrc_ref_node handling routines
Create common routines to be used for both files/buffers registration.
[remove io_sqe_rsrc_set_node substitution]
Reviewed-by: Pavel Begunkov <asml.silence@gmail.com>
Signed-off-by: Bijan Mottahedeh <bijan.mottahedeh@oracle.com>
[merge, quiesce only for files]
Signed-off-by: Pavel Begunkov <asml.silence@gmail.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Diffstat (limited to 'fs/io_uring.c')
-rw-r--r-- | fs/io_uring.c | 38 |
1 files changed, 26 insertions, 12 deletions
diff --git a/fs/io_uring.c b/fs/io_uring.c index bb51f2abd009..727d0d3cdbcc 100644 --- a/fs/io_uring.c +++ b/fs/io_uring.c @@ -7373,20 +7373,13 @@ static void io_sqe_rsrc_set_node(struct io_ring_ctx *ctx, percpu_ref_get(&rsrc_data->refs); } -static int io_sqe_files_unregister(struct io_ring_ctx *ctx) +static int io_rsrc_ref_quiesce(struct fixed_rsrc_data *data, + struct io_ring_ctx *ctx, + struct fixed_rsrc_ref_node *backup_node) { - struct fixed_rsrc_data *data = ctx->file_data; - struct fixed_rsrc_ref_node *backup_node, *ref_node = NULL; - unsigned nr_tables, i; + struct fixed_rsrc_ref_node *ref_node; int ret; - if (!data) - return -ENXIO; - backup_node = alloc_fixed_rsrc_ref_node(ctx); - if (!backup_node) - return -ENOMEM; - init_fixed_file_ref_node(ctx, backup_node); - io_rsrc_ref_lock(ctx); ref_node = data->node; io_rsrc_ref_unlock(ctx); @@ -7410,6 +7403,28 @@ static int io_sqe_files_unregister(struct io_ring_ctx *ctx) } } while (1); + destroy_fixed_rsrc_ref_node(backup_node); + return 0; +} + +static int io_sqe_files_unregister(struct io_ring_ctx *ctx) +{ + struct fixed_rsrc_data *data = ctx->file_data; + struct fixed_rsrc_ref_node *backup_node; + unsigned nr_tables, i; + int ret; + + if (!data) + return -ENXIO; + backup_node = alloc_fixed_rsrc_ref_node(ctx); + if (!backup_node) + return -ENOMEM; + init_fixed_file_ref_node(ctx, backup_node); + + ret = io_rsrc_ref_quiesce(data, ctx, backup_node); + if (ret) + return ret; + __io_sqe_files_unregister(ctx); nr_tables = DIV_ROUND_UP(ctx->nr_user_files, IORING_MAX_FILES_TABLE); for (i = 0; i < nr_tables; i++) @@ -7419,7 +7434,6 @@ static int io_sqe_files_unregister(struct io_ring_ctx *ctx) kfree(data); ctx->file_data = NULL; ctx->nr_user_files = 0; - destroy_fixed_rsrc_ref_node(backup_node); return 0; } |