io_uring: add helpers to decode the fixed file file_ptr
[linux-block.git] / io_uring / filetable.c
index 0f6fa791a47de6834de0b264812f367485dcd080..e7d749991de4267e8d1771b20a1e8d9cbe5c31c6 100644 (file)
@@ -78,10 +78,8 @@ static int io_install_fixed_file(struct io_ring_ctx *ctx, struct file *file,
        file_slot = io_fixed_file_slot(&ctx->file_table, slot_index);
 
        if (file_slot->file_ptr) {
-               struct file *old_file;
-
-               old_file = (struct file *)(file_slot->file_ptr & FFS_MASK);
-               ret = io_queue_rsrc_removal(ctx->file_data, slot_index, old_file);
+               ret = io_queue_rsrc_removal(ctx->file_data, slot_index,
+                                           io_slot_file(file_slot));
                if (ret)
                        return ret;
 
@@ -140,7 +138,6 @@ int io_fixed_fd_install(struct io_kiocb *req, unsigned int issue_flags,
 int io_fixed_fd_remove(struct io_ring_ctx *ctx, unsigned int offset)
 {
        struct io_fixed_file *file_slot;
-       struct file *file;
        int ret;
 
        if (unlikely(!ctx->file_data))
@@ -153,8 +150,8 @@ int io_fixed_fd_remove(struct io_ring_ctx *ctx, unsigned int offset)
        if (!file_slot->file_ptr)
                return -EBADF;
 
-       file = (struct file *)(file_slot->file_ptr & FFS_MASK);
-       ret = io_queue_rsrc_removal(ctx->file_data, offset, file);
+       ret = io_queue_rsrc_removal(ctx->file_data, offset,
+                                   io_slot_file(file_slot));
        if (ret)
                return ret;