Re: [PATCH 5.15] io_uring: auto-removal for direct open/accept

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 9/14/21 2:37 PM, Pavel Begunkov wrote:
> It might be inconvenient that direct open/accept deviates from the
> update semantics and fails if the slot is taken instead of removing a
> file sitting there. Implement the auto-removal.
> 
> Note that removal might need to allocate and so may fail. However, if an
> empty slot is specified, it's guaraneed to not fail on the fd
> installation side. It's needed for users that can't tolerate spuriously
> closed files, e.g. accepts where the other end doesn't expect it.
> 
> Signed-off-by: Pavel Begunkov <asml.silence@xxxxxxxxx>
> ---
>  fs/io_uring.c | 59 +++++++++++++++++++++++++++++++++++----------------
>  1 file changed, 41 insertions(+), 18 deletions(-)
> 
> diff --git a/fs/io_uring.c b/fs/io_uring.c
> index a864a94364c6..29bca3a1ddeb 100644
> --- a/fs/io_uring.c
> +++ b/fs/io_uring.c

[...]
>  static int io_install_fixed_file(struct io_kiocb *req, struct file *file,
>  				 unsigned int issue_flags, u32 slot_index)
>  {
>  	struct io_ring_ctx *ctx = req->ctx;
>  	bool force_nonblock = issue_flags & IO_URING_F_NONBLOCK;
> +	bool needs_switch = false;
>  	struct io_fixed_file *file_slot;
>  	int ret = -EBADF;
>  
> @@ -8304,12 +8321,31 @@ static int io_install_fixed_file(struct io_kiocb *req, struct file *file,
>  	ret = -EINVAL;
>  	if (slot_index >= ctx->nr_user_files)
>  		goto err;
> +	/*
> +	 * Ignore error, ->rsrc_backup_node is not needed if the slot is empty,
> +	 * and we'd rather not drop the file.
> +	 */
> +	io_rsrc_node_switch_start(ctx);

Can be made easier, will resend shortly

-- 
Pavel Begunkov



[Index of Archives]     [Linux Samsung SoC]     [Linux Rockchip SoC]     [Linux Actions SoC]     [Linux for Synopsys ARC Processors]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]


  Powered by Linux